§
    ¹³Ùgï  ã                  ó<   — d Z ddlmZ ddlZddlmZ dd
„Zddd„ZdS )zSI unit utilitiesé    )ÚannotationsN)ÚParameterExpressionÚvalueúfloat | ParameterExpressionÚunitÚstrÚreturnc                óú   — dddddddddd	d
dœ}|rt          |¦  «        dk    r| S |d         |vrt          d|› �¦  «        ‚||d                  }|dk     r| t          d| ¦  «        z  S | t          d|¦  «        z  S )aÚ  
    Given a SI unit prefix and value, apply the prefix to convert to
    standard SI unit.

    Args:
        value: The number to apply prefix to.
        unit: String prefix.

    Returns:
        Converted value.

    .. note::

        This may induce tiny value error due to internal representation of float object.
        See https://docs.python.org/3/tutorial/floatingpoint.html for details.

    Raises:
        ValueError: If the ``units`` aren't recognized.
    éñÿÿÿéôÿÿÿé÷ÿÿÿéúÿÿÿéýÿÿÿé   é   é	   é   é   )ÚfÚpÚnÚuõ   ÂµÚmÚkÚMÚGÚTÚPé   r   zCould not understand unit: é
   )ÚlenÚ
ValueErrorÚpow)r   r   Ú
prefactorsÚpow10s       úH/granary/edev/quantum/lib/python3.11/site-packages/qiskit/utils/units.pyÚapply_prefixr(      sµ   € ð* ØØØØØØØØØØðð €Jð ð •3�t‘9”9 ’>�>àˆàˆA„w�jÐ Ð ÝÐ=°tÐ=Ð=Ñ>Ô>Ð>à�t˜A”wÔ€Eð ˆq‚y€yØ•s˜2 ˜v‘”Ñ&Ð&à•3�r˜5‘>”>Ñ!Ð!ó    ÚfloatÚdecimalú
int | Noneútuple[float, str]c                ó"  — ddddddddd	d
ddœ}t          j        | ¦  «        st          d| › d�¦  «        ‚t          j        | ¦  «        dk    rLt	          t          j        t          j        t          j        | ¦  «        ¦  «        dz  ¦  «        dz  ¦  «        }nd}|dk    r| t          d|¦  «        z  }n| t          d| ¦  «        z  }|�%t          j        ||¦  «        }|dk    r
|dz  }|dz  }||vrt          d| › �¦  «        ‚|||         fS )aÄ  
    Given a SI unit value, find the most suitable prefix to scale the value.

    For example, the ``value = 1.3e8`` will be converted into a tuple of ``(130.0, "M")``,
    which represents a scaled value and auxiliary unit that may be used to display the value.
    In above example, that value might be displayed as ``130 MHz`` (unit is arbitrary here).

    Example:

        >>> value, prefix = detach_prefix(1e4)
        >>> print(f"{value} {prefix}Hz")
        10 kHz

    Args:
        value: The number to find prefix.
        decimal: Optional. An arbitrary integer number to represent a precision of the value.
            If specified, it tries to round the mantissa and adjust the prefix to rounded value.
            For example, 999_999.91 will become 999.9999 k with ``decimal=4``,
            while 1.0 M with ``decimal=3`` or less.

    Returns:
        A tuple of scaled value and prefix.

    .. note::

        This may induce tiny value error due to internal representation of float object.
        See https://docs.python.org/3/tutorial/floatingpoint.html for details.

    Raises:
        ValueError: If the ``value`` is out of range.
        ValueError: If the ``value`` is not real number.
    r   r   r   r   r   Ú r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   z,Input should be real number. Cannot convert ú.r   r   r!   Niè  zValue is out of range: )	ÚnpÚisrealr#   ÚabsÚintÚfloorÚlog10r$   Úround)r   r+   r%   r&   Úmants        r'   Údetach_prefixr9   G   sG  € ðD ØØØØØØØØØØðð €Jõ Œ9�UÑÔð RÝÐPÈÐPÐPÐPÑQÔQÐQå	„vˆe�}„}˜ÒÐÝ•B”H�RœX¥b¤f¨U¡m¤mÑ4Ô4°qÑ8Ñ9Ô9¸AÑ=Ñ>Ô>ˆˆàˆð ˆq‚y€yØ•s˜2˜u‘~”~Ñ%ˆˆà•s˜2 ˜v‘”Ñ&ˆàÐõ Œx˜˜gÑ&Ô&ˆØ�4Š<ˆ<Ø�D‰LˆDØ�Q‰JˆEà�JÐÐÝÐ:°5Ð:Ð:Ñ;Ô;Ð;à�˜EÔ"Ð"Ð"r)   )r   r   r   r   r	   r   )N)r   r*   r+   r,   r	   r-   )	Ú__doc__Ú
__future__r   Únumpyr1   Ú"qiskit.circuit.parameterexpressionr   r(   r9   © r)   r'   ú<module>r?      s|   ðð Ð Ø "Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð à BÐ BÐ BÐ BÐ BÐ Bð/"ð /"ð /"ð /"ðdH#ð H#ð H#ð H#ð H#ð H#ð H#r)   