
    sg?                     p    d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
  G d de      Z G d	 d
e      Zy)z
Physical quantities.
    )
AtomicExpr)Symbol)sympify)_QuantityMapper)Prefixc                       e Zd ZdZdZdZdZdZdZdZ		 	 	 	 ddZ
d Zd Zed        Zed	        Zed
        Zed        Zd Zd Zd Zd Zd ZddZed        Zed        Zy)QuantityzX
    Physical quantity: can be a unit of measure, a constant or a generic quantity.
    TFNc                    t        |t              st        |      }||}nt        |t              rt        |      }|| _        t	        j
                  | ||      }	||	_        ||	_        ||	_        ||	_	        ||	_
        ||	_        ||	_        |	S N)
isinstancer   str_is_prefixedr   __new___name_abbrev_latex_repr_unicode_repr_ascii_repr_mathml_repr)
clsnameabbrev
latex_reprpretty_unicode_reprpretty_ascii_reprmathml_presentation_repris_prefixedassumptionsobjs
             Q/var/www/html/venv/lib/python3.12/site-packages/sympy/physics/units/quantities.pyr   zQuantity.__new__   s     $'$<D>F$F^F '  dF3	$/+3&
    c                 *    |t         j                  | <   y r   )r   _quantity_dimension_global)self	dimensions     r    set_global_dimensionzQuantity.set_global_dimension3   s    ;D2248r!   c                     ddl m} t        |      }t        |t              rd| _        |j                  d d       }t        |      }||f|j                  | <   ||j                  | <   y)zN
        Setting a scale factor that is valid across all unit system.
        r   
UnitSystemTc                 "    t        | t              S r   )r   r   xs    r    <lambda>z;Quantity.set_global_relative_scale_factor.<locals>.<lambda>@   s    jF+ r!   c                     | j                   S r   )scale_factorr+   s    r    r-   z;Quantity.set_global_relative_scale_factor.<locals>.<lambda>A   s
    ann r!   N)	sympy.physics.unitsr)   r   r   r   r   replace_quantity_scale_factors_global,_quantity_dimensional_equivalence_map_global)r$   r/   reference_quantityr)   s       r     set_global_relative_scale_factorz)Quantity.set_global_relative_scale_factor6   sk     	3|,lF+ $D#+++$
 |,;GI[:\
11$7HZ
??Er!   c                     | j                   S r   )r   r$   s    r    r   zQuantity.nameG   s    zzr!   c                 P    ddl m} |j                         }|j                  |       S )Nr   r(   )r0   r)   get_default_unit_systemget_quantity_dimensionr$   r)   unit_systems      r    r%   zQuantity.dimensionK   s$    2 88:11$77r!   c                     | j                   S )z
        Symbol representing the unit name.

        Prepend the abbreviation with the prefix symbol if it is defines.
        )r   r7   s    r    r   zQuantity.abbrevQ   s     ||r!   c                 P    ddl m} |j                         }|j                  |       S )zW
        Overall magnitude of the quantity as compared to the canonical units.
        r   r(   )r0   r)   r9   get_quantity_scale_factorr;   s      r    r/   zQuantity.scale_factorZ   s&    
 	3 88:44T::r!   c                      yNT r7   s    r    _eval_is_positivezQuantity._eval_is_positivec       r!   c                      yrA   rB   r7   s    r    _eval_is_constantzQuantity._eval_is_constantf   rD   r!   c                     | S r   rB   r7   s    r    	_eval_AbszQuantity._eval_Absi   s    r!   c                 4    t        |t              r| |k7  r| S y y r   )r   r	   )r$   oldnews      r    
_eval_subszQuantity._eval_subsl   s    c8$K *5$r!   c                     | j                   r| j                   S dj                  t        | j                        dk\  r| j                  d         S | j                  d         S )Nz\text{{{}}}      r   )r   formatlenargs)r$   printers     r    _latexzQuantity._latexp   s`    ###!(( ^q0 *.1 D D6:iilD Dr!   c                 "    ddl m}  || ||      S )a  
        Convert the quantity to another quantity of same dimensions.

        Examples
        ========

        >>> from sympy.physics.units import speed_of_light, meter, second
        >>> speed_of_light
        speed_of_light
        >>> speed_of_light.convert_to(meter/second)
        299792458*meter/second

        >>> from sympy.physics.units import liter
        >>> liter.convert_to(meter**3)
        meter**3/1000
        rO   )
convert_to)utilrV   )r$   otherr<   rV   s       r    rV   zQuantity.convert_tow   s    " 	%${33r!   c                     t               S )z"Return free symbols from quantity.)setr7   s    r    free_symbolszQuantity.free_symbols   s     ur!   c                     | j                   S )zWWhether or not the quantity is prefixed. Eg. `kilogram` is prefixed, but `gram` is not.)r   r7   s    r    r   zQuantity.is_prefixed   s        r!   )NNNNNF)SI)__name__
__module____qualname____doc__is_commutativeis_real	is_number
is_nonzerois_physical_constant	_diff_wrtr   r&   r5   propertyr   r%   r   r/   rC   rF   rH   rL   rT   rV   r[   r   rB   r!   r    r	   r	      s     NGIJ I"&59AE!6E["   8 8
   ; ;D4(   ! !r!   r	   c                       e Zd ZdZdZy)PhysicalConstantzLRepresents a physical constant, eg. `speed_of_light` or `avogadro_constant`.TN)r^   r_   r`   ra   rf   rB   r!   r    rj   rj      s    Vr!   rj   N)ra   sympy.core.exprr   sympy.core.symbolr   sympy.core.sympifyr   sympy.physics.units.dimensionsr   sympy.physics.units.prefixesr   r	   rj   rB   r!   r    <module>rp      s6    ' $ & : /G!z G!R x  r!   