PlasmaCalcs.dimensions.subsampling.SubsamplingInfoPathManager
- class PlasmaCalcs.dimensions.subsampling.SubsamplingInfoPathManager(info_dir, *, make=True, exist_ok=True)
Bases:
dictclass that helps manage subsampling info paths.- info_dir: str
- path to subsampling_info directory. Internally will be converted to abspath.
All paths will be stored internally as abspaths.info_dir: subsampling_info info_txt: subsampling_info/subsampling_info.txt info_meta: subsampling_info/subsampling_meta.txt
subclasses might add other paths too.Note: self.basename(key) aliases to os.path.basename(self[key]).
make: whether to create the ‘subsampling_info’ folder if it doesn’t exist yet. exist_ok: if False and any folders to make already exist, crash instead.
- __init__(info_dir, *, make=True, exist_ok=True)
Methods
__init__(info_dir, *[, make, exist_ok])assert_does_not_exist(key)assert_exists(key)assert_isdir(key)assert_isfile(key)basename(key)clear()copy()exists(key)fromkeys([value])get(key[, default])implied([file_or_dir, dir, make])isdir(key)isfile(key)items()keys()pop(k[,d])popitem()setdefault(key[, default])update([E, ]**F)values()Attributes
basename_info_dirbasename_info_metabasename_info_txtkeys_to_make_paths- basename(key)
- returns os.path.basename(self[key])
- clear() None. Remove all items from D.
- copy() a shallow copy of D
- exists(key)
- returns os.path.exists(self[key])
- fromkeys(value=None, /)
- Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)
- Return the value for key if key is in the dictionary, else default.
- classmethod implied(file_or_dir=None, *, dir=None, make=None, **kw)
- returns SubsamplingInfoPathManager implied from path information or current directory.
- file_or_dir: None or str
- None –> look within current directory (or use dir if dir is provided)directory –> info_dir = here if ‘subsampling_info.txt’ contained within it,else look for ‘subsampling_info’ directory to use as info_dir.file –> if ‘subsampling_info.txt’, use info_dir = directory containing file.
- dir: None or str
- ‘subsampling_info’ –> info_dir = dirany other str –> info_dir = dir/subsampling_infoCannot provide dir AND file_or_dir.
- make: None or bool
- None –> use True if dir is provided, else False.
(use cls.basename_info_txt and cls.basename_info_dir instead of ‘subsampling_info.txt’ and ‘subsampling_info’.)
- init_path_strings()
- initialize all path strings. See help(self) for details.
- isdir(key)
- returns os.path.isdir(self[key])
- isfile(key)
- returns os.path.isfile(self[key])
- items() a set-like object providing a view on D's items
- keys() a set-like object providing a view on D's keys
- make_paths()
- create paths for all keys in self.keys_to_make_paths, if the paths don’t exist already.if any paths existed already but not self.exist_ok, crash before making any of them!
- pop(k[, d]) v, remove specified key and return the corresponding value.
- If key is not found, default is returned if given, otherwise KeyError is raised
- popitem()
- Remove and return a (key, value) pair as a 2-tuple.Pairs are returned in LIFO (last-in, first-out) order.Raises KeyError if the dict is empty.
- setdefault(key, default=None, /)
- Insert key with a value of default if key is not in the dictionary.Return the value for key if key is in the dictionary, else default.
- update([E, ]**F) None. Update D from dict/iterable E and F.
- If E is present and has a .keys() method, then does: for k in E: D[k] = E[k]If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = vIn either case, this is followed by: for k in F: D[k] = F[k]
- values() an object providing a view on D's values