pyrokinetics.units.PyroUnitRegistry#

class pyrokinetics.units.PyroUnitRegistry(*args, **kwargs)[source]#

Bases: UnitRegistry

Specialisation of pint.UnitRegistry that expands some methods to be aware of pyrokinetics normalisation objects.

Parameters:
  • args (Any)

  • kwargs (Any)

__init__()[source]#

Methods

UnitsContainer(*args, **kwargs)

rtype:

UnitsContainer

__init__()

add_context(context)

Add a context object to the registry.

as_system(system)

Temporarily change the current system of units

check(*args)

Decorator to for quantity type checking for function inputs.

context(*names, **kwargs)

Used as a context manager, this function enables to activate a context which is removed after usage.

convert(value, src, dst[, inplace])

Convert value from some source to destination units.

define(definition)

Add unit to the registry.

disable_contexts([n])

Disable the last n enabled contexts.

enable_contexts(*names_or_contexts, **kwargs)

Enable contexts provided by name or by object.

get_base_units(input_units[, check_nonmult, ...])

Convert unit or dict of units to the plain units.

get_compatible_units(input_units[, ...])

rtype:

frozenset[PlainUnit]

get_dimensionality(input_units)

Convert unit or dict of units or dimensions to a dict of plain dimensions dimensions

get_group(name[, create_if_needed])

Return a Group.

get_name(name_or_alias[, case_sensitive])

Return the canonical name of a unit.

get_root_units(input_units[, check_nonmult])

Convert unit or dict of units to the root units.

get_symbol(name_or_alias[, case_sensitive])

Return the preferred alias for a unit.

get_system(name[, create_if_needed])

Return a Group.

is_compatible_with(obj1, obj2, *contexts, ...)

check if the other object is compatible

load_definitions(file[, is_resource])

Add units and prefixes defined in a definition text file.

parse_expression(input_string[, case_sensitive])

Parse a mathematical expression including units and return a quantity object.

parse_pattern(input_string, pattern[, ...])

Parse a string with a given regex pattern and returns result.

parse_unit_name(unit_name[, case_sensitive])

Parse a unit to identify prefix, unit name and suffix by walking the list of prefix and suffix.

parse_units(input_string[, as_delta, ...])

Parse a units expression and returns a UnitContainer with the canonical names.

parse_units_as_container(input_string[, ...])

rtype:

UnitsContainer

pi_theorem(quantities)

Builds dimensionless quantities using the Buckingham π theorem

remove_context(name_or_alias)

Remove a context from the registry and return it.

set_fmt_locale(loc)

Change the locale used by default by format_babel.

setup_matplotlib([enable])

Set up handlers for matplotlib's unit support.

with_context(name, **kwargs)

Decorator to wrap a function call in a Pint context.

wraps(ret, args[, strict])

Wraps a function to become pint-aware.

Attributes

cache_folder

default_format

Default formatting string for quantities.

default_system

fmt_locale

Babel.Locale instance or None

non_int_type

sys

System

default_as_delta

When performing a multiplication of units, interpret non-multiplicative units as their delta counterparts.

separate_format_defaults

mode used to fill in the format defaults

auto_reduce_dimensions

Determines if dimensionality should be reduced on appropriate operations.

autoconvert_to_preferred

Determines if units will be converted to preffered on appropriate operations.

mpl_formatter

sets the formatter used when plotting with matplotlib

case_sensitive

Default unit case sensitivity

Quantity#

alias of PyroQuantity

as_system(system)[source]#

Temporarily change the current system of units