mudu.base
base module for mudu.
Attributes
Classes
Internal base class for defining multiple prefix (order). |
|
Internal base class definition for conversion table for dimension objects. |
|
Internal base class for units definition. |
|
Intenal class for creating a multiple prefix unit. |
|
Internal base class descriptor for setting attributes only once. |
Module Contents
- mudu.base.LENGTH
- mudu.base.MASS
- mudu.base.TIME
- mudu.base.PLANE_ANGLE
- mudu.base.SOLID_ANGLE
- mudu.base.THERMODYNAMIC_TEMPERATURE
- mudu.base.ELECTRIC_CURRENT
- mudu.base.AMOUNT_OF_SUBSTANCE
- mudu.base.LUMINOUS_INTENSITY
- mudu.base.FORCE = 'force'
- mudu.base.PRESSURE = 'pressure'
- mudu.base.ENERGY = 'energy'
- mudu.base.DENSITY = 'density'
- mudu.base.POWER = 'power'
- mudu.base.SPEED = 'speed'
- mudu.base.ILLUMINANCE = 'illuminance'
- mudu.base.VOLTAGE = 'voltage'
- mudu.base.CAPACITANCE = 'capacitance'
- mudu.base.RESISTANCE = 'resistance'
- mudu.base.CONDUCTANCE = 'conductance'
- mudu.base.MAGNETIC_FLUX = 'magnetic_flux'
- mudu.base.MAGNETIC_FIELD_STRENGTH = 'magnetic_field_strength'
- mudu.base.INDUCTANCE = 'inductance'
- mudu.base.RADIOACTIVITY = 'radioactivity'
- mudu.base.ABSORBED_DOSE = 'absorbed_dose'
- mudu.base.DOSE_EQUIVALENT = 'dose_equivalent'
- mudu.base.GENERIC_UNIT = 'generic_unit'
- mudu.base.GENERIC_DIMENSION = 'generic_dimension'
- mudu.base.GENERIC_QUANTITY = 'generic_quantity'
- mudu.base.DIMENSIONLESS = 'dimensionless'
- mudu.base.DIMENSIONLESS_UNIT = 'dimensionless_unit'
- class mudu.base._OrderType
Internal base class for defining multiple prefix (order).
- name
name of the multiple prefix e.g. kilo
- Type:
str
- symbol
symbol of the multiple prefix e.g. k
- Type:
str
- name: str
- symbol: str
- value: float
- class mudu.base._ConversionTableType
Internal base class definition for conversion table for dimension objects.
- dimension
Conversion table contains units of dimension. Dimension could be LENGTH TIME MASS e.t.c.
- Type:
str
- conversion_table
tuple containing the conversion units and a lambda calculating the conversion. e.g. ((INCH, METER), functools.partial(_basic_unit_converter, y=0.0254))
- Type:
Sequence
- extend
Extend an existing conversion table with more conversion standards.
- Type:
None
- dimension: str
- conversion_table: Sequence
- extend(seq: Sequence) None
Convieniece method to extend the built-in conversion standard to accomodate other user defined units.
- Parameters:
seq (Sequence) –
- tuple that contains:
a tuple of the units and a callable that defines the conversion operation.
example (- Usage) –
import functools from mudu import Length, METER from mudu.base import _UnitType from mudu.units import _basic_unit_converter # define a new unit type ME_UNIT = _UnitType( _dimension=LENGTH, _unit_name="me_unit", _unit_symbol="m_u", ) # create a conversion standard with METER seq = ((ME_UNIT, METER), functools.partial(_basic_unit_converter, y=0.001)) # extend the conversion table Length._conversion_standards.extend(seq)
- class mudu.base._UnitType
Internal base class for units definition.
- _unit_name
The unit name e.g. meter
- Type:
str
- _unit_symbol
Symbolic representation of the unit, usually passed as a string, then converted to a sympy.Symbol object
- Type:
str
- _order
Multiple prefix, if unit is a multiple prefix of a _UnitType.
- Type:
- _base
If a unit is a multiple prefix, then it has a base unit. e.g. CENTIMETER is composed of the multiple prefix CENTI and the base unit METER.
- Type:
- _quantity
The quantity the unit represents, say Force, Energy.
- Type:
str
- is_unit_type
Internal method to validate that an object is an instance of _UnitType
- Type:
bool
- - **Usage example**
from mudu import Length, METER from mudu.base import _UnitType # define a new unit type ME_UNIT = _UnitType( _dimension=LENGTH, _unit_name="me_unit", _unit_symbol="m_u", ) some_length = Length(12, ME_UNIT)
- To create a conversion standard with another unit, read the documentation
- on _ConversionTableType or read the full documentation at <https
- Type:
//github.com/techkaduna/mudu>_.
- _dimension: str
- _unit_name: str
- _unit_symbol: str | sympy.Symbol
- _quantity: str = 'generic_quantity'
- _order: _OrderType = None
- _base: Self = None
- classmethod create_unit(**kwargs)
Internal alternate _UnitType constructor.
- Parameters:
__init__. (create_unit takes same parameters as the _UnitType)
- __post_init__()
- __repr__()
- __mul__(x: Self)
- __rmul__(x: Self)
- __truediv__(x)
- __rtruediv__(x)
- __pow__(x)
- mudu.base.GIGA
- mudu.base.MEGA
- mudu.base.KILO
- mudu.base.CENTI
- mudu.base.MILLI
- mudu.base.MICRO
- mudu.base.NANO
- mudu.base.PICO
- mudu.base.FEMTO
- mudu.base.ATTO
- class mudu.base._OrderUnitType
Intenal class for creating a multiple prefix unit.
Usage example
from mudu import Length, METER, OrderUnit, KILO # define an OrderUnit KILOMETER = OrderUnit(KILO, METER) some_length = Length(12, KILOMETER)
NOTE _OrderUnit was not used to create the multiple prefix unit, OrderUnit, which is an instance of _OrderUnit, was used instead.
- __call__(_order: _OrderType, unit: _UnitType)
- mudu.base.OrderUnit