Extract base classes

Classes to manipulate output from job folders.

class pylada.jobfolder.extract.AbstractMassExtract(path=None, view=None, excludes=None, dynamic=False, ordered=True, naked_end=None, unix_re=True)[source]

Bases: object

Collects extraction methods from different job-folders.

Wraps around a root job folder and provides means to access it (or something related to it). In practice, a derived class will hold a list of somethings which does something good for a particular folder. This is a base class, concerned mostly with providing a rich mapping and attribute access interface. It allows the user to focus on a small set of executable folders via the mapping ([]) methods, e.g. a view of the folders. The attributes of the wrapped somethings of the current view are retrieved into a forwarding dict <pylada.jobfolder.forwardingdict.ForwardingDict.

The __iter_alljobs__() method should be implemented within derived classes. It should yield for each executable folder a tuple consisting of the name of that folder and the relevant something.

__init__(path=None, view=None, excludes=None, dynamic=False, ordered=True, naked_end=None, unix_re=True)[source]

Initializes extraction object.

Parameters:
  • path (str) – Root directory for which to investigate all subdirectories. If None, uses current working directory.
  • view (str) – Pattern which the job names must match to be included in the extraction. Ignored if None.
  • dynamic (bool) – If true, chooses a slower but more dynamic caching method. Only usefull for ipython shell.
  • ordered (bool) – If true, uses OrderedDict rather than conventional dict.
  • naked_end (bool) – True if should return value rather than dict when only one item.
  • unix_re (bool) – Converts regex patterns from unix-like expression.
Para excludes:

List of patterns which the job names must not match to be included in the extraction. Ignored if None.

rootpath[source]

Root of the directory-tree to trawl for OUTCARs.

excludes[source]

Patterns to exclude.

view

Current view into the map of extraction object. Filters out the names which do not fit the view. It should be either a regex or a unix file-completion like string. The behavior is controled by pylada.unix_re

__getitem__(name)[source]

Returns a view of the current job-dictionary.

Note

normpath returns a valid path when descending below root, e.g.``normpath(‘/../../other’) == ‘/other’), so there won’t be any errors on that account.

__contains__(key)[source]

Returns True if key is valid and not empty.

__iter__()[source]

Iterates through all job names.

iteritems()[source]

Iterates through all extraction objects and names.

itervalues()[source]

Iterates through all extraction objects.

iterkeys()[source]

Iterates through all extraction objects.

items()[source]

Iterates through all extraction objects and names.

values()[source]

Iterates through all extraction objects.

keys()[source]

Iterates through all extraction objects.

avoid(excludes)[source]

Returns a new object with further exclusions.

Parameters:excludes (str or list of str or None) – Pattern or patterns to exclude from output.

The goal of this function is to work as an anti operator [], i.e. by excluding from the output anything that matches the patterns, rather including only those which match the pattern. This is strickly equivalent to:

>>> other = massextract.copy(excludes=excludes)
>>> other.excludes.extend(massextract.excludes)

and then doing calculations with other. The advantage is that it can all be done on one line.

If the excludes argument is None or an empty list, then the returned object will not exlude anything.

uncache()[source]

Uncache values.

iterfiles(**kwargs)[source]

Iterates over output/input files.

This is rerouted to all extraction objects.

shallow_copy(**kwargs)[source]

Returns a shallow copy.

Parameters:kwargs – Any keyword attribute will modify the corresponding attribute of the copy.

See also

pylada.vasp.extract.MassExtract extracts a directory and its subdirectories for vasp calculations.

Previous topic

Result mass extraction

Next topic

Forwarding dictionary

This Page