ParamDict1D#
- class ParamDict1D(mapping=None, /, *, key_name=None, value_name=None)#
Custom subclass of dict to define parameters with 1-dim scalar keys.
Requires all keys to be unique scalars (such as int, str, pd.Timestamp, etc.) and all values to be int or float.
- Parameters:
- mappingdict or dict-like mapping, optional
Input data to be encapsulated in the ParamDict.
- key_namestr, optional
Name to refer to 1-dim scalar keys - not used internally, and solely for user reference.
- value_namestr, optional
Name to refer to parameter values - not used internally, and solely for user reference.
- Raises:
- TypeError
If input includes key(s) that are not scalar (any iterable except string).
- TypeError
If input includes value(s) that are not int or float.
See also
ParamDictNDFor N-dim tuple keys.
Examples
Constructing empty to populate later:
>>> ParamDict1D() ParamDict1D: {}
Constructing with a mapping:
>>> ParamDict1D( ... {'JAN': 31, 'FEB': 28, 'MAR': 31}, ... key_name='MONTH', ... value_name='DAYS', ... ) ParamDict1D: MONTH -> DAYS {'JAN': 31, 'FEB': 28, 'MAR': 31}
Methods
Remove all items from the ParamDict.
ParamDict1D.get(key[, default])Get the parameter value for the specified key, or the default if not found.
ParamDict1D.lookup(key)Get the parameter value for the specified key, or zero if it is not found.
Calculate the mean of parameter values.
Calculate the median of parameter values.
Calculate the high median of parameter values.
Calculate the low median of parameter values.
ParamDict1D.pop(key[, default])Remove the specified key and return it's parameter value, or the default if not found.
Remove and return the last inserted key and parameter value pair from the ParamDict.
ParamDict1D.setdefault(key, default, /)Get the parameter value for the specified key, or the default if not found.
Calculate the sum of parameter values.
Attributes
Name to refer to 1-dim scalar keys.
Name to refer to Dict values.