SubsamplingInfoPathManager
- class PlasmaCalcs.dimensions.subsampling.SubsamplingInfoPathManager(info_dir, *, make=True, exist_ok=True)
Bases:
dictclass that helps manage subsampling info paths.
info_dir: strpath to subsampling_info directory. Internally will be converted to abspath.All paths will be stored internally as abspaths.info_dir: subsampling_infoinfo_txt: subsampling_info/subsampling_info.txtinfo_meta: subsampling_info/subsampling_meta.txtsubclasses 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.Methods
assert_does_not_exist(key)assert_exists(key)assert_isdir(key)assert_isfile(key)basename(key)returns os.path.basename(self[key])
clear()copy()exists(key)returns os.path.exists(self[key])
fromkeys([value])Create a new dictionary with keys from iterable and values set to value.
get(key[, default])Return the value for key if key is in the dictionary, else default.
implied([file_or_dir, dir, make])returns SubsamplingInfoPathManager implied from path information or current directory.
initialize all path strings.
isdir(key)returns os.path.isdir(self[key])
isfile(key)returns os.path.isfile(self[key])
items()keys()create paths for all keys in self.keys_to_make_paths, if the paths don't exist already.
pop(k[,d])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.
setdefault(key[, default])Insert key with a value of default if key is not in the dictionary.
update([E, ]**F)If E is present and has a .keys() method, then does: for k in E: D[k] = E[k]
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 strNone –> 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 boolNone –> 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