2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-06-06 08:54:24 +00:00

Specify R as ohms (#12065)

* Specify R as ohms

* Adjust comments
This commit is contained in:
Oliver
2026-06-02 16:16:19 +10:00
committed by GitHub
parent d3be030486
commit 0f717e2749
2 changed files with 13 additions and 0 deletions
@@ -114,6 +114,9 @@ def reload_unit_registry():
reg.define('@alias degF = Fahrenheit') reg.define('@alias degF = Fahrenheit')
reg.define('@alias degK = Kelvin') reg.define('@alias degK = Kelvin')
# Override R as ohm (pint defines R as an SI prefix by default)
reg.define('R = ohm')
# Define some "standard" additional units # Define some "standard" additional units
reg.define('piece = 1') reg.define('piece = 1')
reg.define('each = 1 = ea') reg.define('each = 1 = ea')
+10
View File
@@ -293,6 +293,16 @@ class ConversionTest(TestCase):
) )
self.assertAlmostEqual(output, expected, 12) self.assertAlmostEqual(output, expected, 12)
# Test that 'R' is interpreted as ohms
# Ref: https://github.com/inventree/InvenTree/issues/12063
r_tests = [('8R6', 8.6), ('10R', 10), ('4R7', 4.7), ('100R', 100)]
for val, expected in r_tests:
output = InvenTree.conversion.convert_physical_value(
val, 'ohm', strip_units=True
)
self.assertAlmostEqual(output, expected, 6)
def test_scientific_notation(self): def test_scientific_notation(self):
"""Test that scientific notation is handled correctly.""" """Test that scientific notation is handled correctly."""
tests = [ tests = [