n_const.deprecated

Deprecated items, kept for compatibility.

class Constants(**kwargs)[source]

Bases: DataClass

Fundamental class to declare arbitrary parameters.

Deprecated since version 1.0.1: n_const.constants.Constants will be removed in N-CONST 2.0.0, it’s replaced by n_const.data_format.Constants because this module should be more like config file.

Parameters

kwargs (Any) – Any parameter(s) in name=value style.

classmethod set_values(**kwargs)[source]

Set arbitrary parameters.

Deprecated since version 1.0.1: set_values will be removed in N-CONST 2.0.0, it’s replaced by class constructor Constants(**kwargs) because this method is not intuitive and value protection not necessarily be this hard.

Parameters

kwargs (Any) – Any parameter(s) in name=value style.

Examples

>>> params = Constants.set_values(param1=1, param2='a')
>>> params.param1
1
>>> params["param2"]
'a'
classmethod from_csv(path)[source]

Read CSV file and create Constants. User defined constants. Intended to be used in __init__.py of the packages that depends on this package.

Deprecated since version 1.0.1: from_csv will be removed in N-CONST 2.0.0, the successor won’t be implemented because resolving paths to config files can be problematic.

Parameters
  • name (str) – The name of the Constants instance.

  • path (PathLike) – Path to the CSV file.

Notes

The CSV file is expected to have the following structure; ` col_name1,col_name2,col_name3 ... row_name1,value_2-1,value_3-1 ... row_name2,value_2-2,value_3-2 ... ` Note that column 1 is identical to the row labels.