sasdata.quantities.units module

This file is autogenerated!

Do not edit by hand, instead edit the files that build it (_build_tables.py, _units_base.py)

DDDDDDDDDDDDD NNNNNNNN NNNNNNNN tttt D::::::::::::DDD N:::::::N N::::::N ttt:::t D:::::::::::::::DD N::::::::N N::::::N t:::::t DDD:::::DDDDD:::::D N:::::::::N N::::::N t:::::t

D:::::D D:::::D ooooooooooo N::::::::::N N::::::N ooooooooooo ttttttt:::::ttttttt D:::::D D:::::D oo:::::::::::oo N:::::::::::N N::::::N oo:::::::::::oo t:::::::::::::::::t D:::::D D:::::Do:::::::::::::::o N:::::::N::::N N::::::No:::::::::::::::ot:::::::::::::::::t D:::::D D:::::Do:::::ooooo:::::o N::::::N N::::N N::::::No:::::ooooo:::::otttttt:::::::tttttt D:::::D D:::::Do::::o o::::o N::::::N N::::N:::::::No::::o o::::o t:::::t D:::::D D:::::Do::::o o::::o N::::::N N:::::::::::No::::o o::::o t:::::t D:::::D D:::::Do::::o o::::o N::::::N N::::::::::No::::o o::::o t:::::t D:::::D D:::::D o::::o o::::o N::::::N N:::::::::No::::o o::::o t:::::t tttttt

DDD:::::DDDDD:::::D o:::::ooooo:::::o N::::::N N::::::::No:::::ooooo:::::o t::::::tttt:::::t D:::::::::::::::DD o:::::::::::::::o N::::::N N:::::::No:::::::::::::::o tt::::::::::::::t D::::::::::::DDD oo:::::::::::oo N::::::N N::::::N oo:::::::::::oo tt:::::::::::tt DDDDDDDDDDDDD ooooooooooo NNNNNNNN NNNNNNN ooooooooooo ttttttttttt

dddddddd

EEEEEEEEEEEEEEEEEEEEEE d::::::d iiii tttt BBBBBBBBBBBBBBBBB E::::::::::::::::::::E d::::::d i::::i ttt:::t B::::::::::::::::B E::::::::::::::::::::E d::::::d iiii t:::::t B::::::BBBBBB:::::B EE::::::EEEEEEEEE::::E d:::::d t:::::t BB:::::B B:::::B

E:::::E EEEEEE ddddddddd:::::d iiiiiiittttttt:::::ttttttt B::::B B:::::Byyyyyyy yyyyyyy E:::::E dd::::::::::::::d i:::::it:::::::::::::::::t B::::B B:::::B y:::::y y:::::y E::::::EEEEEEEEEE d::::::::::::::::d i::::it:::::::::::::::::t B::::BBBBBB:::::B y:::::y y:::::y E:::::::::::::::E d:::::::ddddd:::::d i::::itttttt:::::::tttttt B:::::::::::::BB y:::::y y:::::y E:::::::::::::::E d::::::d d:::::d i::::i t:::::t B::::BBBBBB:::::B y:::::y y:::::y E::::::EEEEEEEEEE d:::::d d:::::d i::::i t:::::t B::::B B:::::B y:::::y y:::::y E:::::E d:::::d d:::::d i::::i t:::::t B::::B B:::::B y:::::y:::::y E:::::E EEEEEEd:::::d d:::::d i::::i t:::::t tttttt B::::B B:::::B y:::::::::y

EE::::::EEEEEEEE:::::Ed::::::ddddd::::::ddi::::::i t::::::tttt:::::t BB:::::BBBBBB::::::B y:::::::y E::::::::::::::::::::E d:::::::::::::::::di::::::i tt::::::::::::::t B:::::::::::::::::B y:::::y E::::::::::::::::::::E d:::::::::ddd::::di::::::i tt:::::::::::tt B::::::::::::::::B y:::::y EEEEEEEEEEEEEEEEEEEEEE ddddddddd dddddiiiiiiii ttttttttttt BBBBBBBBBBBBBBBBB y:::::y

y:::::y

y:::::y

y:::::y

y:::::y

yyyyyyy

dddddddd

