-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: define default units for fields
Use default units in the plots. This removes some of the hard-coded strings, therefore mitigating typos of units. Fixes #27
- Loading branch information
1 parent
5fee858
commit d6d1291
Showing
4 changed files
with
109 additions
and
38 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import re | ||
|
||
import pytest | ||
|
||
from wind_up.plots import scada_funcs_plots | ||
|
||
|
||
class TestAxisLabelFromFieldName: | ||
@staticmethod | ||
@pytest.mark.parametrize( | ||
"field_name_unsupported", ["UnsupportedFieldName", "test_UnsupportedFieldName", "raw_UnsupportedFieldName"] | ||
) | ||
def test_unsupported_field_name(field_name_unsupported: str) -> None: | ||
fname_unsupported_lean = re.sub(r"^.*?_", "", field_name_unsupported) | ||
msg = ( | ||
f"Failed to construct axis label for field '{field_name_unsupported}' " | ||
f"because {fname_unsupported_lean} does not have a default unit defined" | ||
) | ||
|
||
with pytest.raises(ValueError, match=msg): | ||
scada_funcs_plots._axis_label_from_field_name(field_name=field_name_unsupported) # noqa: SLF001 | ||
|
||
@staticmethod | ||
@pytest.mark.parametrize( | ||
("field_name", "expected"), | ||
[ | ||
("ActivePowerMean", "ActivePowerMean [kW]"), | ||
("test_ActivePowerMean", "test_ActivePowerMean [kW]"), | ||
("raw_ActivePowerMean", "raw_ActivePowerMean [kW]"), | ||
("WindSpeedMean", "WindSpeedMean [m/s]"), | ||
("YawAngleMean", "YawAngleMean [deg]"), | ||
("PitchAngleMean", "PitchAngleMean [deg]"), | ||
("GenRpmMean", "GenRpmMean [RPM]"), | ||
("AmbientTemp", "AmbientTemp [degC]"), | ||
], | ||
) | ||
def test_supported_field_name(field_name: str, expected: str) -> None: | ||
actual = scada_funcs_plots._axis_label_from_field_name(field_name=field_name) # noqa: SLF001 | ||
assert actual == expected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters