11.1.11.2. Unit

This module implements units.

A shortcut is defined for each unit prefix, e.g. pico, nano, micro, milli, kilo, mega, tera.

class PySpice.Unit.Unit.FrequencyMixin[source]

Bases: object

This class implements a frequency mixin.

period

Return the period \(T = \frac{1}{f}\).

pulsation

Return the pulsation \(\omega = 2\pi f\).

class PySpice.Unit.Unit.PeriodMixin[source]

Bases: object

This class implements a period mixin.

frequency

Return the period \(f = \frac{1}{T}\).

pulsation

Return the pulsation \(\omega = \frac{2\pi}{T}\).

class PySpice.Unit.Unit.PrefixedUnit(unit=None, power=None, value_ctor=None, values_ctor=None)[source]

Bases: object

This class implements a prefixed unit.

check_unit(other)[source]
clone()[source]
classmethod from_prefixed_unit(unit, power=0)[source]
classmethod from_si_unit(si_unit)[source]
is_same_power(other)[source]
is_same_unit(other)[source]
is_unit_less
new_value(value)[source]
power
classmethod register(prefixed_unit)[source]
scale
str(spice=False, unit=True)[source]
str_spice()[source]
unit
class PySpice.Unit.Unit.SiBaseUnit(si_unit=None)[source]

Bases: PySpice.Unit.Unit.Unit

This class implements an SI base unit.

classmethod is_base_unit()[source]
classmethod is_default_unit()[source]
class PySpice.Unit.Unit.SiDerivedUnit(string=None, powers=None)[source]

Bases: object

This class implements a unit defined as powers of SI base units.

cbrt()[source]
clone()[source]
hash
is_base_unit()[source]
is_unit_less()[source]
classmethod new_powers()[source]
classmethod parse_si(string)[source]
power(value)[source]
powers
reciprocal()[source]
sqrt()[source]
square()[source]
string
classmethod to_hash(powers)[source]
classmethod to_string(si_powers)[source]
class PySpice.Unit.Unit.Unit(si_unit=None)[source]

Bases: object

This class implements a unit.

cbrt(prefixed_unit=False)[source]
divide(other, prefixed_unit=False)[source]
classmethod is_base_unit()[source]
classmethod is_default_unit()[source]
is_same_unit(value)[source]
is_unit_less
multiply(other, prefixed_unit=False)[source]
power(exponent, prefixed_unit=False)[source]
quantity
reciprocal(prefixed_unit=False)[source]
si_unit
sqrt(prefixed_unit=False)[source]
square(prefixed_unit=False)[source]
unit_name
unit_suffix
validate(value, none=False)[source]
exception PySpice.Unit.Unit.UnitError[source]

Bases: ValueError

class PySpice.Unit.Unit.UnitMetaclass[source]

Bases: type

Metaclass to register units

classmethod from_hash(hash_)[source]
classmethod from_prefix(prefix)[source]
classmethod from_si_unit(si_unit, unique=True)[source]
classmethod init_unit(cls)[source]
classmethod register_unit(cls)[source]
classmethod unit_iter()[source]
class PySpice.Unit.Unit.UnitPrefix[source]

Bases: object

This class implements a unit prefix like kilo

is_defined_in_spice
is_unit
power
prefix
scale
spice_prefix
str(spice=False)[source]
class PySpice.Unit.Unit.UnitPrefixMetaclass[source]

Bases: type

Metaclass to register unit prefixes

classmethod get(power)[source]
classmethod prefix_iter()[source]
classmethod register_prefix(cls)[source]
class PySpice.Unit.Unit.UnitValue(prefixed_unit, value)[source]

Bases: object

This class implements a value with a unit and a power (prefix).

The value is not converted to float if the value is an int.

canonise()[source]
clone()[source]
clone_prefixed_unit(value)[source]
convert(prefixed_unit)[source]

Convert the value to another power.

convert_to_power(power=0)[source]

Convert the value to another power.

get_prefixed_unit(power=0)[source]
is_same_power(other)[source]
is_same_unit(other)[source]
power
prefixed_unit
reciprocal()[source]
scale
classmethod simple_value(value)[source]
str(spice=False, space=False, unit=True)[source]
str_space()[source]
str_spice()[source]
unit
value
class PySpice.Unit.Unit.UnitValues[source]

Bases: numpy.ndarray

This class implements a Numpy array with a unit and a power (prefix).

CONVERSION

alias of PySpice.Tools.EnumFactory.ConversionType