HHHHHHHHH HHHHHHHHH d::::::d H:::::::H H:::::::H d::::::d H:::::::H H:::::::H d::::::d HH::::::H H::::::HH d:::::d

H:::::H H:::::H aaaaaaaaaaaaa nnnn nnnnnnnn ddddddddd:::::d H:::::H H:::::H a::::::::::::a n:::nn::::::::nn dd::::::::::::::d H::::::HHHHH::::::H aaaaaaaaa:::::an::::::::::::::nn d::::::::::::::::d H:::::::::::::::::H a::::ann:::::::::::::::nd:::::::ddddd:::::d H:::::::::::::::::H aaaaaaa:::::a n:::::nnnn:::::nd::::::d d:::::d H::::::HHHHH::::::H aa::::::::::::a n::::n n::::nd:::::d d:::::d H:::::H H:::::H a::::aaaa::::::a n::::n n::::nd:::::d d:::::d H:::::H H:::::H a::::a a:::::a n::::n n::::nd:::::d d:::::d

HH::::::H H::::::HHa::::a a:::::a n::::n n::::nd::::::ddddd::::::dd H:::::::H H:::::::Ha:::::aaaa::::::a n::::n n::::n d:::::::::::::::::d H:::::::H H:::::::H a::::::::::aa:::a n::::n n::::n d:::::::::ddd::::d HHHHHHHHH HHHHHHHHH aaaaaaaaaa aaaa nnnnnn nnnnnn ddddddddd ddddd

exception sasdata.quantities.units.DimensionError

Bases: Exception

__doc__ = None
__firstlineno__ = 95
__module__ = 'sasdata.quantities.units'
__static_attributes__ = ()
__weakref__

list of weak references to the object

class sasdata.quantities.units.Dimensions(length: int = 0, time: int = 0, mass: int = 0, current: int = 0, temperature: int = 0, moles_hint: int = 0, angle_hint: int = 0)

Bases: object

Note that some SI Base units are not useful from the perspecive of the sasview project, and make things behave badly. In particular: moles and angular measures are dimensionless, and candelas are really a weighted measure of power.

We do however track angle and amount, because its really useful for formatting units

__dict__ = mappingproxy({'__module__': 'sasdata.quantities.units', '__firstlineno__': 98, '__doc__': '\n\nNote that some SI Base units are not useful from the perspecive of the sasview project, and make things\nbehave badly. In particular: moles and angular measures are dimensionless, and candelas are really a weighted\nmeasure of power.\n\nWe do however track angle and amount, because its really useful for formatting units\n\n', '__init__': <function Dimensions.__init__>, 'is_dimensionless': <property object>, '__mul__': <function Dimensions.__mul__>, '__truediv__': <function Dimensions.__truediv__>, '__pow__': <function Dimensions.__pow__>, '__eq__': <function Dimensions.__eq__>, '__hash__': <function Dimensions.__hash__>, '__repr__': <function Dimensions.__repr__>, 'si_repr': <function Dimensions.si_repr>, '__static_attributes__': ('angle_hint', 'current', 'length', 'mass', 'moles_hint', 'temperature', 'time'), '__dict__': <attribute '__dict__' of 'Dimensions' objects>, '__weakref__': <attribute '__weakref__' of 'Dimensions' objects>, '__annotations__': {}})
__doc__ = '\n\nNote that some SI Base units are not useful from the perspecive of the sasview project, and make things\nbehave badly. In particular: moles and angular measures are dimensionless, and candelas are really a weighted\nmeasure of power.\n\nWe do however track angle and amount, because its really useful for formatting units\n\n'
__eq__(other: Self)

Return self==value.

__firstlineno__ = 98
__hash__()

Unique representation of units using Godel like encoding

__init__(length: int = 0, time: int = 0, mass: int = 0, current: int = 0, temperature: int = 0, moles_hint: int = 0, angle_hint: int = 0)
__module__ = 'sasdata.quantities.units'
__mul__(other: Self)
__pow__(power: int | float)
__repr__()

Return repr(self).

__static_attributes__ = ('angle_hint', 'current', 'length', 'mass', 'moles_hint', 'temperature', 'time')
__truediv__(other: Self)
__weakref__

list of weak references to the object

property is_dimensionless

Is this dimension dimensionless (ignores moles_hint and angle_hint)

