armi.reactor.parameters.parameterCollections module¶
- armi.reactor.parameters.parameterCollections.GLOBAL_SERIAL_NUM = 54495¶
The serial number for all ParameterCollections
This is a counter of the number of instances of all types. They are useful for tracking items through the history of a database.
Warning
This is not MPI safe. We also have not done anything to make it thread safe, except that the GIL exists.
- class armi.reactor.parameters.parameterCollections.ParameterCollection(_state: Optional[List[Any]] = None)[source]¶
Bases:
object
An empty class for holding state information in the ARMI data structure.
A parameter collection stores one or more formally-defined values (“parameters”). Until a given ParameterCollection subclass has been instantiated, new parameters may be added to its parameter definitions (e.g., from plugins). Upon first instantiation,
applyParameters()
will be called, binding the parameter definitions to the Collection class as descriptors.It is illegal to redefine a parameter with the same name in the same class, or its subclasses, and attempting to do so should result in exceptions in
applyParameters()
.- Variables
~ParameterCollection._backup (str) – A pickle dump of the __getstate__, or None.
~ParameterCollection._hist (dict) – Keys are
(paramName, timeStep)
.~ParameterCollection.assigned (int Flag) –
indicates the synchronization state of the parameter collection. This is used to reduce the amount of information that is transmitted during database, and MPI operations as well as determine the collection’s state when exiting a
Composite.retainState
.This attribute when used with the
Parameter.assigned
attribute allows us to efficiently perform many operations.
See also
armi.reactors.parameters
Create a new ParameterCollection instance.
- Parameters
_state – Optional list of parameter values, ordered by _allFields. Passed values should come from a call to __getstate__(). This should only be used internally to this model.
- pDefs: armi.reactor.parameters.parameterDefinitions.ParameterDefinitionCollection = <armi.reactor.parameters.parameterDefinitions.ParameterDefinitionCollection object>¶
- classmethod applyParameters()[source]¶
Apply the definitions from a ParameterDefinitionCollection as properties.
This places the parameter definitions in the associated ParameterDefinitionCollection onto this ParameterCollection class as class attributes. In the process it recursively calls the same method on base classes, and adds their parameter definitions as well. Since each instance of Parameter implements the descriptor protocol, these are effectively behaving as
@property
-style accessors.This function must act on each ParameterCollection subclass before the first instance is created. Subsequent calls will short-circuit. Before calling this method, it is possible to add more Parameters to the associated ParameterDefinitionCollection,
cls.pDefs
. After calling this method, the ParameterDefinitionCollection will be locked, preventing any further additions.This method is called in the
__init__()
method, but can also be called proactively to compile the parameter definitions earlier, if desired.
- get(key, default=None)[source]¶
Return a requested parameter value, if possible.
This functions similarly to the same method on a dict or similar. If there is a value present for the requested parameter on this parameter collection, return it. Otherwise, return the supplied default. The main reason for using this is for safely attempting to access a parameter that doesn’t have a default value, and may not have been set. Other methods for accessing parameters would raise an exception.
- property paramDefs: armi.reactor.parameters.parameterDefinitions.ParameterDefinitionCollection¶
Get the
ParameterDefinitionCollection
associated with this instance.This serves as both an alias for the pDefs class attribute, and as a read-only accessor for them. Most non-paramter-system related interactions with an object’s
ParameterCollection
should go through this. In the future, it probably makes sense to make thepDefs
that theapplyDefinitions
andResolveParametersMeta
things are sensitive to more hidden from outside the parameter system.
- getSyncData()[source]¶
Get all changed parameters SINCE_LAST_DISTRIBUTE_STATE (or
syncMpiState
).If this ParmaterCollection (proxy for a
Composite
) has been modifiedSINCE_LAST_DISTRIBUTE_STATE
, this will return a dictionary of parameter name keys and values, otherwiseNone
.
- restoreBackup(paramsToApply)[source]¶
Restore the backed up the state in a from a pickle.
- Parameters
paramsToApply (list of ParmeterDefinitions) – restores the state of all parameters not in paramsToApply
- serialNum¶
Metadata about a specific parameter