PySharp Units of Measure
Units of Measure in Python
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
uom.quantity.Quantity Class Reference

The Quantity class represents an amount and UnitOfMeasure. More...

Inheritance diagram for uom.quantity.Quantity:

Public Member Functions

 __init__ (self, amount, uom)
 Create a quantity with an amount and unit of measure.
 
 __hash__ (self)
 
 __eq__ (self, other)
 
 __str__ (self)
 
 convert (self, toUOM)
 Convert this quantity to the target UOM.
 
 convertToPowerProduct (self, uom1, uom2)
 Convert this quantity with a product or quotient unit of measure to the specified units of measure.
 
 convertToPower (self, uom)
 Convert this quantity of a power unit using the specified base unit of measure.
 
 subtract (self, other)
 Subtract a quantity from this quantity.
 
 add (self, other)
 Add two quantities.
 
 divide (self, other)
 Divide two quantities to create a third quantity.
 
 divideByAmount (self, divisor)
 Divide this quantity by the specified amount.
 
 multiply (self, other)
 Multiply this quantity by another quantity to create a third quantity.
 
 multiplyByAmount (self, multiplier)
 Multiply this quantity by the specified amount.
 
 invert (self)
 Invert this quantity, i.e.
 
 compare (self, other)
 Compare this quantity to the other quantity.
 
 classify (self)
 Find a matching unit type for the quantity's unit of measure.
 

Static Public Member Functions

 createAmountFromString (value)
 Create an amount of a quantity that adheres to precision and rounding settings from a Number.
 

Public Attributes

 amount
 
 uom
 

Detailed Description

The Quantity class represents an amount and UnitOfMeasure.

A constant quantity can be named and given a symbol, e.g. the speed of light.

Constructor & Destructor Documentation

◆ __init__()

uom.quantity.Quantity.__init__ ( self,
amount,
uom )

Create a quantity with an amount and unit of measure.

Parameters
amountAmount
uomUnitOfMeasure

Member Function Documentation

◆ add()

uom.quantity.Quantity.add ( self,
other )

Add two quantities.

Parameters
otherQuantity
Returns
Sum Quantity

◆ classify()

uom.quantity.Quantity.classify ( self)

Find a matching unit type for the quantity's unit of measure.

Returns
Quantity

◆ compare()

uom.quantity.Quantity.compare ( self,
other )

Compare this quantity to the other quantity.

Parameters
otherQuantity
Returns
-1 if less than, 0 if equal and 1 if greater than

◆ convert()

uom.quantity.Quantity.convert ( self,
toUOM )

Convert this quantity to the target UOM.

Parameters
toUOMUnitOfMeasure
Returns
Converted quantity

◆ convertToPower()

uom.quantity.Quantity.convertToPower ( self,
uom )

Convert this quantity of a power unit using the specified base unit of measure.

Parameters
uomBase UnitOfMeasure
Returns
Converted quantity

◆ convertToPowerProduct()

uom.quantity.Quantity.convertToPowerProduct ( self,
uom1,
uom2 )

Convert this quantity with a product or quotient unit of measure to the specified units of measure.

Parameters
uom1Multiplier or dividend UnitOfMeasure
uom2Multiplicand or divisor UnitOfMeasure
Returns
Converted quantity

◆ createAmountFromString()

uom.quantity.Quantity.createAmountFromString ( value)
static

Create an amount of a quantity that adheres to precision and rounding settings from a Number.

Parameters
numberValue
Returns
Amount

◆ divide()

uom.quantity.Quantity.divide ( self,
other )

Divide two quantities to create a third quantity.

Parameters
otherQuantity
Returns
Quotient Quantity

◆ divideByAmount()

uom.quantity.Quantity.divideByAmount ( self,
divisor )

Divide this quantity by the specified amount.

Parameters
divisorAmount
Returns
Quantity Quantity

◆ invert()

uom.quantity.Quantity.invert ( self)

Invert this quantity, i.e.

1 divided by this quantity to create another quantity

Returns
Quantity

◆ multiply()

uom.quantity.Quantity.multiply ( self,
other )

Multiply this quantity by another quantity to create a third quantity.

Parameters
otherQuantity
Returns
Multiplied quantity

◆ multiplyByAmount()

uom.quantity.Quantity.multiplyByAmount ( self,
multiplier )

Multiply this quantity by the specified amount.

Parameters
multiplierAmount
Returns
Quantity Quantity

◆ subtract()

uom.quantity.Quantity.subtract ( self,
other )

Subtract a quantity from this quantity.

Parameters
otherquantity
Returns
New quantity

The documentation for this class was generated from the following file: