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

ParamDictND

For 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

ParamDict1D.clear()

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.

ParamDict1D.mean()

Calculate the mean of parameter values.

ParamDict1D.median()

Calculate the median of parameter values.

ParamDict1D.median_high()

Calculate the high median of parameter values.

ParamDict1D.median_low()

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.

ParamDict1D.popitem()

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.

ParamDict1D.sum()

Calculate the sum of parameter values.

Attributes

ParamDict1D.key_name

Name to refer to 1-dim scalar keys.

ParamDict1D.value_name

Name to refer to Dict values.