Definition filesΒΆ

natu’s constants and units are defined in INI files. Four files are loaded by default:

Other files can be added by appending the definitions list in natu.config. The files are processed sequentially, and the definitions of symbols can reference previous symbols. These constants, functions, and classes are defined before the first file:

The INI format is very similar to the tables in the pages for the files listed above. An equals sign separates the first two columns (“Symbol” and “Expression”), a comma starts the “Prefixable” column, and a semicolon starts the last column (“Name & notes”).

The “Prefixable” column may be True, False, or empty. A unit has a True or a False “Prefixable” entry. If a unit is prefixable, SI prefixes are added upon access. A constant has an empty “Prefixable” entry. Constants are never prefixable.

Single-character SI prefixes take precedence over the two-character prefix ‘da’ (deca). As a hypothetical example, if a unit with name and symbol ‘am’ is defined, ‘dam’ will refer to the deciam, not the decametre. Also, non-prefixed units override the prefixed ones. For example, if a unit named ‘dam’ is established, it will override the decametre (and deciam), which has the same symbol.

The “Name & notes” column is ignored. It is only included for reference.

Some units such as degC and Np are not simple scaling factors. The “Expression” entry of these units contains a tuple with two functions. The first function maps a number to a quantity. The second function is its inverse. These are the first two arguments to construct a lambda unit (LambdaUnit).

SI prefixes can be applied to previous symbols except in the definition of lambda units.

The sections of the INI files are only for organization (though required). The submodules of natu.groups do not rely on the sections. The dimensions of the derived constants and units are calculated and used instead.

Warning

Be sure that you use definition files from a trusted source. Parts of the files are processed using eval(), which is susceptible to malicious code.