Ë
    P/æjd+  ã                   óŒ   — d Z ddlZddlZddlZddlmZmZ ddlmZ d„ Z	d„ Z
d„ Zd„ Z G d	„ d
«      Z	 	 dd„Zd„ Zd„ Zddœd„Zy)zUseful utility decorators. é    N)ÚwrapsÚupdate_wrapper©Úsympy_deprecation_warningc                 ób   ‡ ‡‡‡‡— ddl mŠ ddlmŠ ddlmŠ t        ‰ «      ˆˆ ˆˆˆfd„«       }|S )z'A factory for ``threaded`` decorators. r   )Úsympify)Ú
MatrixBase)Úiterablec           
      ó  •‡‡— t        | ‰«      r| j                  ˆˆˆfd„«      S  ‰| «      r*	 | j                  | D �cg c]  } ‰|g‰¢­i ‰¤Ž‘Œ c}«      S  ‰| «      } ‰r=| j                  r1 | j                  | j
                  D �cg c]  } ‰|g‰¢­i ‰¤Ž‘Œ c}Ž S | j                  r:| j                   ‰| j                  g‰¢­i ‰¤Ž ‰| j                  g‰¢­i ‰¤Ž«      S  ‰| g‰¢­i ‰¤ŽS c c}w # t        $ r | cY S w xY wc c}w )Nc                 ó   •—  ‰| g‰¢­i ‰¤ŽS ©N© )ÚfÚargsÚfuncÚkwargss    €€€ú\/root/repos/pocs/video-evals/.venv/lib/python3.12/site-packages/sympy/utilities/decorator.pyú<lambda>z9threaded_factory.<locals>.threaded_func.<locals>.<lambda>   s   ø€ ©D°Ð,D°TÒ,D¸VÑ,D€ ó    )	Ú
isinstanceÚ	applyfuncÚ	__class__Ú	TypeErrorÚis_Addr   Úis_RelationalÚlhsÚrhs)	Úexprr   r   r   r	   r   r
   r   Úuse_adds	    `` €€€€€r   Úthreaded_funcz'threaded_factory.<locals>.threaded_func   s  ú€ ä�d˜JÔ'Ø—>‘>Õ"DÓEÐEÙ�dŒ^ðØ—~‘~ÈÖ&NÀA¡t¨AÐ'?°Ò'?¸Ó'?Ò&NÓOÐOñ ˜4“=ˆDá˜4Ÿ;š;Ø%�t—~‘~È4Ï9É9Ö'VÀa©¨aÐ)A°$Ò)A¸&Ó)AÒ'VÐWÐWØ×#Ò#Ø—~‘~¡d¨4¯8©8Ð&E°dÒ&E¸fÑ&EÙ&*¨4¯8©8Ð&E°dÒ&E¸fÑ&EóGð Gñ ˜DÐ2 4Ò2¨6Ñ2Ð2ùò 'OøÜò Ø’ðüò (Ws(   ¯C6 ¾C1ÁC6 ÂDÃ1C6 Ã6DÄD)Ú
sympy.corer   Úsympy.matricesr	   Úsympy.utilities.iterablesr
   r   )r   r   r    r	   r
   r   s   `` @@@r   Úthreaded_factoryr$   
   s*   ü€ å"Ý)Ý2ä
