Ë
    7^(h©  ã                  óŽ   — d Z ddlmZ ddlmZ ddlmZ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 d
dlmZ  G d„ de«      Zy)zG
Unit system for physical quantities; include definition of constants.
é    )Úannotations)ÚAdd)Ú
DerivativeÚFunction)ÚMul)ÚPow)ÚS)Ú_QuantityMapper©ÚQuantityé   )Ú	Dimensionc                  óà   ‡ — e Zd ZU dZi Zded<   ddddi fdˆ fd„Zd„ Zd	„ Zddddi fdd
„Z	d„ Z
ˆ fd„Zˆ fd„Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zedd„«       Zd„ Zd„ Zdd„Zˆ xZS )Ú
UnitSystemzð
    UnitSystem represents a coherent set of units.

    A unit system is basically a dimension system with notions of scales. Many
    of the methods are defined in the same way.

    It is much better if all base units have a symbol.
    zdict[str, UnitSystem]Ú_unit_systems© Ú Nc                óø   •— | t         j                  |<   || _        || _        || _        || _        t        t        |«      t        |«      z  «      | _        t        |«      | _        || _	        t        ‰| �-  «        y ©N)r   r   ÚnameÚdescrÚ_base_unitsÚ_dimension_systemÚtupleÚsetÚ_unitsÚ_derived_unitsÚsuperÚ__init__)ÚselfÚ
base_unitsÚunitsr   r   Údimension_systemÚderived_unitsÚ	__class__s          €ú\/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sympy/physics/units/unitsystem.pyr   zUnitSystem.__init__   sj   ø€ à)-Œ
× Ñ  Ñ&àˆŒ	ØˆŒ
à%ˆÔØ!1ˆÔÜœC 
›O¬c°%«jÑ8Ó9ˆŒÜ  Ó,ˆÔØ+ˆÔä‰ÑÕó    c                ó‚   — | j                   dk7  r| j                   S ddj                  d„ | j                  D «       «      z  S )zš
        Return the name of the system.

        If it does not exist, then it makes a list of symbols (or names) of
        the base dimensions.
        r   zUnitSystem((%s))ú, c              3  ó2   K  — | ]  }t        |«      –— Œ y ­wr   )Ústr)Ú.0Úds     r&   ú	<genexpr>z%UnitSystem.__str__.<locals>.<genexpr>7   s   è ø€ ò 22Ø”�A—ñ22ùs   ‚)r   Újoinr   ©r    s    r&   Ú__str__zUnitSystem.__str__,   sD   € ð �9‰9˜Š?Ø—9‘9Ðà%¨¯	©	ñ 22Ø $× 0Ñ 0ô22ó )2ñ 2ð 2r'   c                ó2   — dt        | j                  «      z  S )Nz<UnitSystem: %s>)Úreprr   r0   s    r&   Ú__repr__zUnitSystem.__repr__:   s   € Ø!¤D¨×)9Ñ)9Ó$:Ñ:Ð:r'   c           	     óž   — | j                   t        |«      z   }| j                  t        |«      z   }t        |||||i | j                  ¥|¥«      S )a  Extend the current system into a new one.

        Take the base and normal units of the current system to merge
        them to the base and normal units given in argument.
        If not provided, name and description are overridden by empty strings.
        )r   r   r   r   r   )r    Úbaser"   r   Údescriptionr#   r$   s          r&   ÚextendzUnitSystem.extend=   sR   € ð ×Ñ¤%¨£+Ñ-ˆØ—‘œe E›lÑ*ˆä˜$  t¨[Ð:JÐLtÈt×ObÑObÐLtÐfsÐLtÓuÐur'   c                ó   — | j                   S r   )r   r0   s    r&   Úget_dimension_systemzUnitSystem.get_dimension_systemJ   s   € Ø×%Ñ%Ð%r'   c                óh   •— | j                  «       j                  }||v r||   S t        ‰| �  |«      S r   )r:   Ú_quantity_dimension_mapr   Úget_quantity_dimension)r    ÚunitÚqdmr%   s      €r&   r=   z!UnitSystem.get_quantity_dimensionM   s8   ø€ Ø×'Ñ'Ó)×AÑAˆØ�3‰;Ø�t‘9ÐÜ‰wÑ-¨dÓ3Ð3r'   c                óh   •— | j                  «       j                  }||v r||   S t        ‰| �  |«      S r   )r:   Ú_quantity_scale_factorsr   Úget_quantity_scale_factor)r    r>   Úqsfmr%   s      €r&   rB   z$UnitSystem.get_quantity_scale_factorS   s8   ø€ Ø×(Ñ(Ó*×BÑBˆØ�4‰<Ø˜‘:ÐÜ‰wÑ0°Ó6Ð6r'   c           	     óð   — t        | t        «      r| S | t        j                  vr@t        dj	                  dj                  t        t        j                  «      «      «      «      ‚t        j                  |    S )NzDUnit system is not supported. Currentlysupported unit systems are {}r)   )Ú
