pyunitwizard.forms package
Submodules
pyunitwizard.forms.api_openmm_unit module
- pyunitwizard.forms.api_openmm_unit.change_value(quantity: Quantity, value: int | float | ArrayLike) Quantity [source]
- pyunitwizard.forms.api_openmm_unit.compatibility(quantity_or_unit_1: Quantity | Unit, quantity_or_unit_2: Quantity | Unit) bool [source]
Check whether two quantities or units are compatible.
- Parameters:
quantity_or_unit_1 (openmm_unit.Quantity or openmm_unit.Quantity) – A quanitity or a unit.
quantity_or_unit_2 (openmm_unit.Quantity or openmm_unit.Quantity) – A quanitity or a unit.
- Returns:
True if they are compatible.
- Return type:
bool
- pyunitwizard.forms.api_openmm_unit.convert(quantity: Quantity, unit: Unit) Quantity [source]
Converts the quantity to a different unit.
- Parameters:
quantity (openmm.unit.Quantity) – A quanitity or a unit.
unit (openmm.unit.Unit) – The unit to convert to.
- Returns:
The converted quantity.
- Return type:
openmm.unit.Quantity
- pyunitwizard.forms.api_openmm_unit.dimensionality(quantity_or_unit: Quantity | Unit) Dict[str, int] [source]
Returns the dimensionality of the quantity or unit.
- Parameters:
quantity_or_unit (openmm_unit.Quantity or openmm_unit.Unit) – A quanitity or a unit
- Returns:
dimensionality_dict – Dictionary which keys are fundamental units and values are the exponent of each unit in the quantity.
- Return type:
dict
- pyunitwizard.forms.api_openmm_unit.get_unit(quantity: Quantity) Unit [source]
Returns the units of the quantity.
- Parameters:
quantity (openmm.unit.Quantity) – A quanitity or a unit.
- Returns:
The unit.
- Return type:
openmm.unit.Unit
- pyunitwizard.forms.api_openmm_unit.get_value(quantity: Quantity) int | float | ArrayLike [source]
Returns the value of the quantity.
- Parameters:
quantity (openmm.unit.Quantity) – A quanitity or a unit.
- Returns:
The value.
- Return type:
int, float or ArrrayLike
- pyunitwizard.forms.api_openmm_unit.is_quantity(quantity_or_unit: Any) bool [source]
Check whether a quantity or unit is an openmm quantity.
- Parameters:
quantity_or_unit (Any) – A quanitity or a unit
- Returns:
True if it’s an openmm.unit.Quantity
- Return type:
bool
- pyunitwizard.forms.api_openmm_unit.is_unit(quantity_or_unit: Any) bool [source]
Check whether a quantity or unit is an openmm unit.
- Parameters:
quantity_or_unit (Any) – A quanitity or a unit
- Returns:
True if its an openmm.unit.Unit
- Return type:
bool
- pyunitwizard.forms.api_openmm_unit.make_quantity(value: int | float | ArrayLike, unit: Unit) Quantity [source]
Returns an openmm quantity.
Parmeters
- value: int, float or ArrayLike
The value of the quantity.
- unitopenmm_unit.Unit
The unit.
- returns:
The quantity.
- rtype:
openmm_unit.Quantity
- pyunitwizard.forms.api_openmm_unit.quantity_to_pint(quantity: Quantity)[source]
Transform a quantity from openmm.unit to a pint quantity.
- Parameters:
quantity (openmm.unit.Quantity) – A quanitity.
- Returns:
The quantity.
- Return type:
pint.Quantity
- pyunitwizard.forms.api_openmm_unit.quantity_to_string(quantity: Quantity) str [source]
Convert a quantity to string.
- Parameters:
quantity (openmm_unit.Quantity) – A quanitity.
- Returns:
The quantitity as a string.
- Return type:
str
- pyunitwizard.forms.api_openmm_unit.quantity_to_unyt(quantity: Quantity)[source]
Transform a quantity from openmm.unit to a unyt quantity.
- Parameters:
quantity (openmm.unit.Quantity) – A quanitity or a unit.
- Returns:
The quantity.
- Return type:
unyt_array or unyt_quantity
- pyunitwizard.forms.api_openmm_unit.unit_to_pint(unit: Unit)[source]
Transform a unit from openmm.unit to a pint unit.
- Parameters:
unit (openmm.unit.Unit) – A unit.
- Returns:
The unit.
- Return type:
pint.Unit
pyunitwizard.forms.api_pint module
- pyunitwizard.forms.api_pint.change_value(quantity: Quantity, value: int | float | ArrayLike) Quantity [source]
- pyunitwizard.forms.api_pint.compatibility(quantity_or_unit_1: Quantity | Unit, quantity_or_unit_2: Quantity | Unit) bool [source]
Check whether two quantities or units are compatible.
- Parameters:
quantity_or_unit_1 (openmm_unit.Quantity or openmm_unit.Quantity) – A quanitity or a unit.
quantity_or_unit_2 (openmm_unit.Quantity or openmm_unit.Quantity) – A quanitity or a unit.
- Returns:
True if they are compatible.
- Return type:
bool
- pyunitwizard.forms.api_pint.convert(quantity: Quantity, unit_name: str) Quantity [source]
Converts the quantity to a different unit.
- Parameters:
quantity (pint.Quantity) – A quanitity or a unit.
unit (str) – The unit to convert to.
- Returns:
The converted quantity.
- Return type:
pint.Quantity
- pyunitwizard.forms.api_pint.dimensionality(quantity_or_unit: Quantity | Unit) Dict[str, int] [source]
Returns the dimensionality of the quantity or unit.
- Parameters:
quantity_or_unit (pint.Quantity or pint.Unit) – A quanitity or a unit
- Returns:
dimensionality_dict – Dictionary which keys are fundamental units and values are the exponent of each unit in the quantity.
- Return type:
dict
- pyunitwizard.forms.api_pint.get_unit(quantity: Quantity) Unit [source]
Returns the units of the quantity.
- Parameters:
quantity (pint.Quantity) – A quanitity or a unit.
- Returns:
The unit.
- Return type:
pint.Unit
- pyunitwizard.forms.api_pint.get_value(quantity: Quantity) int | float | ArrayLike [source]
Returns the value of the quantity.
- Parameters:
quantity (pint.Quantity) – A quanitity or a unit.
- Returns:
The value.
- Return type:
int, float or ArrrayLike
- pyunitwizard.forms.api_pint.is_quantity(quantity_or_unit: Any) bool [source]
Check whether a quantity or unit is an pint quantity.
- Parameters:
quantity_or_unit (Any) – A quanitity or a unit
- Returns:
True if it’s an pint quantity.
- Return type:
bool
- pyunitwizard.forms.api_pint.is_unit(quantity_or_unit: Any) bool [source]
Check whether a quantity or unit is a pint unit.
- Parameters:
quantity_or_unit (Any) – A quanitity or a unit
- Returns:
True if its an openmm.unit.Unit
- Return type:
bool
- pyunitwizard.forms.api_pint.make_quantity(value: float | int | ArrayLike, unit: str) Quantity [source]
Returns a pint quantity.
Parmeters
- value: int, float or ArrayLike
The value of the quantity.
- unitstr
Name of the unit.
- returns:
The quantity.
- rtype:
pint.Quantity
- pyunitwizard.forms.api_pint.quantity_to_openmm_unit(quantity: Quantity)[source]
Transform a quantity from a pint quantity to a openmm.unit quantity.
- Parameters:
quantity (pint.Quantity) – A quanitity.
- Returns:
The quantity.
- Return type:
openmm_unit.Quantity
- pyunitwizard.forms.api_pint.quantity_to_string(quantity_or_item) str [source]
Convert a quantity to string.
- Parameters:
quantity_or_item (pint.Quantity) – A quanitity or a unit.
- Returns:
The quantitity as a string.
- Return type:
str
- pyunitwizard.forms.api_pint.quantity_to_unyt(quantity: Quantity)[source]
Transform a quantity from a pint quantity to a unyt quantity.
- Parameters:
quantity (pint.Quantity) – A quantity.
- Returns:
The unyt quantity
- Return type:
unyt_array or unyt_quantity
- pyunitwizard.forms.api_pint.string_to_quantity(string: str) Quantity [source]
Get a quantity from a string.
- Parameters:
string (str) – A string with the quantity.
- Returns:
The quantity.
- Return type:
pint.Quantity
- pyunitwizard.forms.api_pint.string_to_unit(string: str) Unit [source]
Get a unit from a string.
- Parameters:
string (str) – A string with the unit.
- Returns:
The unit.
- Return type:
pint.Unit
- pyunitwizard.forms.api_pint.unit_to_openmm_unit(unit: Unit)[source]
Transform a unit from a pint unit to a openmm.unit unit.
- Parameters:
unit (pint.Unit) – A unit.
- Returns:
The unit.
- Return type:
openmm_unit.Unit
pyunitwizard.forms.api_string module
- pyunitwizard.forms.api_string.change_value(quantity: str, value: int | float | ArrayLike) str [source]
- pyunitwizard.forms.api_string.compatibility(quantity_or_unit_1: str, quantity_or_unit_2: str) bool [source]
Check whether two quantities or units are compatible.
- Parameters:
quantity_or_unit_1 (str) – A quanitity or a unit.
quantity_or_unit_2 (str) – A quanitity or a unit.
- Returns:
True if they are compatible.
- Return type:
bool
- pyunitwizard.forms.api_string.convert(quantity: str, unit_name: str) str [source]
Converts the quantity to a different unit.
- Parameters:
quantity (str) – A quanitity-
unit (str) – The unit to convert to.
- Returns:
The converted quantity.
- Return type:
str
- pyunitwizard.forms.api_string.dimensionality(quantity_or_unit: str) Dict[str, int] [source]
Returns the dimensionality of the quantity or unit.
- Parameters:
quantity_or_unit (str) – A quanitity or a unit
- Returns:
dimensionality_dict – Dictionary which keys are fundamental units and values are the exponent of each unit in the quantity.
- Return type:
dict
- pyunitwizard.forms.api_string.get_unit(quantity: str) str [source]
Returns the units of the quantity.
- Parameters:
quantity (pint.Quantity) – A quanitity or a unit.
- Returns:
The unit.
- Return type:
pint.Unit
- pyunitwizard.forms.api_string.get_value(quantity: str) str [source]
Returns the value of the quantity.
- Parameters:
quantity (pint.Quantity) – A quanitity or a unit.
- Returns:
The value.
- Return type:
int, float or ArrrayLike
- pyunitwizard.forms.api_string.is_quantity(quantity_or_unit: str) bool [source]
Check whether a string is a quantity.
- Parameters:
quantity_or_unit (Any) – A quanitity or a unit
- Returns:
True if it’s a quantity.
- Return type:
bool
- pyunitwizard.forms.api_string.is_unit(quantity_or_unit: str) bool [source]
Check whether a string is a unit.
- Parameters:
quantity_or_unit (str) – A quanitity or a unit
- Returns:
True if its a unit.
- Return type:
bool
- pyunitwizard.forms.api_string.make_quantity(value: int | float | ArrayLike, unit_name: str) str [source]
Returns a string quantity.
Parmeters
- value: int, float or ArrayLike
The value of the quantity.
- unitstr
Name of the unit.
- returns:
The quantity.
- rtype:
str
- pyunitwizard.forms.api_string.quantity_to_pint(quantity: str)[source]
Transform a quantity from a string quantity to a pint quantity.
- Parameters:
quantity (str) – A quanitity.
- Returns:
The quantity.
- Return type:
pint.Quantity
pyunitwizard.forms.api_unyt module
- pyunitwizard.forms.api_unyt.change_value(quantity: unyt_quantity | unyt_array, value: int | float | ArrayLike) unyt_array | unyt_quantity [source]
- pyunitwizard.forms.api_unyt.compatibility(quantity_or_unit_1: unyt_array | unyt_quantity | Unit, quantity_or_unit_2: unyt_array | unyt_quantity | Unit) bool [source]
Check whether two quantities or units are compatible.
- Parameters:
quantity_or_unit_1 (unyt_array or unyt_quantity or unyt_unit) – A quanitity or a unit.
quantity_or_unit_2 (unyt_array or unyt_quantity or unyt_unit) – A quanitity or a unit.
- Returns:
True if they are compatible.
- Return type:
bool
- pyunitwizard.forms.api_unyt.convert(quantity: unyt_array | unyt_quantity, unit_name: str) unyt_array | unyt_quantity [source]
Converts the quantity to a different unit.
- Parameters:
quantity (unyt_array or unyt_quantity) – A quanitity or a unit.
unit (str) – The unit to convert to.
- Returns:
The converted quantity.
- Return type:
unyt_array or unyt_quantity
- pyunitwizard.forms.api_unyt.dimensionality(quantity_or_unit: unyt_array | unyt_quantity | Unit) Dict[str, int] [source]
Returns the dimensionality of the quantity or unit.
- Parameters:
quantity_or_unit (pint.Quantity or pint.Unit) – A quanitity or a unit
- Returns:
dimensionality_dict – Dictionary which keys are fundamental units and values are the exponent of each unit in the quantity.
- Return type:
dict
- pyunitwizard.forms.api_unyt.get_unit(quantity: unyt_array | unyt_quantity) Unit [source]
Returns the units of the quantity.
- Parameters:
quantity (unyt_array or unyt_quantity) – A quanitity or a unit.
- Returns:
The unit.
- Return type:
unyt_unit
- pyunitwizard.forms.api_unyt.get_value(quantity: unyt_array | unyt_quantity) int | float | ArrayLike [source]
Returns the value of the quantity.
- Parameters:
quantity (unyt_array or unyt_quantity) – A quanitity or a unit.
- Returns:
The value.
- Return type:
int, float or ArrrayLike
- pyunitwizard.forms.api_unyt.is_quantity(quantity_or_unit: Any) bool [source]
Check whether a quantity or unit is a unyt quantity.
- Parameters:
quantity_or_unit (Any) – A quanitity or a unit
- Returns:
True if it is a unyt.unyt_array or unyt.unyt_quantity.
- Return type:
bool
- pyunitwizard.forms.api_unyt.is_unit(quantity_or_unit: Any) bool [source]
Check whether a quantity or unit is a unyt unit.
- Parameters:
quantity_or_unit (Any) – A quanitity or a unit.
- Returns:
True if it is a unyt_unit.
- Return type:
bool
- pyunitwizard.forms.api_unyt.make_quantity(value: int | float | ArrayLike, unit: str | Unit) unyt_array | unyt_quantity [source]
Returns a unyt quantity.
Parmeters
- value: int, float or ArrayLike
The value of the quantity.
- unitunyt_unit or str
The unit.
- returns:
The quantity.
- rtype:
unyt_array or unyt_quantity
- pyunitwizard.forms.api_unyt.quantity_to_openmm_unit(quantity: unyt_array | unyt_quantity)[source]
Transform a quantity from unyt to an openmm.unit quantity.
- Parameters:
quantity (unyt_array or unyt_quantity) – A quanitity.
- Returns:
The quantity.
- Return type:
openmm.unit.Quantity
- pyunitwizard.forms.api_unyt.quantity_to_pint(quantity: unyt_array | unyt_quantity)[source]
Transform a quantity from unyt to a pint quantity.
- Parameters:
quantity (unyt_array or unyt_quantity) – A quanitity.
- Returns:
The quantity.
- Return type:
pint.Quantity
- pyunitwizard.forms.api_unyt.quantity_to_string(quantity: unyt_array | unyt_quantity) str [source]
Convert a quantity to string.
- Parameters:
quantity (unyt_array or unyt_quantity) – A quanitity or a unit.
- Returns:
The quantitity as a string.
- Return type:
str
- pyunitwizard.forms.api_unyt.unit_to_openmm_unit(unit: Unit)[source]
Transform a unit from unyt to a openmm.unit unit.
- Parameters:
unit (unyt_unit) – A unit.
- Returns:
The unit.
- Return type:
openmm_unit.Unit