ˆ4ƒ[÷3ó ð3ð& Ðr   c                 ó   — t        | d«      S )aU  Apply ``func`` to sub--elements of an object, including :class:`~.Add`.

    This decorator is intended to make it uniformly possible to apply a
    function to all elements of composite objects, e.g. matrices, lists, tuples
    and other iterable containers, or just expressions.

    This version of :func:`threaded` decorator allows threading over
    elements of :class:`~.Add` class. If this behavior is not desirable
    use :func:`xthreaded` decorator.

    Functions using this decorator must have the following signature::

      @threaded
      def function(expr, *args, **kwargs):

    T©r$   ©r   s    r   Úthreadedr(   '   s   € ô" ˜D $Ó'Ð'r   c                 ó   — t        | d«      S )aX  Apply ``func`` to sub--elements of an object, excluding :class:`~.Add`.

    This decorator is intended to make it uniformly possible to apply a
    function to all elements of composite objects, e.g. matrices, lists, tuples
    and other iterable containers, or just expressions.

    This version of :func:`threaded` decorator disallows threading over
    elements of :class:`~.Add` class. If this behavior is not desirable
    use :func:`threaded` decorator.

    Functions using this decorator must have the following signature::

      @xthreaded
      def function(expr, *args, **kwargs):

    Fr&   r'   s    r   Ú	xthreadedr*   ;   s   € ô" ˜D %Ó(Ð(r   c                 ó6   ‡ ‡— ddl Šˆ ˆfd„}t        |‰ «      }|S )zwAfter the function finishes, resets the value of ``mpmath.mp.dps`` to
    the value it had before the function was run.r   Nc                  ó�   •— ‰j                   j                  }	  ‰| i |¤Ž|‰j                   _        S # |‰j                   _        w xY wr   )ÚmpÚdps)r   r   r.   r   Úmpmaths      €€r   Úfunc_wrapperz)conserve_mpmath_dps.<locals>.func_wrapperT   s9   ø€ Ø�i‰i�m‰mˆð	 Ù˜Ð( Ñ(àˆF�I‰I�Mø˜CˆF�I‰I�Mús	   ™2 ²A)r/   r   )r   r0   r/   s   ` @r   Úconserve_mpmath_dpsr1   O   s!   ù€ ó õ ô " ,°Ó5€LØÐr   c                   ó   — e Zd ZdZd„ Zdd„Zy)Úno_attrs_in_subclassaE  Don't 'inherit' certain attributes from a base class

    >>> from sympy.utilities.decorator import no_attrs_in_subclass

    >>> class A(object):
    ...     x = 'test'

    >>> A.x = no_attrs_in_subclass(A, A.x)

    >>> class B(A):
    ...     pass

    >>> hasattr(A, 'x')
    True
    >>> hasattr(B, 'x')
    False

    c                 ó    — || _         || _        y r   )Úclsr   )Úselfr5   r   s      r   Ú__init__zno_attrs_in_subclass.__init__r   s   € ØˆŒØˆ�r   Nc                 ó¨   — || j                   k(  r>t        | j                  d«      r| j                  j                  ||«      S | j                  S t        ‚)NÚ__get__)r5   Úhasattrr   r9   ÚAttributeError)r6   ÚinstanceÚowners      r   r9   zno_attrs_in_subclass.__get__v   s@   € Ø�D—H‘HÒÜ�t—v‘v˜yÔ)Ø—v‘v—~‘~ h°Ó6Ð6Ø—6‘6ˆMÜÐr   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r7   r9   r   r   r   r3   r3   _   s   „ ñò$ôr   r3   c                 ój   ‡‡— i Š| �| ‰d<   |�|‰d<   |�|‰d<   |�|‰d<   |�|‰d<   ˆfd„Šˆˆfd„}|S )a­  
    Adds metadata about the dependencies which need to be met for doctesting
    the docstrings of the decorated objects.

    ``exe`` should be a list of executables

    ``modules`` should be a list of modules

    ``disable_viewers`` should be a list of viewers for :func:`~sympy.printing.preview.preview` to disable

    ``python_version`` should be the minimum Python version required, as a tuple
    (like ``(3, 0)``)
    ÚexecutablesÚmodulesÚdisable_viewersÚpython_versionÚground_typesc                  óv   •— ddl m} m}m}  |«       } ||d «      }	  |j                  di ‰¤Ž y# | $ r Y yw xY w)Nr   )ÚDependencyErrorÚSymPyDocTestsÚPyTestReporterFTr   )Úsympy.testing.runtestsrI   rJ   rK   Ú_check_dependencies)rI   rJ   rK   ÚrÚtÚdependenciess        €r   Ú	skiptestsz%doctest_depends_on.<locals>.skiptests™   sN   ø€ ßYÑYÙÓˆÙ˜!˜TÓ"ˆð	Ø!ˆA×!Ñ!Ñ1 LÒ1ð øð ò 	Ùð	ús   �0 °8·8c                 óº   •— ‰| _         ‰| _        t        j                  | «      r6t	        | | j                   «      | _        t	        | | j                  «      | _        | S r   )Ú_doctest_depends_onÚ__doctest_skip__ÚinspectÚisclassr3   Ú_doctest_depdends_on)ÚfnrP   rQ   s    €€r   Údepends_on_decoz+doctest_depends_on.<locals>.depends_on_deco¤   sT   ø€ Ø!-ˆÔØ'ˆÔä�?‰?˜2ÔÜ&:Ø�B×*Ñ*ó',ˆBÔ#ä"6Ø�B×'Ñ'ó#)ˆBÔàˆ	r   r   )ÚexerD   rE   rF   rG   rY   rP   rQ   s         @@r   Údoctest_depends_onr[   ~   sm   ù€ ð €LØ