si_repr()
class sasdata.quantities.units.GreedyAbsDimensionUnitFormatProcessor

Bases: UnitFormatProcessor

__doc__ = None
__firstlineno__ = 445
__module__ = 'sasdata.quantities.units'
__static_attributes__ = ()
class sasdata.quantities.units.NamedUnit(si_scaling_factor: float, dimensions: Dimensions, name: str | None = None, ascii_symbol: str | None = None, latex_symbol: str | None = None, symbol: str | None = None)

Bases: Unit

Units, but they have a name, and a symbol

Si_scaling_factor:

Number of these units per SI equivalent

Parameters:
  • dimensions – Dimensions object representing the dimensionality of these units

  • name – Name of unit - string without unicode

  • ascii_symbol – Symbol for unit without unicode

  • symbol – Unicode symbol

__doc__ = 'Units, but they have a name, and a symbol\n\n:si_scaling_factor: Number of these units per SI equivalent\n:param dimensions: Dimensions object representing the dimensionality of these units\n:param name: Name of unit - string without unicode\n:param ascii_symbol: Symbol for unit without unicode\n:param symbol: Unicode symbol\n'
__eq__(other)

Match other units exactly or match strings against ANY of our names

__firstlineno__ = 357
__hash__ = None
__init__(si_scaling_factor: float, dimensions: Dimensions, name: str | None = None, ascii_symbol: str | None = None, latex_symbol: str | None = None, symbol: str | None = None)
__module__ = 'sasdata.quantities.units'
__repr__()

Return repr(self).

__static_attributes__ = ('ascii_symbol', 'latex_symbol', 'name', 'symbol')
startswith(prefix: str) bool

Check if any representation of the unit begins with the prefix string

class sasdata.quantities.units.ProcessedUnitToken(base_string: str, exponent_string: str, latex_exponent_string: str, exponent: int)

Bases: object

Mid processing representation of formatted units

