InertiaMoment

class InertiaMoment(value: float | int, unit: str)

Bases: UnitBase

InertiaMoment object.

Attributes

unitstr

Symbol of the unit of measurement for moment of inertia.

valuefloat or int

Moment of inertia numerical value.

Methods

to()

It converts actual value to a new value computed using target_unit as the reference unit of measurement.

to(target_unit: str, inplace: bool = False) InertiaMoment

It converts actual value to a new value computed using target_unit as the reference unit of measurement.

If inplace is True, it overrides actual value and unit, otherwise it returns a new instance with the converted value and the target_unit as unit.

Parameters

target_unitstr

Target unit to which convert the current value.

inplacebool, optional

Whether to override the current instance value. Default is False, so it does not override the current value.

Returns

InertiaMoment

Converted moment of inertia.

Raises

TypeError
  • If target_unit is not a str,

  • if inplace is not a bool.

KeyError

If the target_unit is not among available ones.

Examples

InertiaMoment instantiation.

>>> from gearpy.units import InertiaMoment
>>> i = InertiaMoment(1, 'kgm^2')
>>> i
... 1 kgm^2

Conversion from kilogram-square meter to gram-square meter with inplace = False by default, so it does not override the current value.

>>> i.to('gm^2')
... 1000.0 gm^2
>>> i
... 1 kgm^2

Conversion from kilograms-square meter to gram-square meter with inplace = True, in order to override the current value.

>>> i.to('gm^2', inplace = True)
... 1000.0 gm^2
>>> i
... 1000.0 gm^2
property unit: str

Symbol of the unit of measurement for moment of inertia. It must be a str. Available units are:

  • 'kgm^2' for kilogram-square meter,

  • 'kgdm^2' for kilogram-square decimeter,

  • 'kgcm^2' for kilogram-square centimeter,

  • 'kgmm^2' for kilogram-square millimeter,

  • 'gm^2' for gram-square meter,

  • 'gdm^2' for gram-square decimeter,

  • 'gcm^2' for gram-square centimeter,

  • 'gmm^2' for gram-square millimeter.

Returns

str

Symbol of the unit of measurement for moment of inertia.

Raises

TypeError

If unit is not a str.

KeyError

If the unit is not among available ones.

property value: float | int

Moment of inertia numerical value. The relative unit is expressed by the unit property. It must be positive.

Returns

float or int

Moment of inertia numerical value.

Raises

TypeError

If value is not a float or an int.

ValueError

If value is negative or null.