€Ø&)ˆ�]Ñ#ØÐØ")ˆ�YÑØÐ"Ø*9ˆÐ&Ñ'ØÐ!Ø)7ˆÐ%Ñ&ØÐØ'3ˆ�^Ñ$ô	õ	ð Ðr   c                 ón  — t        | t        j                  «      r| j                  }| j                  }nat        | t        t
        «      t
        f«      r4t        j                  | j                     j                  }| j                  }nt        d| z  «      ‚d|vr|g|d<   | S |d   j                  |«       | S )aå  
    Append ``obj``'s name to global ``__all__`` variable (call site).

    By using this decorator on functions or classes you achieve the same goal
    as by filling ``__all__`` variables manually, you just do not have to repeat
    yourself (object's name). You also know if object is public at definition
    site, not at some random location (where ``__all__`` was set).

    Note that in multiple decorator setup (in almost all cases) ``@public``
    decorator must be applied before any other decorators, because it relies
    on the pointer to object's global namespace. If you apply other decorators
    first, ``@public`` may end up modifying the wrong namespace.

    Examples
    ========

    >>> from sympy.utilities.decorator import public

    >>> __all__ # noqa: F821
    Traceback (most recent call last):
    ...
    NameError: name '__all__' is not defined

    >>> @public
    ... def some_function():
    ...     pass

    >>> __all__ # noqa: F821
    ['some_function']

    z&expected a function or a class, got %sÚ__all__)r   ÚtypesÚFunctionTypeÚ__globals__r>   ÚtypeÚsysrD   r?   Ú__dict__r   Úappend)ÚobjÚnsÚnames      r   Úpublicrh   ²   sŸ   € ô@ �#”u×)Ñ)Ô*Ø�_‰_ˆØ�|‰|‰Ü	�Cœ$œt›*¤dÐ+Ô	,Ü�[‰[˜Ÿ™Ñ(×1Ñ1ˆØ�|‰|‰äÐ@À3ÑFÓGÐGà˜ÑØ˜ˆˆ9‰ð €Jð 	ˆ9‰×Ñ˜TÔ"à€Jr   c                 óz   ‡ ‡‡— d‰ j                   z   Št        «       Št        ‰ «      ˆˆ ˆfd„«       }t        |«      S )zÍProperty decorator that caches the value of potentially expensive
    ``propfunc`` after the first evaluation. The cached value is stored in
    the corresponding property name with an attached underscore.Ú_c                 óT   •— t        | ‰‰«      }|‰u r ‰| «      }t        | ‰|«       |S r   )ÚgetattrÚsetattr)r6   ÚvalÚattrnameÚpropfuncÚsentinels     €€€r   Úaccessorz"memoize_property.<locals>.accessorê   s2   ø€ ä�d˜H hÓ/ˆØ�(‰?Ù˜4“.ˆCÜ�D˜( CÔ(Øˆ