isinstancer   r   Ú
ValueErrorÚformatr/   Úsorted)Úunit_systems    r&   Úget_unit_systemzUnitSystem.get_unit_systemY   sf   € ä�k¤:Ô.ØÐàœj×6Ñ6Ñ6Üð0ß06±Ø—I‘Iœf¤Z×%=Ñ%=Ó>Ó?ó1óð ô ×'Ñ'¨Ñ4Ð4r'   c                 ó(   — t         j                  d   S )NÚSI)r   r   r   r'   r&   Úget_default_unit_systemz"UnitSystem.get_default_unit_systemh   s   € ä×'Ñ'¨Ñ-Ð-r'   c                ó,   — t        | j                  «      S )zr
        Give the dimension of the system.

        That is return the number of units forming the basis.
        )Úlenr   r0   s    r&   ÚdimzUnitSystem.diml   s   € ô �4×#Ñ#Ó$Ð$r'   c                ó6   — | j                  «       j                  S )zI
        Check if the underlying dimension system is consistent.
        )r:   Úis_consistentr0   s    r&   rR   zUnitSystem.is_consistentu   s   € ð ×(Ñ(Ó*×8Ñ8Ð8r'   c                ó   — | j                   S r   )r   r0   s    r&   r$   zUnitSystem.derived_units}   s   € à×"Ñ"Ð"r'   c                ó\  — ddl m} t        |t        «      r/t        |j                  D �cg c]  }| j                  |«      ‘Œ c}Ž S t        |t        «      r(| j                  |j                  «      |j                  z  S t        |t        «      r| j                  |j                  d   «      S t        |t        «      rH| j                  |j                  «      }|j                  D ]  \  }}|| j                  |«      |z  z  }Œ |S t        |t        «      rY|j                  D �cg c]  }| j                  |«      ‘Œ }}t        d„ |D «       «      rt        j                   S  |j"                  |Ž S t        ||«      r| j%                  |«      j&                  S t        j                   S c c}w c c}w )Nr   r   c              3  ó&   K  — | ]	  }|d k(  –— Œ y­w)r   Nr   )r,   Úis     r&   r.   z2UnitSystem.get_dimensional_expr.<locals>.<genexpr>�   s   è ø€ Ò(˜a�1˜•6Ñ(ùó   ‚)Úsympy.physics.unitsr   rE   r   ÚargsÚget_dimensional_exprr   r6   Úexpr   r   ÚexprÚvariable_countr   Úallr	   ÚOneÚfuncr=   r   )	r    r\   r   rV   rP   ÚindependentÚcountÚargrY   s	            r&   rZ   zUnitSystem.get_dimensional_expr�   sb  € Ý0Ü�dœCÔ Ü¸t¿y¹yÖI¸!˜×2Ñ2°1Õ5ÒIÐJÐJÜ˜œcÔ"Ø×,Ñ,¨T¯Y©YÓ7¸4¿8¹8ÑCÐCÜ˜œcÔ"Ø×,Ñ,¨T¯Y©Y°q©\Ó:Ð:Ü˜œjÔ)Ø×+Ñ+¨D¯I©IÓ6ˆCØ&*×&9Ñ&9ò EÑ"�˜UØ�t×0Ñ0°Ó=¸uÑDÑD‘ðEàˆJÜ˜œhÔ'Ø>B¿i¹iÖH°s�D×-Ñ-¨cÕ2ÐHˆDÐHÜÑ( 4Ô(Ô(Ü—u‘u�Ø�4—9‘9˜dÐ#Ð#Ü˜˜hÔ'Ø×.Ñ.¨tÓ4×9Ñ9Ð9Ü�u‰uˆùò# Jùò Is   ªF$Ä"F)c                ó”  — ddl m} t        ||«      r|j                  |j                  fS t        |t
        «      r@d}t        d«      }|j                  D ]   }| j                  |«      \  }}||z  }||z  }Œ" ||fS t        |t        «      rj| j                  |j                  «      \  }}| j                  |j                  «      \  }	}
