Utilities¶
Find below the emdfile module-level and class-level utilities.
Note that emdfile also contains an N-dimensional progress bar utility, curtesy of Steven E. Zeltmann.
Module Level Utilities¶
- emdfile.utils._is_EMD_file(filepath)¶
Returns True iff filepath points to a valid EMD 1.0 file.
- emdfile.utils._get_EMD_version(filepath, rootgroup=None)¶
Returns the version (major,minor,release) of an EMD file.
- emdfile.utils._version_is_geq(current, minimum)¶
Returns True iff current version (major,minor,release) is greater than or equal to minimum.”
- emdfile.utils._get_UUID(filepath)¶
Returns the UUID of an EMD file, or if unavailable returns -1.
- emdfile.utils._read_metadata(group, name)¶
Returns a Metadata instance called name stored in the EMD node at group. Returns False otherwise.
- emdfile.utils._get_EMD_rootgroups(filepath)¶
Returns a list of root groups in an EMD 1.0 file.
Class Level Utilities¶
- emdfile.classes.utils._get_class(grp)¶
Returns a dictionary of Class constructors from corresponding strings
- emdfile.classes.utils._get_dependent_packages()¶
Searches packages with the top level attribute “_emd_hook” = True. Returns a generator of all such packages
- emdfile.classes.utils._walk_module_find_classes(mod, dic, depth=0, maxdepth=6)¶
Searches the tree of a Python module for emd classes, and populates dictionary dic with them
N-dimensional Progress Bar¶
tqdmnd is an extension of the classic tqdm progress-bar module to support for-loops nested to any level. See also here for Steve’s standalone version.
- emdfile.tqdmnd(*args, **kwargs)¶
An N-dimensional extension of tqdm providing an iterator and progress bar over the product of multiple iterators.
Example Usage:
>>> for x,y in tqdmnd(5,6): >>> <expression>
is equivalent to
>>> for x in range(5): >>> for y in range(6): >>> <expression>
with a tqdmnd-style progress bar printed to standard output.
- Parameters:
*args (Any number of integers or iterators. Each integer N) – is converted to a range(N) iterator. Then a loop is constructed from the Cartesian product of all iterables.
**kwargs (keyword arguments passed through directly to tqdm.) –
Full details are available at https://tqdm.github.io A few useful ones:
disable (bool): if True, hide the progress bar keep (bool): if True, delete the progress bar after completion unit (str): unit name for the display of iteration speed unit_scale (bool): whether to scale the displayed units and add
SI prefixes
desc (str): message displayed in front of the progress bar
- Returns:
At each iteration, a tuple of indices is returned, corresponding to the values of each input iterator (in the same order as the inputs).
- Return type:
(variable)