SubsamplingResultPathManager
- class PlasmaCalcs.dimensions.subsampling.SubsamplingResultPathManager(snaps_dir, make=True, exist_ok=True)
Bases:
SubsamplingInfoPathManagerclass that helps manage paths related to results of subsampling.
“Result of subsampling” appears in folder structure as:RUNDIR/subsampling_result/SNAPSDIRRUNDIR/subsampling_result/subsampling_infoContrast this with interpreting subsampled data, which expects folder structure:RUNDIR/SNAPSDIR (of subampled data)RUNDIR/subsampling_infoThe idea is that the contents of subsampling_result may be treated as a new RUNDIR.- snaps_dir: str
- path to snaps directory. Internally will be converted to abspath.
All paths will be stored internally as abspaths:run_dir: RUNDIR # abspath to any directory. snaps_dir: RUNDIR/SNAPSDIR result_dir: RUNDIR/subsampling_result # [TODO] allow for other names here as well, e.g. subsampling_result_N. subsampled_snaps_dir: RUNDIR/subsampling_result/SNAPSDIR info_dir: RUNDIR/subsampling_result/subsampling_info info_txt: RUNDIR/subsampling_result/subsampling_info/subsampling_info.txt info_meta: RUNDIR/subsampling_result/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 subsampling-related folders if they 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.
return dict of storage size (in bytes) of snaps_dir and subsampled_snaps_dir.
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_txtbasename_result_dirkeys_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!
- nbytes_snaps_dirs()
return dict of storage size (in bytes) of snaps_dir and subsampled_snaps_dir.
Keys will be: ‘nbytes_snaps_dir’, ‘nbytes_subsampled_snaps_dir’.Vals will be nbytes (int) if path exists, else None.
- 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