STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_model_units Namespace Reference

Functions

None test_conversion_to_si (float value, str unit, float expected)
None test_conversion_round_trips (float value, str unit, float _expected)
None test_temperature_carries_an_offset ()
None test_temperature_difference_is_a_separate_dimension ()
None test_cv_and_kv_convert_through_the_standard_factor ()
None test_a_wrong_dimension_is_rejected_by_name ()
None test_an_unknown_unit_points_at_the_registry ()
None test_gauge_and_absolute_are_spelled_out_and_bare_is_a_difference ()
None test_every_dimension_has_a_canonical_unit ()
None test_a_unit_can_be_added_from_outside ()

Variables

list CONVERSIONS

Detailed Description

Unit conversion, and the dimension check that catches the expensive mistake.

Unit confusion is the most costly recurring error in this field and the easiest
to prevent, provided the prevention sits at a boundary rather than in everyone's
memory. These tests hold that boundary.

Conversion factors are checked against exact definitions where one exists --
an inch is 0.0254 m by definition, not by measurement -- so a typo in a factor
fails rather than shifting every result by a fraction of a percent.

Function Documentation

◆ test_a_unit_can_be_added_from_outside()

None test_model_units.test_a_unit_can_be_added_from_outside ( )

Definition at line 128 of file test_model_units.py.

◆ test_a_wrong_dimension_is_rejected_by_name()

None test_model_units.test_a_wrong_dimension_is_rejected_by_name ( )
The whole point: the message says what was expected and what was given.

Definition at line 89 of file test_model_units.py.

◆ test_an_unknown_unit_points_at_the_registry()

None test_model_units.test_an_unknown_unit_points_at_the_registry ( )
No close match for this one, so it should still say where to look.

Definition at line 99 of file test_model_units.py.

◆ test_conversion_round_trips()

None test_model_units.test_conversion_round_trips ( float value,
str unit,
float _expected )

Definition at line 51 of file test_model_units.py.

◆ test_conversion_to_si()

None test_model_units.test_conversion_to_si ( float value,
str unit,
float expected )

Definition at line 46 of file test_model_units.py.

◆ test_cv_and_kv_convert_through_the_standard_factor()

None test_model_units.test_cv_and_kv_convert_through_the_standard_factor ( )
Cv/Kv comes from IEC 60534 via ``fluids``, not from a literal here.

The same constant the Phase 03 valve correlations will use, so a valve
authored in Kv and one authored in Cv cannot disagree.

Definition at line 76 of file test_model_units.py.

◆ test_every_dimension_has_a_canonical_unit()

None test_model_units.test_every_dimension_has_a_canonical_unit ( )
Guards the reverse lookup used to label output.

``si_unit_of`` scans for the unit with factor 1.0; a dimension whose units
all have factors would make it raise, and only at report time.

Definition at line 118 of file test_model_units.py.

◆ test_gauge_and_absolute_are_spelled_out_and_bare_is_a_difference()

None test_model_units.test_gauge_and_absolute_are_spelled_out_and_bare_is_a_difference ( )
``psig`` is one standard atmosphere above ``psia``; bare ``psi`` carries
no offset, so it converts a *difference* exactly. Which a drawing's bare
pressure means is decided per parameter (feedtwin.model.pressure), never by
the unit table.

Definition at line 105 of file test_model_units.py.

◆ test_temperature_carries_an_offset()

None test_model_units.test_temperature_carries_an_offset ( )
The one dimension where a scale factor alone is wrong.

Definition at line 55 of file test_model_units.py.

◆ test_temperature_difference_is_a_separate_dimension()

None test_model_units.test_temperature_difference_is_a_separate_dimension ( )
A 20 K rise and a 20 K absolute temperature are not the same quantity.

Sharing a dimension would let a temperature *difference* be written where an
absolute temperature belongs and convert with a 273.15 offset applied -- a
silent 273 K error in a heat balance.

Definition at line 63 of file test_model_units.py.

Variable Documentation

◆ CONVERSIONS

list test_model_units.CONVERSIONS
Initial value:
1= [
2 (1.0, "in", 0.0254), # defined exactly
3 (12.0, "in", 0.3048), # one foot
4 (1.0, "ft", 0.3048),
5 (1.0, "mm", 1e-3),
6 (1.0, "psi", 6894.757293168361),
7 (1.0, "bar", 1e5),
8 (1.0, "atm", 101325.0), # defined exactly
9 (1.0, "lbm", 0.45359237), # defined exactly
10 (1.0, "gal", 3.785411784e-3), # defined exactly
11 (1.0, "L", 1e-3),
12 (1.0, "min", 60.0),
13 (1.0, "cP", 1e-3),
14]

Definition at line 29 of file test_model_units.py.