Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tunits/core/cython/base_unit_data.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ __SI_BASE_UNITS = [
__OTHER_BASE_UNITS = [
BaseUnitData('dB', 'decibel', use_prefixes=False),
BaseUnitData('dBm', 'decibel-milliwatt', use_prefixes=False),
BaseUnitData('degC', 'celsius', use_prefixes=False),
BaseUnitData('degF', 'fahrenheit', use_prefixes=False),
]

ALL_BASE_UNITS = __SI_BASE_UNITS + __OTHER_BASE_UNITS
1 change: 1 addition & 0 deletions tunits/core/cython/derived_unit_data.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ __OTHER_UNITS = [
DerivedUnitData('ton', None, 'lb', 2000),
# Pressure.
DerivedUnitData('psi', 'pounds_per_square_inch', 'Pa', 6894.75729317),
DerivedUnitData('bar', 'barometric_pressure', 'Pa', 1e5),
]

# Units that aren't technically exact, but close enough for our purposes.
Expand Down
10 changes: 7 additions & 3 deletions tunits/core/cython/dimension.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ This module creates the dimension abstraction which allows the creation of value
that belong to a dimension (e.g. t: Time, x: Length, ...etc). This allows us to
use static types to check code correctness (e.g. time_method(t: Time)).

To add a new dimension, create 3 classes:
To add a new dimension, create 3 classes:
- `class _NewDimension(Dimension):` which implements the abstract methods from
the abstract `Dimension` class.
- `class NewDimension(_NewDimension, ValueWithDimension)` which represents scalar
values and doesn't need to implement any methods.
- `class AccelerationArray(_Acceleration, ArrayWithDimension)` which represents
an array of values sharing the same dimension and
an array of values sharing the same dimension and
"""

import abc
Expand Down Expand Up @@ -696,7 +696,11 @@ class _Temperature(Dimension):
@staticmethod
@cache
def valid_base_units() -> tuple[Value, ...]:
return (default_unit_database.known_units['kelvin'],)
return (
default_unit_database.known_units['kelvin'],
default_unit_database.known_units['celsius'],
default_unit_database.known_units['fahrenheit'],
)

def _value_class(self) -> type[Value]:
return Temperature
Expand Down
1 change: 1 addition & 0 deletions tunits/core/cython/physical_constant_data.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ _DERIVED_CONSTANTS = [
# degrees Rankine
PhysicalConstantData('degR', None, 5.0 / 9.0, 'K'),
PhysicalConstantData('bohr_magneton', None, 9.2740096820e-24, 'J/T'),
PhysicalConstantData('R_k', 'resistance_quantum', 25812.78277321444, 'ohm'), # h/e^2
]

ALL_PHYSICAL_CONSTANT_DATA = _PHYSICAL_CONSTANTS + _DERIVED_CONSTANTS
Loading