QAnalysis#

class QAnalysis(*args, **kwargs)[source]#

QAnalysis is the core class from which all Metal analysis classes are derived.

The class defines the user interface for working with analysis.

For front-end user:
  • Manipulates the setup dictionary to fine-tune the analysis parameters.

For creator user:
  • Creates a class that inherits this or the QSimulation classes.

  • Implements the run and run_*** methods to define the analysis procedures.

  • Defines the methods to communicate with the QRenderers. (see QSimulation)

  • Defines default_setup, which describes the parameteric interface to the analysis class.

Default Setup:

Nested default setup parameters can be overwritten with the setup_update method, or directly by using the dot operator enabled by the Dict type.

Creates a new Analysis object with a setup derived from the default_setup Dict.

Attributes

data_labels = []#

Default data labels.

default_setup = {}#

Default setup.

logger#

Returns the logger.

setup#

Dictionary intended to be used to modify the analysis behavior.

Returns:

Current setup.

Return type:

Dict

Type:

Getter

supported_data#

Set that contains the names of the variables supported from the analysis.

Returns:

list of supported variable names.

Return type:

set

Type:

Getter

Methods

clear_data(data_name: str | list | None = None)[source]#

Clear data. Can optionally specify one or more labels to delete those labels and data.

Parameters:

data_name (Union[str, list], optional) – Can list specific labels to clean. Defaults to None.

get_data(data_name: str | None = None)[source]#

Retrieves the analysis module data. Returns None if nothing is found.

Parameters:

data_name (str, optional) – Label to query for data. If not specified, the entire dictionary is returned. Defaults to None.

Returns:

The data associated with the label, or the entire list of labels and data.

Return type:

Any

get_data_labels() list[source]#

Retrieves the list of data labels currently set. Returns None if nothing is found.

Returns:

list of data names

Return type:

list

print_run_args()[source]#

Prints the args and kwargs that were used in the last run() of this Analysis instance.

abstract run(*args, **kwargs)[source]#

Abstract method. Must be implemented by the subclass. Use as an alias for the main analysis method. Call the main analysis method run_***(). Subclass implementation of run() must: * always call the main analysis method(s) named run_***(). * never implement the analysis, which should be instead in the method run_***().

run_***() must always call self.save_run_args(*args, **kwargs) to save the inputs.

Example

def run(self, *args, **kwargs):
    self.run_sim(*args, **kwargs)
def run_sim(self, *args, **kwargs):
    self.save_run_args(*args, **kwargs)
    <......>

Make sure the name of the method run_***() does not conflict with that of another QAnalysis subclass, in case you expect them to be both inherited from the same subclass.

run_sweep(*args, **kwargs)[source]#

User requests sweeper based on arguments from Sweeper.run_sweep().

save_run_args(**kwargs)[source]#

Intended to be used to store the kwargs passed to the run() method, for repeatability and for later identification of the QAnalysis instance.

set_data(data_name: str, data: Any)[source]#

Stores data in a structure for later retrieval. Could be output, intermediate or even input data. Current implementation uses Dict()

Parameters:
  • data_name (str) – Label for the data. Used a storage key.

  • data (Any) – Free format

setup_update(section: str | None = None, **kwargs)[source]#

Intended to modify multiple setup settings at once, while retaining previous settings. If you intend to change a single setting, the better way is: setup.setting1 = value.

Parameters:

section (str) – Setup section that contains the setup keys to update.