
    EdL#                         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
 ddlmZmZmZ  G d d	e          Z G d
 de          ZdS )z
Physical quantities.
    )
AtomicExpr)Symbol)sympify)_QuantityMapper)Prefix)sympy_deprecation_warningSymPyDeprecationWarningignore_warningsc                   0   e Zd ZdZdZdZdZdZdZdZ		 	 	 	 ddZ
d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edd            Zed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          |          }t          |t                    st          |t                    s|||}}}|t          ddd           |t          ddd           ||}n$t          |t                    rt          |          }|	| _        t          j        | ||          }||_        ||_        ||_	        ||_
        ||_        ||_        |	|_        |At          t                    5  |                    |           d d d            n# 1 swxY w Y   |At          t                    5  |                    |           d d d            n# 1 swxY w Y   |S )Nz
                The 'dimension' argument to to Quantity() is deprecated.
                Instead use the unit_system.set_quantity_dimension() method.
                z1.3z*deprecated-quantity-dimension-scale-factordeprecated_since_versionactive_deprecations_targetz
                The 'scale_factor' argument to to Quantity() is deprecated.
                Instead use the unit_system.set_quantity_scale_factors()
                method.
                )
isinstancer   strr   _is_prefixedr   __new___name_abbrev_latex_repr_unicode_repr_ascii_repr_mathml_reprr
   r	   set_dimensionset_scale_factor)clsnameabbrev	dimensionscale_factor
latex_reprpretty_unicode_reprpretty_ascii_reprmathml_presentation_repris_prefixedassumptionsobjs               >lib/python3.11/site-packages/sympy/physics/units/quantities.pyr   zQuantity.__new__   s9    $'' 	 $<<D &#&& 	Nff--	N.4iV|I 	% */+W     		%
 */+W     	$FF$$ 	$F^^F ' dF33	$/+3& 	- !899 - -!!),,,- - - - - - - - - - - - - - -  	3 !899 3 3$$\2223 3 3 3 3 3 3 3 3 3 3 3 3 3 3 
s$   
D,,D03D0E//E36E3SIc                     t          d|  ddd           ddlm} |                    |          }|                    | |           d S )Nz
            Quantity.set_dimension() is deprecated. Use either
            unit_system.set_quantity_dimension() or
            z-.set_global_dimension() instead.
            1.5deprecated-quantity-methodsr   r   
UnitSystem)r   sympy.physics.unitsr/   get_unit_systemset_quantity_dimension)selfr    unit_systemr/   s       r)   r   zQuantity.set_dimension\   s}    !   
 &+'D	
 	
 	
 	
 	322222 00==**4;;;;;    c                     t          d|  ddd           ddlm} |                    |          }|                    | |           d S )Nz
            Quantity.set_scale_factor() is deprecated. Use either
            unit_system.set_quantity_scale_factors() or
            z9.set_global_relative_scale_factor() instead.
            r,   r-   r   r   r.   )r   r0   r/   r1   set_quantity_scale_factor)r3   r!   r4   r/   s       r)   r   zQuantity.set_scale_factorj   s}    !   
 &+'D	
 	
 	
 	
 	322222 00==--dLAAAAAr5   c                 $    |t           j        | <   d S N)r   _quantity_dimension_global)r3   r    s     r)   set_global_dimensionzQuantity.set_global_dimensionx   s    ;D24888r5   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   r.   Tc                 ,    t          | t                    S r9   )r   r   xs    r)   <lambda>z;Quantity.set_global_relative_scale_factor.<locals>.<lambda>   s    jF++ r5   c                     | j         S r9   )r!   r>   s    r)   r@   z;Quantity.set_global_relative_scale_factor.<locals>.<lambda>   s    an r5   N)	r0   r/   r   r   r   r   replace_quantity_scale_factors_global,_quantity_dimensional_equivalence_map_global)r3   r!   reference_quantityr/   s       r)    set_global_relative_scale_factorz)Quantity.set_global_relative_scale_factor{   s     	322222|,,lF++ 	% $D#++++$$
 
 |,,;GI[:\
1$7HZ
?EEEr5   c                     | j         S r9   )r   r3   s    r)   r   zQuantity.name   s
    zr5   c                 `    ddl m} |                                }|                    |           S )Nr   r.   )r0   r/   get_default_unit_systemget_quantity_dimensionr3   r/   r4   s      r)   r    zQuantity.dimension   s9    222222 88::11$777r5   c                     | j         S )z
        Symbol representing the unit name.

        Prepend the abbreviation with the prefix symbol if it is defines.
        )r   rH   s    r)   r   zQuantity.abbrev   s     |r5   c                 `    ddl m} |                                }|                    |           S )zW
        Overall magnitude of the quantity as compared to the canonical units.
        r   r.   )r0   r/   rJ   get_quantity_scale_factorrL   s      r)   r!   zQuantity.scale_factor   s;    
 	322222 88::44T:::r5   c                     dS NT rH   s    r)   _eval_is_positivezQuantity._eval_is_positive       tr5   c                     dS rQ   rR   rH   s    r)   _eval_is_constantzQuantity._eval_is_constant   rT   r5   c                     | S r9   rR   rH   s    r)   	_eval_AbszQuantity._eval_Abs   s    r5   c                 D    t          |t                    r| |k    r| S d S d S r9   )r   r   )r3   oldnews      r)   
