padne.units =========== .. py:module:: padne.units Classes ------- .. autoapisummary:: padne.units.Value Module Contents --------------- .. py:class:: Value .. py:attribute:: value :type: float .. py:attribute:: unit :type: str .. py:method:: parse(s: str) -> Value :classmethod: Parse a string containing a value with optional SI prefix and unit. Examples: "100mA" -> Value(value=0.1, unit="A") "0.1A" -> Value(value=0.1, unit="A") "1e4A" -> Value(value=10000.0, unit="A") "100 mA" -> Value(value=0.1, unit="A") "50uV" -> Value(value=0.00005, unit="V") "10" -> Value(value=10.0, unit="") Args: s: String to parse Returns: Value object with parsed value and unit Raises: ValueError: If the string cannot be parsed .. py:method:: pretty_format(decimal_places: int | None = None) -> str Pretty format the stored value with SI prefix and unit. Uses self.value and self.unit. Args: decimal_places: Number of decimal places to show. If None, uses smart precision based on magnitude (1-3 decimal places). Returns: A formatted string with the value, appropriate SI prefix, and unit Examples: >>> Value(0.000001, "A").pretty_format() '1.000 μA' >>> Value(1500, "V").pretty_format() '1.500 kV' >>> Value(23.97, "V").pretty_format(3) '23.970 V' >>> Value(23.97, "V").pretty_format(5) '23.97000 V'