o
    jgt                     @   s  d Z ddlmZ ddlmZ ddlmZ G dd deZdd Zed	d
dZ	edddZ
edddZedddZedddZedddZedddZeddd Zed!d"d#Zed$d%d&Zed'd(d)Zed*d+d,Zed-d.d/Zed0d1d2d3d4Zed5d6d7Zed8d9d:Zed;d<d=Zed>d?d@ZedAdBdCZedDdEdFZi d
e	de
dedededededed"ed%ed(ed+ed.ed1ed6ed9ed<eeeedGZedHd
dId#ZedJd
dKd#ZedLd
dMd#Z edNd
dOd#Z!edPd
dQd#Z"edRd
dSd#Z#eee e!e"e#dTZ$dUS )Vz
Module defining unit prefixe class and some constants.

Constant dict for SI and binary prefixes are defined as PREFIXES and
BIN_PREFIXES.
    )Expr)sympify)Sc                       s   e Zd ZdZdZdZeddfddZedd	 Z	ed
d Z
edd Zdd Zedd Zdd Zdd Z fddZ fddZdd Z  ZS )Prefixa  
    This class represent prefixes, with their name, symbol and factor.

    Prefixes are used to create derived units from a given unit. They should
    always be encapsulated into units.

    The factor is constructed from a base (default is 10) to some power, and
    it gives the total multiple or fraction. For example the kilometer km
    is constructed from the meter (factor 1) and the kilo (10 to the power 3,
    i.e. 1000). The base can be changed to allow e.g. binary prefixes.

    A prefix multiplied by something will always return the product of this
    other object times the factor, except if the other object:

    - is a prefix and they can be combined into a new prefix;
    - defines multiplication with prefixes (which is the case for the Unit
      class).
    g      *@T
   Nc                 C   s^   t |}t |}t |}t |}t| ||||}||_||_|| |_||_||_||_|S N)	r   r   __new___name_abbrev_scale_factor	_exponent_base_latex_repr)clsnameabbrevexponentbase
latex_reprobj r   T/var/www/html/zoom/venv/lib/python3.10/site-packages/sympy/physics/units/prefixes.pyr   !   s   
zPrefix.__new__c                 C      | j S r   )r	   selfr   r   r   r   1      zPrefix.namec                 C   r   r   )r
   r   r   r   r   r   5   r   zPrefix.abbrevc                 C   r   r   )r   r   r   r   r   scale_factor9   r   zPrefix.scale_factorc                 C   s   | j d u r
d| j S | j S )Nz	\text{%s})r   r
   )r   printerr   r   r   _latex=   s   

zPrefix._latexc                 C   r   r   )r   r   r   r   r   r   B   r   zPrefix.basec                 C   s
   t | jS r   )strr
   r   r   r   r   __str__F   s   
zPrefix.__str__c                 C   sF   | j dkrdt| jt| j| jf S dt| jt| j| j| j f S )Nr   zPrefix(%r, %r, %r)zPrefix(%r, %r, %r, %r))r   r   r   r   r   r   r   r   r   __repr__I   s   
zPrefix.__repr__c                    s|   ddl m} t||tfst |S | j|j }t|tr9|dkr%tjS t	D ]}t	| j|kr6t	|   S q'|S | j| S )Nr   Quantity   )
sympy.physics.unitsr#   
isinstancer   super__mul__r   r   OnePREFIXES)r   otherr#   factp	__class__r   r   r(   Q   s   

zPrefix.__mul__c                    sl   t |dst |S | j|j }|dkrtjS t|tr1tD ]}t| j|kr.t|   S q|S | j| S )Nr   r$   )	hasattrr'   __truediv__r   r   r)   r&   r   r*   )r   r+   r,   r-   r.   r   r   r1   c   s   


zPrefix.__truediv__c                 C   s<   |dkrt D ]}t | jd| j krt |   S q|| j S )Nr$   )r*   r   )r   r+   r-   r   r   r   __rtruediv__s   s   
zPrefix.__rtruediv__)__name__
__module____qualname____doc___op_priorityis_commutativer   r   propertyr   r   r   r   r   r    r!   r(   r1   r2   __classcell__r   r   r.   r   r      s&    



r   c                 C   sx   ddl m} ddlm} g }| D ]'}|d|j| jf d|j| jf dd}| |j|< |j| f|j	|< |
| q|S )aK  
    Return a list of all units formed by unit and the given prefixes.

    You can use the predefined PREFIXES or BIN_PREFIXES, but you can also
    pass as argument a subdict of them if you do not want all prefixed units.

        >>> from sympy.physics.units.prefixes import (PREFIXES,
        ...                                                 prefix_unit)
        >>> from sympy.physics.units import m
        >>> pref = {"m": PREFIXES["m"], "c": PREFIXES["c"], "d": PREFIXES["d"]}
        >>> prefix_unit(m, pref)  # doctest: +SKIP
        [millimeter, centimeter, decimeter]
    r   r"   )
UnitSystemz%s%sT)r   is_prefixed)sympy.physics.units.quantitiesr#   r%   r;   valuesr   r   ,_quantity_dimensional_equivalence_map_globalr   _quantity_scale_factors_globalappend)unitprefixesr#   r;   prefixed_unitsprefixquantityr   r   r   prefix_unit{   s   
rG   yottaY   zettaZ   exaE   petaP   teraT   gigaG	   megaM   kilok   hectoh   decadar$   decidcenticmillimmicromuiz\mu)r   nanonipicor-   ifemtofiattoaizeptoziyoctoyi)rv   rx   rz   kibir   mebi   gibi   tebi(   pebi2   exbi<   )KiMiGiTiPiEiN)%r6   sympy.core.exprr   sympy.core.sympifyr   sympy.core.singletonr   r   rG   rH   rK   rN   rQ   rT   rW   rZ   r]   r`   rc   re   rh   rk   rn   rp   rr   rs   ru   rw   ry   r*   r{   r|   r~   r   r   r   BIN_PREFIXESr   r   r   r   <module>   s    p!	