r   )r>   Úobjectr   Úproperty)rp   rr   ro   rq   s   ` @@r   Úmemoize_propertyru   ã   s?   ú€ ð �X×&Ñ&Ñ&€HÜ‹x€Hä
ˆ8ƒ_õó ðô �HÓÐr   é   )Ú
stacklevelc                ó$   ‡ ‡‡— ||dœŠˆˆ ˆfd„}|S )aš  
    Mark a function as deprecated.

    This decorator should be used if an entire function or class is
    deprecated. If only a certain functionality is deprecated, you should use
    :func:`~.warns_deprecated_sympy` directly. This decorator is just a
    convenience. There is no functional difference between using this
    decorator and calling ``warns_deprecated_sympy()`` at the top of the
    function.

    The decorator takes the same arguments as
    :func:`~.warns_deprecated_sympy`. See its
    documentation for details on what the keywords to this decorator do.

    See the :ref:`deprecation-policy` document for details on when and how
    things should be deprecated in SymPy.

    Examples
    ========

    >>> from sympy.utilities.decorator import deprecated
    >>> from sympy import simplify
    >>> @deprecated("""    ... The simplify_this(expr) function is deprecated. Use simplify(expr)
    ... instead.""", deprecated_since_version="1.1",
    ... active_deprecations_target='simplify-this-deprecation')
    ... def simplify_this(expr):
    ...     """
    ...     Simplify ``expr``.
    ...
    ...     .. deprecated:: 1.1
    ...
    ...        The ``simplify_this`` function is deprecated. Use :func:`simplify`
    ...        instead. See its documentation for more information. See
    ...        :ref:`simplify-this-deprecation` for details.
    ...
    ...     """
    ...     return simplify(expr)
    >>> from sympy.abc import x
    >>> simplify_this(x*(x + 1) - x**2) # doctest: +SKIP
    <stdin>:1: SymPyDeprecationWarning:
    <BLANKLINE>
    The simplify_this(expr) function is deprecated. Use simplify(expr)
    instead.
    <BLANKLINE>
    See https://docs.sympy.org/latest/explanation/active-deprecations.html#simplify-this-deprecation
    for details.
    <BLANKLINE>
    This has been deprecated since SymPy version 1.1. It
    will be removed in a future version of SymPy.
    <BLANKLINE>
      simplify_this(x)
    x

    See Also
    ========
    sympy.utilities.exceptions.SymPyDeprecationWarning
    sympy.utilities.exceptions.sympy_deprecation_warning
    sympy.utilities.exceptions.ignore_warnings
    sympy.testing.pytest.warns_deprecated_sympy

    )Údeprecated_since_versionÚactive_deprecations_targetc                 ó¢   •‡ — t        ‰ d«      r# G ˆˆˆˆ fd„d‰ «      }‰ j                  |_        |S t        ‰ «      ˆˆˆˆ fd„«       }‰ |_        |S )NÚ__mro__c                   ó–   •‡ — e Zd ZW °j                  ZW °j                  ZW °ZdW °j
                  v rˆ ˆˆˆfd„Zˆ xZS ˆ ˆˆˆfd„Zˆ xZS )ú9deprecated.<locals>.deprecated_decorator.<locals>.wrapperÚ__new__c                 óJ   •— t        ‰fi ‰¤d‰i¤Ž t        ‰| �  | g|¢­i |¤ŽS ©Nrw   )r   Úsuperr   )r5   r   r   r   Údecorator_kwargsÚmessagerw   s      €€€€r   r   zAdeprecated.<locals>.deprecated_decorator.<locals>.wrapper.__new__>  s0   ø€ Ü1°'ÑeÐ=MÑeÐZdÓeÜ$™w™¨sÐD°TÒD¸VÑDÐDr   c                 óD   •— t        ‰fi ‰¤d‰i¤Ž t        ‰| �  |i |¤Ž y r�   )r   r‚   r7   )r6   r   r   r   rƒ   r„   rw   s      €€€€r   r7   zBdeprecated.<locals>.deprecated_decorator.<locals>.wrapper.__init__B  s)   ø€ Ü1°'ÑeÐ=MÑeÐZdÓeÜ™Ñ(¨$Ð9°&Ó9r   )	r>   r?   r@   rA   Ú_sympy_deprecated_funcrc   r   r7   Ú__classcell__)r   rƒ   r„   rw   Úwrappeds   @€€€€r   Úwrapperr~   9  sA   ù„ Ù!Ÿ/™/�Ù$×/Ñ/�
Ù)0Ð&Ø¡× 0Ñ 0Ñ0÷Eó E÷:ó :r   r‰   c                  ó4   •— t        ‰fi ‰¤d‰i¤Ž  ‰| i |¤ŽS r�   r   )r   r   rƒ   r„   rw   rˆ   s     €€€€r   r‰   z9deprecated.<locals>.deprecated_decorator.<locals>.wrapperG  s'   ø€ ä)¨'Ñ]Ð5EÑ]ÐR\Ó]Ù Ð/¨Ñ/Ð/r   )r:   r>   r   r†   )rˆ   r‰   rƒ   r„   rw   s   ` €€€r   Údeprecated_decoratorz(deprecated.<locals>.deprecated_decorator7  s\   ù€ Ü�7˜IÔ&÷:ñ :˜'ô :ð  '×/Ñ/ˆGÔð ˆô �7‹^ö0ó ð0ð .5ˆGÔ*Øˆr   r   )r„   ry   rz   rw   r‹   rƒ   s   `  ` @r   Ú
deprecatedrŒ   õ   s#   ú€ ð@ 5MØ-GñIÐöð,  Ðr   )NNNNN)rA   rb   r^   rU   Ú	functoolsr   r   Úsympy.utilities.exceptionsr   r$   r(   r*   r1   r3   r[   rh   ru   rŒ   r   r   r   ú<module>r�      s[   ðÙ !ã 
Û Û ß +å @òò:(ò()ò(÷ ñ ð> @DØ9=ó1òh.òbð& 78õX r   