aviary_options_dict.py#
- class aviary.utils.aviary_options_dict.AviaryOptionsDictionary(data=None, parent_name=None)[source]
Bases:
OptionsDictionary
Modified OptionsDictionary that is used by Aviary to store the user_options for a phase.
This subclass adds support for declaring options and getting options with units.
- Parameters:
data (dict) – Dictionary of option name: value to set.
parent_name (str) – Name or class name of System that owns this OptionsDictionary.
- __init__(data=None, parent_name=None)[source]
Initialize all attributes.
- declare(name, default=UNDEFINED, values=None, types=None, desc='', units=None, upper=None, lower=None, check_valid=None, allow_none=False, deprecation=None)[source]
Declare an option.
The value of the option must satisfy the following: 1. If values only was given when declaring, value must be in values. 2. If types only was given when declaring, value must satisfy isinstance(value, types). 3. It is an error if both values and types are given.
- Parameters:
name (str) – Name of the option.
default (object or Null) – Optional default value that must be valid under the above 3 conditions.
values (set or list or tuple or None) – Optional list of acceptable option values.
types (type or tuple of types or None) – Optional type or list of acceptable option types.
desc (str) – Optional description of the option.
upper (float or None) – Maximum allowable value.
lower (float or None) – Minimum allowable value.
check_valid (function or None) – User-supplied function with arguments (name, value) that raises an exception if the value is not valid.
allow_none (bool) – If True, allow None as a value regardless of values or types.
recordable (bool) – If True, add to recorder.
set_function (None or function) – User-supplied function with arguments (Options metadata, value) that pre-processes value and returns a new value.
deprecation (str or tuple or None) – If None, it is not deprecated. If a str, use as a DeprecationWarning during __setitem__ and __getitem__. If a tuple of the form (msg, new_name), display msg as with str, and forward any __setitem__/__getitem__ to new_name.
- declare_options()[source]
Hook for declaring options for a phase builder.
- get_val(key, units=None)[source]
Return the current value for the requested default.
- Parameters:
key (str) – the name of the item
units (str ('unitless')) – the units of the returned value
- Return type:
val
- to_phase_info()[source]
Returns an equivalent phase_info dictionary for this options dict.
- Returns:
Equivalent phase_info.
- Return type:
dict
- aviary.utils.aviary_options_dict.units_setter(opt_meta, value)[source]
Convert units for a tuple with form (val, “unitstring”).
- Parameters:
opt_meta (dict) – Dictionary of entries for the option.
value (any) – New value for the option.
- Returns:
Post processed value to set into the option.
- Return type:
any