armi.reactor.parameters.parameterDefinitions module

This module contains the code necessary to represent parameter definitions.

``ParameterDefinition``s are the metadata that describe specific parameters, and aid in enforcing certain rules upon the parameters themselves and the parameter collections that contain them.

This module also describes the ParameterDefinitionCollection class, which serves as a specialized container to manage related parameter definitions.

class armi.reactor.parameters.parameterDefinitions.Category[source]

Bases: object

A “namespace” for storing parameter categories.

assignInBlueprints = 'assign in blueprints'
retainOnReplacement = 'retain on replacement'
volumeIntegrated = 'volumeIntegrated'
fluxQuantities = 'fluxQuantities'
multiGroupQuantities = 'multi-group quantities'
class armi.reactor.parameters.parameterDefinitions.ParamLocation[source]

Bases: enum.Flag

Represents point which a parameter is physically meaningful.

TOP = 1
CENTROID = 2
BOTTOM = 4
AVERAGE = 10
MAX = 16
CORNERS = 32
EDGES = 64
VOLUME_INTEGRATED = 128
CHILDREN = 256
class armi.reactor.parameters.parameterDefinitions.NoDefault[source]

Bases: object

Class used to allow distinction between not setting a default and setting a default of None

class armi.reactor.parameters.parameterDefinitions.Parameter(name, units, description, location, saveToDB, default, setter, categories)[source]

Bases: object

Metadata about a specific parameter

collectionType
name
fieldName
location
saveToDB
description
units
default
categories
assigned
__eq__(other)[source]

Name defines equality

__lt__(other)[source]

Sort alphabetically by name

__set__(obj, val)[source]

This is a property setter, see Python documentation for “descriptor”.

__get__(obj, cls=None)[source]

This is a property getter, see Python documentation for “descriptor”.

Notes

We do not check to see if cls != None. This is an optimization choice, that someone may deem unnecessary. As a result, unlike Python’s property class, a subclass cannot override the getter method.

setter(setter)[source]

Decorator method for assigning setter.

Notes

Unlike the traditional Python property class, this does not return a new instance of a Parameter; therefore it cannot be reassigned in the same way that a Python property can be.

Examples

>>> class MyParameterCollection(parameters.ParameterCollection):
...     mass = parameters.Parameter(...)
...     @mass.setter
...     def mass(self, value):
...         if value < 0:
...             raise ValueError("Negative mass is not possible, consider a diet.")
...         self._p_speed = value
backUp()[source]

Back up the assigned state.

restoreBackup(paramsToApply)[source]

Restore the backed up state.

atLocation(loc)[source]

True if parameter is defined at location.

class armi.reactor.parameters.parameterDefinitions.ParameterDefinitionCollection[source]

Bases: object

A very specialized container for managing parameter definitions.

Notes

_representedTypes is used to detect if this ParameterDefinitionCollection contains definitions for only one type. If the collection only exists for 1 type, the lookup (__getitem__) can short circuit O(n) logic for O(1) dictionary lookup.

__getitem__(name)[source]

Get a parameter by name.

Notes

This method might break if the collection is for multiple composite types, and there exists a parameter with the same name in multiple types.

add(paramDef)[source]

add a Parameter to this collection.

extend(other)[source]

Grow a parameter definition collection by another parameter definition collection

inCategory(categoryName)[source]

Create a ParameterDefinitionCollection that contains definitions that are in a specific category.

atLocation(paramLoc)[source]

Make a param definition collection with all defs defined at a specific location.

Parameters can be defined at various locations within their container based on ParamLocation. This allows selection by those values.

since(mask)[source]

Create a ParameterDefinitionCollection that contains definitions that have been modified since a specific set of actions.

unchanged_since(mask)[source]

Create a ParameterDefinitionCollection that contains definitions that have not been modified since a specific set of actions. This is the complementary set of the collection returned by since.

forType(compositeType)[source]

Create a ParameterDefinitionCollection that contains definitions for a specific composite type.

resetAssignmentFlag(mask)[source]

Clear the assigned flag for a certain operation on all parameters.

These flags will get set by the param definition setters if they get changed again.

Notes

See http://www.vipan.com/htdocs/bitwisehelp.html to understand the bitwise operations

setAssignmentFlag(mask)[source]
byNameAndType(name, compositeType)[source]

Get a Parameter by compositeType and name.

byNameAndCollectionType(name, collectionType)[source]

Get a Parameter by compositeType and name.

property categories

Get the categories of all the Parameter instances within this collection

property names
lock()[source]
property locked
toWriteToDB(assignedMask)[source]

Get a list of acceptable parameters to store to the database for a level of the data model.

Parameters

assignedMask (int) – a bitmask to down-filter which params to use based on how “stale” they are.

createBuilder(*args, **kwargs)[source]

Create an associated object that can create definitions into this collection

Using the returned ParameterBuilder will add all defined parameters to this ParameterDefinitionCollection, using the passed arguments as defaults. Arguments should be valid arguments to ParameterBuilder.__init__()

class armi.reactor.parameters.parameterDefinitions.ParameterBuilder(location=<ParamLocation.AVERAGE: 10>, default=<class 'armi.reactor.parameters.parameterDefinitions.NoDefault'>, categories=None, saveToDB=True)[source]

Bases: object

Factory for creating Parameter and parameter properties

Create a ParameterBuilder

associateParameterDefinitionCollection(paramDefs)[source]

Associate this parameter factory with a specific ParameterDefinitionCollection

Subsequent calls to defParam will automatically add the created ParameterDefinitions to this ParameterDefinitionCollection. This results in a cleaner syntax when defining many ParameterDefinitions.

defParam(name, units, description, location=None, saveToDB=<class 'armi.reactor.parameters.parameterDefinitions.NoDefault'>, default=<class 'armi.reactor.parameters.parameterDefinitions.NoDefault'>, setter=<class 'armi.reactor.parameters.parameterDefinitions.NoDefault'>, categories=None)[source]

Create a parameter as a property (with get/set) on a class

Parameters
  • units (str) – string representation of the units

  • name (str) – the official name of the parameter

  • location (str) – string representation of the location the attribute is applicable to, such as average, max, etc.

  • saveToDB (bool) – Boolean indicator as to whether the parameter should be written to the database. The actual default is defined by the ParameterBuilder, and is True.

  • default (immutable type) – a default value for this parameter which must be an immutable type. If the type is mutable, e.g. a list, dict, an exception should be raised, or unknown behavior.

  • setter (None or callable) – If None, there is no direct way to set the parameter. If some other callable method, (which may have the same name as the property!) then the setter method is used instead.

Notes

It is not possible to initialize the parameter on the class this method would be used on, because there is no instance (i.e. self) when this method is run. However, this method could access a globally available set of definitions, if one existed.