| j                  «       j                  |
«      rd}
||	z  ||	|
z  z  fS t        |t        «      rŽ| j                  |j                  d   «      \  }}|j                  dd D ]W  }| j                  |«      \  }}| j                  «       j                  ||«      st!        dj#                  |||«      «      ‚||z  }ŒY ||fS t        |t$        «      r]| j                  |j                  d   «      \  }}|j&                  D ])  \  }}| j                  |«      \  }}|||z  z  }|||z  z  }Œ+ ||fS t        |t(        «      r�|j                  D �cg c]  }| j                  |«      ‘Œ }}|D �cg c]4  }| j                  «       j                  |d   «      rt        d«      n|d   ‘Œ6 }} |j*                  d„ |D «       Ž g|¢­S t        |t        «      rt,        j.                  |fS |t        d«      fS c c}w c c}w )zU
        Return tuple with scale factor expression and dimension expression.
        r   r   r   Nz,Dimension of "{}" is {}, but it should be {}c              3  ó&   K  — | ]	  }|d    –— Œ y­w)r   Nr   )r,   Úfs     r&   r.   z;UnitSystem._collect_factor_and_dimension.<locals>.<genexpr>Â   s   è ø€ Ò2¨  !¥Ñ2ùrW   )rX   r   rE   Úscale_factorÚ	dimensionr   r   rY   Ú_collect_factor_and_dimensionr   r6   r[   r:   Úis_dimensionlessr   Úequivalent_dimsrF   rG   r   r]   r   r`   r	   r_   )r    r\   r   Úfactorrh   rc   Ú
arg_factorÚarg_dimrP   Ú
exp_factorÚexp_dimÚaddendÚaddend_factorÚ
addend_dimra   rb   ÚifactorÚidimÚfdsr-   Údimss                        r&   ri   z(UnitSystem._collect_factor_and_dimension—   sÚ  € õ 	1Ü�d˜HÔ%Ø×$Ñ$ d§n¡nÐ4Ð4Ü˜œcÔ"ØˆFÜ! !›ˆIØ—y‘yò %�Ø&*×&HÑ&HÈÓ&MÑ#�
˜GØ˜*Ñ$�Ø˜WÑ$‘	ð%ð ˜9Ð$Ð$Ü˜œcÔ"Ø×<Ñ<¸T¿Y¹YÓG‰KˆF�CØ"&×"DÑ"DÀTÇXÁXÓ"NÑˆJ˜Ø×(Ñ(Ó*×;Ñ;¸GÔDØ�Ø˜ZÑ'¨°¸gÑ1EÑ)FÐFÐFÜ˜œcÔ"Ø×<Ñ<¸T¿Y¹YÀq¹\ÓJ‰KˆF�CØŸ)™) A B˜-ò (�à×6Ñ6°vÓ>ñ *�˜zà×0Ñ0Ó2×BÑBÀ3È
ÔSÜ$ð.ß.4©fØ" J°ó/5ó6ð 6ð ˜-Ñ'‘ð(ð ˜3�;ÐÜ˜œjÔ)Ø×<Ñ<¸T¿Y¹YÀq¹\ÓJ‰KˆF�CØ&*×&9Ñ&9ò #Ñ"�˜UØ $× BÑ BÀ;Ó O‘�˜Ø˜' 5™.Ñ(�Ø�t˜U‘{Ñ"‘ð#ð ˜3�;ÐÜ˜œhÔ'ØFJÇiÁiÖP¸s�4×5Ñ5°cÕ:ÐPˆCÐPØjmÖnÐef D×$=Ñ$=Ó$?×$PÑ$PÐQRÐSTÑQUÔ$V”I˜a”LÐ\]Ð^_Ñ\`Ñ`ÐnˆDÐnØ�D—I‘IÑ2¨cÔ2Ð3Ð;°dÑ;Ð;Ü˜œiÔ(Ü—5‘5˜$�;Ðàœ 1›Ð%Ð%ùò QùÚns   ÈK È<9Kc                óB   — t        t        d„ | j                  «      «      S )zK
        Return the units of the system that do not have a prefix.
        c                ó:   — | j                    xr | j                   S r   )Úis_prefixedÚis_physical_constant)Úus    r&   ú<lambda>z3UnitSystem.get_units_non_prefixed.<locals>.<lambda>Ì   s   € ¨¯©Ð$5Ò$T¸a×>TÑ>TÐ:T€ r'   )r   Úfilterr   r0   s    r&   Úget_units_non_prefixedz!UnitSystem.get_units_non_prefixedÈ   s   € ô ”6ÑTÐVZ×VaÑVaÓbÓcÐcr'   )r$   údict[Dimension, Quantity])Úreturnr€   )r�   zset[Quantity])Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__annotations__r   r1   r4   r8   r:   r=   rB   ÚstaticmethodrJ   rM   ÚpropertyrP   rR   r$   rZ   ri   r   Ú__classcell__)r%   s   @r&   r   r      sÑ   ø… ñð ,.€MÐ(Ó-à)+°"¸BÐQUð  ACö ò2ò;ð "$¨"¸"Ètð  Aô vò&ô4ô7ð ñ5ó ð5ð ñ.ó ð.ð ñ%ó ð%ð ñ9ó ð9ð ò#ó ð#òò,/&÷bdr'   r   N)r…   Ú
__future__r   Úsympy.core.addr   Úsympy.core.functionr   r   Úsympy.core.mulr   Úsympy.core.powerr   Úsympy.core.singletonr	   Úsympy.physics.units.dimensionsr
   Úsympy.physics.units.quantitiesr   Ú
dimensionsr   r   r   r'   r&   ú<module>r“      s7   ðñõ #å ß 6Ý Ý  Ý "Ý :Ý 3å !ô{d�õ {dr'   