UFUNC_MAP = {<ufunc 'add'>: UNIT_MATCH, <ufunc 'subtract'>: UNIT_MATCH, <ufunc 'multiply'>: NEW_UNIT, <ufunc 'true_divide'>: NEW_UNIT, <ufunc 'logaddexp'>: FLOAT, <ufunc 'logaddexp2'>: FLOAT, <ufunc 'floor_divide'>: NEW_UNIT, <ufunc 'negative'>: NO_CONVERSION, <ufunc 'positive'>: NO_CONVERSION, <ufunc 'power'>: NEW_UNIT, <ufunc 'remainder'>: UNIT_MATCH, <ufunc 'fmod'>: NOT_IMPLEMENTED, <ufunc 'divmod'>: UNIT_MATCH, <ufunc 'absolute'>: NO_CONVERSION, <ufunc 'fabs'>: NOT_IMPLEMENTED, <ufunc 'rint'>: NO_CONVERSION, <ufunc 'sign'>: NO_CONVERSION, <ufunc 'heaviside'>: NOT_IMPLEMENTED, <ufunc 'conjugate'>: NOT_IMPLEMENTED, <ufunc 'exp'>: FLOAT, <ufunc 'exp2'>: FLOAT, <ufunc 'log'>: FLOAT, <ufunc 'log2'>: FLOAT, <ufunc 'log10'>: FLOAT, <ufunc 'expm1'>: FLOAT, <ufunc 'log1p'>: FLOAT, <ufunc 'sqrt'>: NEW_UNIT, <ufunc 'square'>: NEW_UNIT, <ufunc 'cbrt'>: NEW_UNIT, <ufunc 'reciprocal'>: NEW_UNIT, <ufunc 'sin'>: FLOAT, <ufunc 'cos'>: FLOAT, <ufunc 'tan'>: FLOAT, <ufunc 'arcsin'>: FLOAT, <ufunc 'arccos'>: FLOAT, <ufunc 'arctan'>: FLOAT, <ufunc 'arctan2'>: FLOAT, <ufunc 'hypot'>: FLOAT, <ufunc 'sinh'>: FLOAT, <ufunc 'cosh'>: FLOAT, <ufunc 'tanh'>: FLOAT, <ufunc 'arcsinh'>: FLOAT, <ufunc 'arccosh'>: FLOAT, <ufunc 'arctanh'>: FLOAT, <ufunc 'deg2rad'>: FLOAT, <ufunc 'rad2deg'>: FLOAT, <ufunc 'bitwise_and'>: NOT_IMPLEMENTED, <ufunc 'bitwise_or'>: NOT_IMPLEMENTED, <ufunc 'bitwise_xor'>: NOT_IMPLEMENTED, <ufunc 'invert'>: NOT_IMPLEMENTED, <ufunc 'left_shift'>: NOT_IMPLEMENTED, <ufunc 'right_shift'>: NOT_IMPLEMENTED, <ufunc 'greater'>: UNIT_MATCH_NO_OUT_CAST, <ufunc 'greater_equal'>: UNIT_MATCH_NO_OUT_CAST, <ufunc 'less'>: UNIT_MATCH_NO_OUT_CAST, <ufunc 'less_equal'>: UNIT_MATCH_NO_OUT_CAST, <ufunc 'not_equal'>: UNIT_MATCH_NO_OUT_CAST, <ufunc 'equal'>: UNIT_MATCH_NO_OUT_CAST, <ufunc 'logical_and'>: UNIT_MATCH, <ufunc 'logical_or'>: UNIT_MATCH, <ufunc 'logical_xor'>: UNIT_MATCH, <ufunc 'logical_not'>: UNIT_MATCH, <ufunc 'maximum'>: UNIT_MATCH, <ufunc 'minimum'>: UNIT_MATCH, <ufunc 'fmax'>: UNIT_MATCH, <ufunc 'fmin'>: UNIT_MATCH, <ufunc 'isfinite'>: NOT_IMPLEMENTED, <ufunc 'isinf'>: NOT_IMPLEMENTED, <ufunc 'isnan'>: NOT_IMPLEMENTED, <ufunc 'signbit'>: NOT_IMPLEMENTED, <ufunc 'copysign'>: NOT_IMPLEMENTED, <ufunc 'nextafter'>: NOT_IMPLEMENTED, <ufunc 'spacing'>: NOT_IMPLEMENTED, <ufunc 'modf'>: NOT_IMPLEMENTED, <ufunc 'ldexp'>: NOT_IMPLEMENTED, <ufunc 'frexp'>: NOT_IMPLEMENTED, <ufunc 'floor'>: NOT_IMPLEMENTED, <ufunc 'ceil'>: NO_CONVERSION, <ufunc 'trunc'>: NO_CONVERSION}
as_ndarray(scale=False)[source]
convert(prefixed_unit)[source]

Convert the value to another power.

convert_to_power(power=0)[source]

Convert the value to another power.

classmethod from_ndarray(array, prefixed_unit)[source]
get_prefixed_unit(power=0)[source]
is_same_power(other)[source]
is_same_unit(other)[source]
power
prefixed_unit
reciprocal()[source]
scale
unit
class PySpice.Unit.Unit.ZeroPower[source]

Bases: PySpice.Unit.Unit.UnitPrefix