__annotations__ = {'base_string': <class 'str'>, 'exponent': <class 'int'>, 'exponent_string': <class 'str'>, 'latex_exponent_string': <class 'str'>}
__dataclass_fields__ = {'base_string': Field(name='base_string',type=<class 'str'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'exponent': Field(name='exponent',type=<class 'int'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'exponent_string': Field(name='exponent_string',type=<class 'str'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'latex_exponent_string': Field(name='latex_exponent_string',type=<class 'str'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD)}
__dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False,match_args=True,kw_only=False,slots=False,weakref_slot=False)
__dict__ = mappingproxy({'__module__': 'sasdata.quantities.units', '__firstlineno__': 412, '__annotations__': {'base_string': <class 'str'>, 'exponent_string': <class 'str'>, 'latex_exponent_string': <class 'str'>, 'exponent': <class 'int'>}, '__doc__': 'Mid processing representation of formatted units ', '__static_attributes__': (), '__dict__': <attribute '__dict__' of 'ProcessedUnitToken' objects>, '__weakref__': <attribute '__weakref__' of 'ProcessedUnitToken' objects>, '__dataclass_params__': _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False,match_args=True,kw_only=False,slots=False,weakref_slot=False), '__dataclass_fields__': {'base_string': Field(name='base_string',type=<class 'str'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'exponent_string': Field(name='exponent_string',type=<class 'str'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'latex_exponent_string': Field(name='latex_exponent_string',type=<class 'str'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'exponent': Field(name='exponent',type=<class 'int'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD)}, '__replace__': <function _replace>, '__hash__': None, '__init__': <function ProcessedUnitToken.__init__>, '__repr__': <function ProcessedUnitToken.__repr__>, '__eq__': <function ProcessedUnitToken.__eq__>, '__match_args__': ('base_string', 'exponent_string', 'latex_exponent_string', 'exponent')})
__doc__ = 'Mid processing representation of formatted units '
__eq__(other)

Return self==value.

__firstlineno__ = 412
__hash__ = None
__init__(base_string: str, exponent_string: str, latex_exponent_string: str, exponent: int) None
__match_args__ = ('base_string', 'exponent_string', 'latex_exponent_string', 'exponent')
__module__ = 'sasdata.quantities.units'
__replace__(**changes)
__repr__()

Return repr(self).

__static_attributes__ = ()
__weakref__

list of weak references to the object

base_string: str
exponent: int
exponent_string: str
latex_exponent_string: str
class sasdata.quantities.units.RequiredUnitFormatProcessor(unit: Unit, power: int = 1)

Bases: UnitFormatProcessor

This unit is required to exist in the formatting

__annotations__ = {}
__doc__ = 'This unit is required to exist in the formatting '
__firstlineno__ = 425
__init__(unit: Unit, power: int = 1)
__module__ = 'sasdata.quantities.units'
__static_attributes__ = ('power', 'unit')
apply(scale, dimensions) tuple[float, Dimensions, ProcessedUnitToken]

This will be called to deal with each processing stage

class sasdata.quantities.units.Unit(si_scaling_factor: float, dimensions: Dimensions)

Bases: object

__annotations__ = {}
__dict__ = mappingproxy({'__module__': 'sasdata.quantities.units', '__firstlineno__': 290, '__init__': <function Unit.__init__>, '_components': <function Unit._components>, '__mul__': <function Unit.__mul__>, '__truediv__': <function Unit.__truediv__>, '__rtruediv__': <function Unit.__rtruediv__>, '__pow__': <function Unit.__pow__>, 'equivalent': <function Unit.equivalent>, '__eq__': <function Unit.__eq__>, 'si_equivalent': <function Unit.si_equivalent>, '_format_unit': <function Unit._format_unit>, '__repr__': <function Unit.__repr__>, 'parse': <staticmethod(<function Unit.parse>)>, '__static_attributes__': ('dimensions', 'scale'), '__dict__': <attribute '__dict__' of 'Unit' objects>, '__weakref__': <attribute '__weakref__' of 'Unit' objects>, '__doc__': None, '__hash__': None, '__annotations__': {}})
__doc__ = None
__eq__(other: Unit)

Return self==value.

__firstlineno__ = 290
__hash__ = None
__init__(si_scaling_factor: float, dimensions: Dimensions)
__module__ = 'sasdata.quantities.units'
__mul__(other: Unit)
__pow__(power: int | float)
__repr__()

Return repr(self).

__rtruediv__(other: Unit)
__static_attributes__ = ('dimensions', 'scale')
__truediv__(other: Unit)
__weakref__

list of weak references to the object

_components(tokens: Sequence[UnitToken])
_format_unit(format_process: list[UnitFormatProcessor])
equivalent(other: Unit)
static parse(unit_string: str) Unit
si_equivalent()

Get the SI unit corresponding to this unit

class sasdata.quantities.units.UnitFormatProcessor

Bases: object

Represents a step in the unit processing pipeline

__annotations__ = {}
__dict__ = mappingproxy({'__module__': 'sasdata.quantities.units', '__firstlineno__': 420, '__doc__': 'Represents a step in the unit processing pipeline', 'apply': <function UnitFormatProcessor.apply>, '__static_attributes__': (), '__dict__': <attribute '__dict__' of 'UnitFormatProcessor' objects>, '__weakref__': <attribute '__weakref__' of 'UnitFormatProcessor' objects>, '__annotations__': {}})
__doc__ = 'Represents a step in the unit processing pipeline'
__firstlineno__ = 420
__module__ = 'sasdata.quantities.units'
__static_attributes__ = ()
__weakref__

list of weak references to the object

apply(scale, dimensions) tuple[ProcessedUnitToken, float, Dimensions]

This will be called to deal with each processing stage

class sasdata.quantities.units.UnitGroup(name: str, units: list[NamedUnit])

Bases: object

A group of units that all have the same dimensionality

__dict__ = mappingproxy({'__module__': 'sasdata.quantities.units', '__firstlineno__': 448, '__doc__': 'A group of units that all have the same dimensionality ', '__init__': <function UnitGroup.__init__>, '__static_attributes__': ('name', 'units'), '__dict__': <attribute '__dict__' of 'UnitGroup' objects>, '__weakref__': <attribute '__weakref__' of 'UnitGroup' objects>, '__annotations__': {}})
__doc__ = 'A group of units that all have the same dimensionality '
__firstlineno__ = 448
__init__(name: str, units: list[NamedUnit])
__module__ = 'sasdata.quantities.units'
__static_attributes__ = ('name', 'units')
__weakref__

list of weak references to the object