PySharp Units of Measure
Units of Measure in Python
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

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

Static Public Member Functions

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

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__()

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

Create a quantity with an amount and unit of measure.

Parameters
amountAmount
uomUnitOfMeasure

Member Function Documentation

◆ add()

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

Add two quantities.

Parameters
otherQuantity
Returns
Sum Quantity

◆ classify()

def uom.quantity.Quantity.classify (   self)

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

Returns
Quantity

◆ compare()

def 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()

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

Convert this quantity to the target UOM.

Parameters
toUOMUnitOfMeasure
Returns
Converted quantity

◆ convertToPower()

def 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()

def 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()

def 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()

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

Divide two quantities to create a third quantity.

Parameters
otherQuantity
Returns
Quotient Quantity

◆ divideByAmount()

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

Divide this quantity by the specified amount.

Parameters
divisorAmount
Returns
Quantity Quantity

◆ invert()

def uom.quantity.Quantity.invert (   self)

Invert this quantity, i.e.

1 divided by this quantity to create another quantity

Returns
Quantity

◆ multiply()

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

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

Parameters
otherQuantity
Returns
Multiplied quantity

◆ multiplyByAmount()

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

Multiply this quantity by the specified amount.

Parameters
multiplierAmount
Returns
Quantity Quantity

◆ subtract()

def 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: