diff --git a/src/atopile/assertions.py b/src/atopile/assertions.py index 42bade24..49a32d62 100644 --- a/src/atopile/assertions.py +++ b/src/atopile/assertions.py @@ -450,7 +450,6 @@ def simplify_expressions(entry_addr: address.AddrStr): assertion.rhs = expressions.Expression.from_numericish( expressions.simplify_expression(assertion.rhs, simplified_context) ) - pass def _translator_factory( diff --git a/src/atopile/expressions.py b/src/atopile/expressions.py index 55d8d015..517a948b 100644 --- a/src/atopile/expressions.py +++ b/src/atopile/expressions.py @@ -183,8 +183,8 @@ def _f(val: float): tol, tol_unit = pretty_unit(self.tolerance * self.unit) if nom == 0: - return f"± {_f(tol)}{unit}" - if unit == tol_unit or nom == 0 or tol == 0: + return f"± {_f(tol)}{tol_unit}" + if unit == tol_unit: return f"{_f(nom)} ± {_f(tol)} {unit}" return f"{_f(nom)}{unit} ± {_f(tol)}{tol_unit}" diff --git a/tests/test_expressions/test_ranged_values.py b/tests/test_expressions/test_ranged_values.py index 00994fe6..cb746c28 100644 --- a/tests/test_expressions/test_ranged_values.py +++ b/tests/test_expressions/test_ranged_values.py @@ -53,6 +53,7 @@ def test_pretty_str(): assert RangedValue(3, 3, pint.Unit("V"), str_rep=str_rep).pretty_str() == str_rep assert RangedValue(3, 3, pint.Unit("V")).pretty_str() == "3V" assert RangedValue(3, 5, pint.Unit("V")).pretty_str() == "3 to 5 V" + assert RangedValue(3, 5, pint.Unit("mV")).pretty_str() == "3 to 5 mV" assert RangedValue(3, 3.1, pint.Unit("V")).pretty_str() == "3.05V ± 50mV" # # Test Zeros @@ -64,6 +65,7 @@ def test_pretty_str(): assert RangedValue(-50, -48, pint.Unit("V")).pretty_str() == "-49 ± 1 V" assert RangedValue(-50, -30, pint.Unit("V")).pretty_str() == "-50 to -30 V" assert RangedValue(-50, 50, pint.Unit("V")).pretty_str() == "± 50V" + assert RangedValue(-50, 50, pint.Unit("mV")).pretty_str() == "± 50mV" # Make sure combined units compact properly v = RangedValue(3, 3, pint.Unit("V"))