
    g?                     ~    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dS )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dS )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
             Z/var/www/html/ai-engine/env/lib/python3.11/site-packages/sympy/physics/units/quantities.pyr   zQuantity.__new__   s     $'' 	 $<<D>FF$$ 	$F^^F ' dF33	$/+3&
    c                 $    |t           j        | <   d S r   )r   _quantity_dimension_global)self	dimensions     r    set_global_dimensionzQuantity.set_global_dimension3   s    ;D24888r!   c                     ddl m} t          |          }t          |t                    rd| _        |                    d d           }t          |          }||f|j        | <   ||j        | <   dS )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    an 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   s     	322222|,,lF++ 	% $D#++++$$
 
 |,,;GI[:\
1$7HZ
?EEEr!   c                     | j         S r   )r   r$   s    r    r   zQuantity.nameG   s
    zr!   c                 `    ddl m} |                                }|                    |           S )Nr   r(   )r0   r)   get_default_unit_systemget_quantity_dimensionr$   r)   unit_systems      r    r%   zQuantity.dimensionK   s9    222222 88::11$7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                 `    ddl m} |                                }|                    |           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22222 88::44T:::r!   c                     dS NT r7   s    r    _eval_is_positivezQuantity._eval_is_positivec       tr!   c                     dS 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                 D    t          |t                    r| |k    r| S d S d S r   )r   r	   )r$   oldnews      r    
_eval_subszQuantity._eval_subsl   s/    c8$$ 	K	 	r!   c                     | j         r| j         S d                    t          | j                  dk    r| j        d         n| j        d                   S )Nz\text{{{}}}      r   )r   formatlenargs)r$   printers     r    _latexzQuantity._latexp   s[     	D##!(( ^^q00 *.16:ilD D Dr!   SIc                 (    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)utilrW   )r$   otherr<   rW   s       r    rW   zQuantity.convert_tow   s*    " 	%$$$$$z${333r!   c                     t                      S )z"Return free symbols from quantity.)setr7   s    r    free_symbolszQuantity.free_symbols   s     uu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)rU   )__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   rW   r\   r   rB   r!   r    r	   r	      s         NGIJ I"&59AE!   6E E E[ [ ["   X 8 8 X8
   X ; ; X;        D D D4 4 4 4(   X ! ! X! ! !r!   r	   c                       e Zd ZdZdZdS )PhysicalConstantzLRepresents a physical constant, eg. `speed_of_light` or `avogadro_constant`.TN)r^   r_   r`   ra   rf   rB   r!   r    rj   rj      s        V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      s     ' & & & & & $ $ $ $ $ $ & & & & & & : : : : : : / / / / / /G! G! G! G! G!z G! G! G!R         x          r!   