AngularSpeed

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

Bases: UnitBase

AngularSpeed object.

Attributes

unitstr

Symbol of the unit of measurement for angular speed.

valuefloat or int

Angular speed 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) AngularSpeed

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

AngularSpeed

Converted angular speed.

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

AngularSpeed instantiation.

>>> from gearpy.units import AngularSpeed
>>> s = AngularSpeed(1000, 'rpm')
>>> s
1000 rpm

Conversion from revolutions per minute to radian per second with inplace=False by default, so it does not override the current value.

>>> s.to('rad/s')
104.71975511965977 rad/s
>>> s
1000 rpm

Conversion from revolutions per minute to revolutions per second with inplace=True, in order to override the current value.

>>> s.to('rps', inplace=True)
16.666666666666664 rps
>>> s
16.666666666666664 rps
property unit: str

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

  • 'rad/s' for radian per second,

  • 'rad/min' for radian per minute,

  • 'rad/h' for radian per hour,

  • 'deg/s' for degree per second,

  • 'deg/min' for degree per minute,

  • 'deg/h' for degree per hour,

  • 'rps' for revolutions per second,

  • 'rpm' for revolutions per minute,

  • 'rph' for revolutions per hour.

Returns

str

Symbol of the unit of measurement for angular speed.

Raises

TypeError

If unit is not a str.

KeyError

If the unit is not among available ones.

property value: float | int

Angular speed numerical value. The relative unit is expressed by the unit property.

Returns

float or int

Angular speed numerical value.

Raises

TypeError

If value is not a float or an int.