fix(leakage): accept display flow units
This commit is contained in:
@@ -121,13 +121,15 @@ def _worker_evaluate(raw_ratios: np.ndarray) -> float:
|
||||
_cleanup_temp_files(prefix)
|
||||
|
||||
|
||||
class LeakageIdentifier:
|
||||
FLOW_UNIT_TO_M3S = {
|
||||
"m3/s": 1.0,
|
||||
"m3/h": 1.0 / 3600.0,
|
||||
"L/s": 1.0 / 1000.0,
|
||||
"L/min": 1.0 / 60000.0,
|
||||
}
|
||||
class LeakageIdentifier:
|
||||
FLOW_UNIT_TO_M3S = {
|
||||
"m3/s": 1.0,
|
||||
"m³/s": 1.0,
|
||||
"m3/h": 1.0 / 3600.0,
|
||||
"m³/h": 1.0 / 3600.0,
|
||||
"L/s": 1.0 / 1000.0,
|
||||
"L/min": 1.0 / 60000.0,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def _flow_to_m3s(cls, value: float, unit: str) -> float:
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import pytest
|
||||
|
||||
from app.algorithms.leakage.identifier import LeakageIdentifier
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("unit", "expected"),
|
||||
[
|
||||
("m3/s", 1.0),
|
||||
("m³/s", 1.0),
|
||||
("m3/h", 3600.0),
|
||||
("m³/h", 3600.0),
|
||||
],
|
||||
)
|
||||
def test_leakage_identifier_accepts_display_flow_units(unit, expected):
|
||||
assert LeakageIdentifier._flow_from_m3s(1.0, unit) == expected
|
||||
|
||||
|
||||
def test_leakage_identifier_accepts_display_flow_units_for_input():
|
||||
assert LeakageIdentifier._flow_to_m3s(3600.0, "m³/h") == 1.0
|
||||
Reference in New Issue
Block a user