pystellibs.ezunits package

Submodules

pystellibs.ezunits.pint module

pint

Pint is Python module/package to define, operate and manipulate physical quantities: the product of a numerical value and a unit of measurement. It allows arithmetic operations between them and conversions from and to different units.

copyright:

2012 by Hernan E. Grecco.

license:

BSD, see LICENSE for more details.

class pystellibs.ezunits.pint.AliasDict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list.  For example:  dict(one=1, two=2)[source]

Bases: dict

Methods

clear()

copy()

fromkeys(iterable[, value])

Create a new dictionary with keys from iterable and values set to value.

get(key[, default])

Return the value for key if key is in the dictionary, else default.

items()

keys()

pop(k[,d])

If key is not found, d is returned if given, otherwise KeyError is raised

popitem(/)

Remove and return a (key, value) pair as a 2-tuple.

setdefault(key[, default])

Insert key with a value of default if key is not in the dictionary.

update([E, ]**F)

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values()

add_alias

get_aliased

add_alias(key, value, preferred=False)[source]
get_aliased(key)[source]
exception pystellibs.ezunits.pint.DimensionalityError(units1, units2, dim1=None, dim2=None)[source]

Bases: ValueError

Raised when trying to convert between incompatible units.

exception pystellibs.ezunits.pint.UndefinedUnitError(unit_names)[source]

Bases: ValueError

Raised when the units are not defined in the unit registry.

class pystellibs.ezunits.pint.UnitRegistry(filename='', force_ndarray=False)[source]

Bases: object

The unit registry stores the definitions and relationships between units.

Parameters:
  • filename – path of the units definition file to load. Empty to load the default definition file. None to leave the UnitRegistry empty.

  • force_ndarray – convert any input, scalar or not to a numpy.ndarray.

Methods

add_from_file(filename)

Add units and prefixes defined in a definition text file.

add_prefix(name, value[, aliases])

Add prefix to the registry.

add_unit(name, value[, aliases])

Add unit to the registry.

get_alias(name)

Return the preferred alias for a unit

add_from_file(filename)[source]

Add units and prefixes defined in a definition text file.

add_prefix(name, value, aliases=())[source]

Add prefix to the registry.

add_unit(name, value, aliases=(), **modifiers)[source]

Add unit to the registry.

get_alias(name)[source]

Return the preferred alias for a unit

class pystellibs.ezunits.pint.UnitsContainer(*args, **kwargs)[source]

Bases: dict

The UnitsContainer stores the product of units and their respective exponent and implements the corresponding operations

Methods

clear()

copy()

fromkeys(iterable[, value])

Create a new dictionary with keys from iterable and values set to value.

get(key[, default])

Return the value for key if key is in the dictionary, else default.

items()

keys()

pop(k[,d])

If key is not found, d is returned if given, otherwise KeyError is raised

popitem(/)

Remove and return a (key, value) pair as a 2-tuple.

setdefault(key[, default])

Insert key with a value of default if key is not in the dictionary.

update([E, ]**F)

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values()

add

add(key, value)[source]
pystellibs.ezunits.pint.converter_from_reference(scale, offset, log_base)[source]
pystellibs.ezunits.pint.converter_to_reference(scale, offset, log_base)[source]

Module contents

pint

Pint is Python module/package to define, operate and manipulate physical quantities: the product of a numerical value and a unit of measurement. It allows arithmetic operations between them and conversions from and to different units.

copyright:
  1. 2012 by Hernan E. Grecco.

license:

BSD, see LICENSE for more details.

pystellibs.ezunits.hasUnit(val)[source]