You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
diff_str = Voltage("3.3V").diff("5V") # 1.7V (strings are auto-converted)
913
+
```
914
+
915
+
**Note:** All arithmetic operations and methods automatically convert string arguments to physical values when possible. For example, `Voltage("3.3V") + "2V"` works and returns `5.3V`.
916
+
917
+
**Tolerance Handling:**
918
+
919
+
- Multiplication/Division: Tolerance preserved only for dimensionless scaling (e.g., `2 * 3.3V±1%` keeps 1%)
920
+
- Addition/Subtraction: Tolerance is always dropped
921
+
-`.abs()`: Tolerance is preserved
922
+
-`.diff()`: Tolerance is dropped (consistent with subtraction)
923
+
924
+
**Parsing Support:**
925
+
926
+
Physical value constructors accept flexible string formats:
927
+
928
+
```python
929
+
# Basic format with units
930
+
Voltage("3.3V")
931
+
Current("100mA")
932
+
933
+
# SI prefixes: m, μ/u, n, p, k, M, G
934
+
Capacitance("100nF")
935
+
Resistance("4.7kOhm")
936
+
937
+
# Resistor notation (4k7 = 4.7kΩ)
938
+
Resistance("4k7")
939
+
940
+
# Temperature conversions
941
+
Temperature("25C") # Converts to Kelvin
942
+
Temperature("77F") # Converts to Kelvin
943
+
```
944
+
818
945
### builtin.physical_range(unit)
819
946
820
947
**Built-in function** that creates unit-specific range constructor types for defining bounded physical value ranges.
0 commit comments