_eval_subszQuantity._eval_subs   s8    c8$$ 	 	K	 	 	 	r5   c                     t          ddd           ddlm} |                    |          }|                    |           S )Na  
            Quantity.get_dimensional_expr() is deprecated. It is now
            associated with UnitSystem objects. The dimensional relations
            depend on the unit system used. Use
            unit_system.get_dimensional_expr() instead.
            r,   r-   r   r   r.   )r   r0   r/   r1   get_dimensional_exprexprr4   r/   s      r)   r^   zQuantity.get_dimensional_expr   sa    ! &+'D		
 		
 		
 		
 	322222 00==//555r5   c                     t          ddd           ddlm} |                    |          }|                    |           S )zCReturn tuple with scale factor expression and dimension expression.z
            Quantity._collect_factor_and_dimension() is deprecated. This
            method has been moved to the UnitSystem class. Use
            unit_system._collect_factor_and_dimension(expr) instead.
            r,   r-   r   r   r.   )r   r0   r/   r1   _collect_factor_and_dimensionr_   s      r)   rb   z&Quantity._collect_factor_and_dimension   sc     	"
 &+'D	
 	
 	
 	
 	322222 00==88>>>r5   c                     | j         r| j         S d                    t          | j                  dk    r| j        d         n| j        d                   S )Nz\text{{{}}}      r   )r   formatlenargs)r3   printers     r)   _latexzQuantity._latex   s[     	D##!(( ^^q0*C16:ilD D Dr5   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
        re   )
convert_to)utilrl   )r3   otherr4   rl   s       r)   rl   zQuantity.convert_to   s*    " 	%$$$$$z${333r5   c                     t                      S )z"Return free symbols from quantity.)setrH   s    r)   free_symbolszQuantity.free_symbols   s     uur5   c                     | j         S )zWWhether or not the quantity is prefixed. Eg. `kilogram` is prefixed, but `gram` is not.)r   rH   s    r)   r&   zQuantity.is_prefixed   s       r5   )NNNNNNNF)r*   )__name__
__module____qualname____doc__is_commutativeis_real	is_number
is_nonzerois_physical_constant	_diff_wrtr   r   r   r;   rF   propertyr   r    r   r!   rS   rV   rX   r\   staticmethodr^   rb   rj   rl   rq   r&   rR   r5   r)   r   r      s         NGIJ IEI59AE!? ? ? ?B< < < <B B B BE E E[ [ ["   X 8 8 X8
   X ; ; X;         6 6 6 \6 ? ? ? \?D D D4 4 4 4(   X ! ! X! ! !r5   r   c                       e Zd ZdZdZdS )PhysicalConstantzLRepresents a physical constant, eg. `speed_of_light` or `avogadro_constant`.TN)rs   rt   ru   rv   r{   rR   r5   r)   r   r      s        VVr5   r   N)rv   sympy.core.exprr   sympy.core.symbolr   sympy.core.sympifyr   sympy.physics.units.dimensionsr   sympy.physics.units.prefixesr   sympy.utilities.exceptionsr   r	   r
   r   r   rR   r5   r)   <module>r      s    ' & & & & & $ $ $ $ $ $ & & & & & & : : : : : : / / / / / /9 9 9 9 9 9 9 9 9 9
i! i! i! i! i!z i! i! i!V         x          r5   