
    Qi+                         d Z ddlm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
  ed          Z	 d Zd Zd	 Zd
 Z G d d          Z	 	 ddZdedefdZd ZdddZdS )zUseful utility decorators.     )TypeVarN)wrapsupdate_wrappersympy_deprecation_warningTc                 p     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|                     fd          S  |           r6	 |                     fd| D                       S # t          $ r | cY S w xY w |           } r$| j        r | j        fd| j        D              S | j        r4|                      | j        gR i  | j        gR i           S  | gR i S )Nc                      | gR i S N )fargsfunckwargss    q/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/sympy/utilities/decorator.py<lambda>z9threaded_factory.<locals>.threaded_func.<locals>.<lambda>   s!    DD,DT,D,D,DV,D,D     c                 (    g | ]} |gR i S r   r   .0r   r   r   r   s     r   
<listcomp>z;threaded_factory.<locals>.threaded_func.<locals>.<listcomp>   s3    &N&N&NAttA'?'?'?'?'?'?&N&N&Nr   c                 (    g | ]} |gR i S r   r   r   s     r   r   z;threaded_factory.<locals>.threaded_func.<locals>.<listcomp>#   s3    'V'V'Vaa)A$)A)A)A&)A)A'V'V'Vr   )	
isinstance	applyfunc	__class__	TypeErroris_Addr   is_Relationallhsrhs)exprr   r   r   r   r   r
   use_adds    ``r   threaded_funcz'threaded_factory.<locals>.threaded_func   sn   dJ'' 	3>>"D"D"D"D"D"DEEEXd^^ 	3~~&N&N&N&N&N&N&N&N&NOOO    74==D 34; 3%t~'V'V'V'V'V'V49'V'V'VWW# 3~~dd48&Ed&E&E&Ef&E&E&*d48&Ed&E&E&Ef&E&EG G G tD242226222s   "A A,+A,)
sympy.corer
   sympy.matricesr   sympy.utilities.iterablesr   r   )r   r&   r'   r   r   r
   s   `` @@@r   threaded_factoryr+      s    """"""))))))222222
4[[3 3 3 3 3 3 3 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   	xthreadedr1   A   s    " D%(((r   c                 >     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                  h    j         j        }	  | i ||j         _        S # |j         _        w xY wr   )mpdps)r   r   r5   r   mpmaths      r   func_wrapperz)conserve_mpmath_dps.<locals>.func_wrapperZ   sC    im	 4(((FIMMCFIMs   # 1)r6   r   )r   r7   r6   s   ` @r   conserve_mpmath_dpsr8   U   sD     MMM            ",55Lr   c                        e Zd ZdZd ZddZdS )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                 "    || _         || _        d S r   )clsr   )selfr<   r   s      r   __init__zno_attrs_in_subclass.__init__x   s    r   Nc                     || j         k    r7t          | j        d          r| j                            ||          S | j        S t          )N__get__)r<   hasattrr   r@   AttributeError)r=   instanceowners      r   r@   zno_attrs_in_subclass.__get__|   sF    DHtvy)) 7v~~h6666Mr   r   )__name__
__module____qualname____doc__r>   r@   r   r   r   r:   r:   e   sA         $       r   r:   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)``)
    Nexecutablesmodulesdisable_viewerspython_versionground_typesc                  |    ddl m} m}m}  |            } ||d           }	  |j        di  dS # | $ r Y dS w xY w)Nr   )DependencyErrorSymPyDocTestsPyTestReporterFTr   )sympy.testing.runtestsrP   rQ   rR   _check_dependencies)rP   rQ   rR   rtdependenciess        r   	skiptestsz%doctest_depends_on.<locals>.skiptests   s    YYYYYYYYYYNM!T""	!A!11L111 5  	 	 	44	s   2 ;;c                     | _         | _        t          j        |           r4t	          | | j                   | _        t	          | | j                  | _        | S r   )_doctest_depends_on__doctest_skip__inspectisclassr:   _doctest_depdends_on)fnrW   rX   s    r   depends_on_decoz+doctest_depends_on.<locals>.depends_on_deco   s^    !-'?2 	)&:B*', ',B#"6B'#) #)B	r   r   )exerK   rL   rM   rN   r`   rW   rX   s         @@r   doctest_depends_onrb      s     L
&)]#")Y"*9&'!)7%&'3^$	 	 	 	 		 	 	 	 	 	 r   objreturnc                 b   t          | t          j                  r| j        }| j        }n_t          | t          t
                    t
          f          r$t          j        | j                 j	        }| j        }nt          d| z            d|vr|g|d<   n|d                             |           | 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__rE   typesysrK   rF   __dict__r    append)rc   nsnames      r   publicrp      s    @ #u)** H_|	C$t**d+	,	, H[(1|@3FGGG9
9T"""Jr   c                      d j         z   t                      t                      fd            }t          |          S )zProperty 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                 j    t          |           }|u r |           }t          | |           |S r   )getattrsetattr)r=   valattrnamepropfuncsentinels     r   accessorz"memoize_property.<locals>.accessor   sA    dHh//(??(4..CD(C(((
r   )rE   objectr   property)rx   rz   rw   ry   s   ` @@r   memoize_propertyr}      s`     X&&HxxH
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        |_        n$t                      fd            } |_        |S )N__mro__c                   p     e Zd Zj        Zj        ZZdj        v r fdZ xZS  fdZ xZS )9deprecated.<locals>.deprecated_decorator.<locals>.wrapper__new__c                 `    t          fi di  t                      j        | g|R i |S Nr   )r   superr   )r<   r   r   r   decorator_kwargsmessager   s      r   r   zAdeprecated.<locals>.deprecated_decorator.<locals>.wrapper.__new__D  sL    1'ee=MeeZdeeee.uwwsDTDDDVDDDr   c                 \    t          fi di  t                      j        |i | d S r   )r   r   r>   )r=   r   r   r   r   r   r   s      r   r>   zBdeprecated.<locals>.deprecated_decorator.<locals>.wrapper.__init__H  sH    1'ee=MeeZdeeee(($9&99999r   )	rE   rF   rG   rH   _sympy_deprecated_funcrl   r   r>   __classcell__)r   r   r   r   wrappeds   @r   wrapperr   ?  s        !/$/
)0& 000E E E E E E E E E E E E: : : : : : : : : : : :r   r   c                  6    t          fi di  | i |S r   r   )r   r   r   r   r   r   s     r   r   z9deprecated.<locals>.deprecated_decorator.<locals>.wrapperM  s;    )']]5E]]R\]]]]w////r   )rA   rE   r   r   )r   r   r   r   r   s   ` r   deprecated_decoratorz(deprecated.<locals>.deprecated_decorator=  s    7I&& 	5: : : : : : : : : :' : : :  '/G7^^0 0 0 0 0 0 0 ^0 .5G*r   r   )r   r   r   r   r   r   s   `  ` @r   
deprecatedr      sI    @ 5M-GI I      ,  r   )NNNNN)rH   typingr   rk   rg   r\   	functoolsr   r   sympy.utilities.exceptionsr   r   r+   r/   r1   r8   r:   rb   rp   r}   r   r   r   r   <module>r      sX   ! !       



   + + + + + + + + @ @ @ @ @ @ GCLL   :( ( (() ) )(          > @D9=1 1 1 1h. .a . . . .b  & 78X  X  X  X  X  X  X r   