armi.reactor.parameters.parameterCollections module¶
-
armi.reactor.parameters.parameterCollections.
GLOBAL_SERIAL_NUM
= 54494¶ 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.
_ParameterCollectionType
[source]¶ Bases:
type
Simple metaclass to make sure that expected class attributes are present.
These attributes shouldn’t be shared among different subclasses, so this makes sure that each subclass gets its own.
-
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()
.-
assigned
¶ 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.- Type
int Flag
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 object>¶
-
_allFields
= ['_backup', '_hist', '_p_serialNum', 'assigned']¶
-
_ArmiObject
= None¶
-
_slots
= {'_backup', '_hist', '_p_serialNum', 'assigned', 'serialNum'}¶
-
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.
-
__deepcopy__
(memo)[source]¶ Returns a new instance of ParameterCollection with a new
serialNum
.Notes
This operates under the assumption that
__deepcopy__
is used when needing a new instance, which should get its own serial number. This follows from the assumption that parameter collections are typically copied when copying an ArmiObject to which it may belong. In this case, serialNum needs to be incremented so that the objects are unique. serialNum is special.
-
__reduce__
()[source]¶ Implement pickle __reduce__ protocol.
We need to do this because most subclasses of ParameterCollection are created from a metaclass, and are therefore not top-level objects and not trivially picklable. This implementation works by asking the ArmiObject itself to give an instance of its associated ParameterCollection class, then setting its state.
-
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
¶ 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
-