Whole file
alengwenus/pypck
The author described this change as “Fix VarUnit issues and add tests for conversion roundtrip and calibration (#83)”. It counts as a record because the checks below fail on the code as it stood at 58292b52b and pass on 3957c91f9, with nothing else changed between the two runs.
Projectalengwenus/pypck
Fix saved2021-06-03
Sharing licenceMIT · LICENSE
Change size+3 −3
What the code was meant to do, written into the code itself as a save note
Fix VarUnit issues and add tests for conversion roundtrip and calibration (#83)
The change
| 775 | 775 | elif unit == VarUnit.VOLT: | |
| 776 | 776 | var_value = VarValue.from_volt(value) | |
| 777 | 777 | elif unit == VarUnit.AMPERE: | |
| 778 | - | var_value = VarValue.from_kelvin(value) | |
| 778 | + | var_value = VarValue.from_ampere(value) | |
| 779 | 779 | elif unit == VarUnit.DEGREE: | |
| 780 | 780 | var_value = VarValue.from_degree(value) | |
| 781 | 781 | else: | |
| ⋯ | |||
| 927 | 927 | :return: The variable value (never null) | |
| 928 | 928 | :rtype: VarValue | |
| 929 | 929 | """ | |
| 930 | - | return VarValue(int(round(value * 100))) | |
| 930 | + | return VarValue(int(round(value * 100000))) | |
| 931 | 931 | ||
| 932 | 932 | @staticmethod | |
| 933 | 933 | def from_degree(value: float, is_abs: bool = True) -> "VarValue": | |
| ⋯ | |||
| 1077 | 1077 | :return: The converted value | |
| 1078 | 1078 | :rtype: float | |
| 1079 | 1079 | """ | |
| 1080 | - | return self.native_value / 100.0 | |
| 1080 | + | return self.native_value / 100000.0 | |
| 1081 | 1081 | ||
| 1082 | 1082 | def to_degree(self) -> float: | |
| 1083 | 1083 | """Convert to degree value. | |
The check that tells the two apart
fail→pass·tests/test_vars.py::test_calibration[VarUnit.AMPERE-100-0.001]
fail→pass·tests/test_vars.py::test_calibration[VarUnit.AMPERE-4000-0.04]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-0-0_0]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-0-0_1]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-100-100_0]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-100-100_1]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-1000-1000_0]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-1000-1000_1]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-1023-1023_0]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-1023-1023_1]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-198-198_0]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-198-198_1]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-199-199_0]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-199-199_1]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-200-200_0]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-200-200_1]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-201-201_0]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-201-201_1]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-202-202_0]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-202-202_1]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-205-205_0]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-205-205_1]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-4095-4095_0]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-4095-4095_1]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-48-48_0]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-48-48_1]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-49-49_0]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-49-49_1]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-50-50_0]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-50-50_1]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-51-51_0]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-51-51_1]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-52-52_0]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-52-52_1]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-65535-65535_0]
fail→pass·tests/test_vars.py::test_roundtrip[VarUnit.AMPERE-65535-65535_1]
Check file tests/test_vars.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it58292b52b03838f0e953b00931c2cdd0c8a9ba29
Broken version dated2021-05-28
Modulepypck.lcn_defs
Units changedVarValue
Fingerprintbd22429adeeca00d
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.