Internal

Contains a collection of support classes/functions for the PRISM package.

exception prism._internal.FeatureWarning[source]

Generic warning raised for experimental features in PRISM.

General purpose warning class, raised whenever a feature is used that should be considered experimental. Its behavior and API are subject to change, or the entire feature may be removed without a deprecation period.

exception prism._internal.RequestError[source]

Generic exception raised for invalid action requests in the PRISM pipeline.

General purpose exception class, raised whenever a requested action cannot be executed due to it not being allowed or possible in the current state of the Pipeline instance.

exception prism._internal.RequestWarning[source]

Generic warning raised for (future) action requests in the PRISM pipeline that may not be useful.

General purpose warning class, raised whenever a requested action may not produce appropriate or expected results due to the current state of the Pipeline instance. It is also raised if an obtained result can lead to such an action in the future.

class prism._internal.CFilter(MPI_rank)[source]

Custom Filter class that only allows the controller rank to log messages to the logfile. Calls from worker ranks are ignored.

class prism._internal.PRISM_Logger(*args, **kwargs)[source]

Special Logger class that allows for special filters to be set more easily.

class prism._internal.RFilter(MPI_rank)[source]

Custom Filter class that prepends the world rank of the MPI process that calls it to the logging message. If the size of MPI.COMM_WORLD is 1, this filter does nothing.

prism._internal.check_compatibility(emul_version)[source]

Checks if the provided emul_version is compatible with the current version of PRISM. Raises a RequestError if False and indicates which version of PRISM still supports the provided emul_version.

prism._internal.check_vals(values, name, *args)[source]

Checks if all values in provided input argument values with name meet all criteria given in args. If no criteria are given, it is checked if all values are finite. Returns values (0 or 1 in case of bool) if True and raises a ValueError or TypeError if False.

Parameters:
  • values (array_like of {int, float, complex, str, bool}) – The values to be checked against all given criteria in args. It must be possible to convert values to a ndarray object.
  • name (str) – The name of the input argument, which is used in the error message if a criterion is not met.
  • args (tuple of {‘bool’, ‘complex’, ‘float’, ‘int’, ‘neg’, ‘nneg’, ‘normal’, ‘npos’, ‘nzero’, ‘pos’, ‘str’}) – Sequence of strings determining the criteria that values must meet. If args is empty, it is checked if values are finite.
Returns:

return_values (array_like of {int, float, complex, str}) – If args contained ‘bool’, returns 0s or 1s. Else, returns values.

Notes

If values contains integers, but args contains ‘float’, return_values will be cast as float.

prism._internal.get_PRISM_File(prism_hdf5_file)[source]

Returns a class definition PRISM_File(mode, emul_s=None, **kwargs).

This class definition is a specialized version of the File class with the filename automatically set to prism_hdf5_file and added logging to the constructor and destructor methods.

Parameters:prism_hdf5_file (str) – Absolute path to the master HDF5-file that is used in a Pipeline instance.
Returns:PRISM_File (class) – Definition of the class PRISM_File(mode, emul_s=None, **kwargs).
prism._internal.get_formatter()[source]

Returns a Formatter object containing the default logging formatting.

prism._internal.get_handler(filename)[source]

Returns a Handler object containing the default logging handling settings.

prism._internal.get_info()[source]

Prints a string that gives an overview of all information relevant to the PRISM package distribution.

prism._internal.getCLogger(name=None)[source]

Creates a PRISM_Logger instance with name, adds the CFilter to it and returns it.

prism._internal.getLogger(name=None, filters=None)[source]

Creates a PRISM_Logger instance with name and adds the provided filters to it. The returned PRISM_Logger instance is a child of the base PRISM_Logger created with set_base_logger(), but has its name changed (such that the parent name does not show up in the log-file).

Other Parameters:
 
  • name (str or None. Default: None) – The name of the PRISM_Logger instance to create. If None, initialize the base PRISM_Logger instead.
  • filters (list of str or None. Default: None) – List of strings naming the filters that must be applied to the created PRISM_Logger instance. If None or the PRISM_Logger instance already existed, no filters will be applied.
Returns:

logger (PRISM_Logger object) – The created PRISM_Logger instance.

prism._internal.getRLogger(name=None)[source]

Creates a PRISM_Logger instance with name, adds the RFilter to it and returns it.

prism._internal.move_logger(working_dir)[source]

Moves the base PRISM_Logger from the current working directory to the given working_dir, and then restarts it again.

Parameters:working_dir (str) – String containing the directory the log-file needs to be moved to.
prism._internal.np_array(obj, *args, **kwargs)[source]

Returns np.array(obj, *args, copy=False, **kwargs).

prism._internal.set_base_logger(filename=None)[source]

Initializes the base PRISM_Logger, from which all other PRISM_Logger instances are derived.

Other Parameters:
 filename (str or None. Default: None) – String containing the name of the log-file that is opened. If None, a new log-file will be created.