Units
planck.units.Units
¤
Bases: dict
Units library storing planck.models.Unit
models.
Methods:
Name | Description |
---|---|
convert |
Convert a |
find |
Return unit keys containing a given string |
Functions¤
convert
¤
convert(value, input_unit, output_unit)
Convert a value
from input_unit
to output_unit
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
Union[float, array]
|
Value to convert |
required |
input_unit
|
str
|
Source unit |
required |
output_unit
|
str
|
Target unit |
required |
Returns:
Type | Description |
---|---|
Union[float, array]
|
Value expressed as |
Examples:
from planck import units
print(units.convert(1.0, "m", "ft"))
#> 3.280839895013124
print(units.convert(0.0, "C", "K"))
#> 273.15
Source code in planck/units.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
find
¤
find(sub=None, quantity=None)
Return unit keys containing a given string
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sub
|
str
|
Sub-string to search keys for. By default, return all keys. |
None
|
quantity
|
str
|
Specific quantity ["length", "mass", "volume", "pressure", etc.] |
None
|
Returns:
Name | Type | Description |
---|---|---|
keys |
list
|
List of keys |
Source code in planck/units.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|