
    sh+                         S r SSKJr  SSKrSSKrSSKrSSKJrJr  SSK	J
r
  \" S5      r S rS rS	 rS
 r " S S5      r  SS jrS\S\4S jrS rSS.S jrg)zUseful utility decorators.     )TypeVarN)wrapsupdate_wrappersympy_deprecation_warningTc                 d   ^ ^^^^ SSK Jm  SSKJm  SSKJm  [        T 5      UU UUU4S j5       nU$ )z'A factory for ``threaded`` decorators. r   )sympify)
MatrixBase)iterablec           
      Z  >^^ [        U T5      (       a  U R                  UUU4S j5      $ T" U 5      (       a-   U R                  U  Vs/ s H  nT" U/TQ70 TD6PM     sn5      $ T" U 5      n T(       aE  U R                  (       a4  U R                  " U R
                   Vs/ s H  nT" U/TQ70 TD6PM     sn6 $ U R                  (       a:  U R                  T" U R                  /TQ70 TD6T" U R                  /TQ70 TD65      $ T" U /TQ70 TD6$ s  snf ! [         a    U s $ f = fs  snf )Nc                    > T" U /TQ70 TD6$ N )fargsfunckwargss    m/Users/tiagomarins/Projetos/claudeai/copy_bank/venv/lib/python3.13/site-packages/sympy/utilities/decorator.py<lambda>9threaded_factory.<locals>.threaded_func.<locals>.<lambda>   s    D,DT,DV,D    )	
isinstance	applyfunc	__class__	TypeErroris_Addr   is_Relationallhsrhs)	exprr   r   r   r   r   r   r
   use_adds	    `` r   threaded_func'threaded_factory.<locals>.threaded_func   s   dJ''>>"DEEd^^~~&NAtA'?'?'?&NOO 4=D4;;~~499'V9aa)A$)A&)A9'VWW##~~d488&Ed&Ef&E&*488&Ed&Ef&EG G D242622 'O  (Ws)   D 	DD  D(D 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 3& r   c                     [        U S5      $ )a-  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                     [        U S5      $ )a0  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.   A   s    " D%((r   c                 8   ^ ^ SSK mU U4S jn[        UT 5      nU$ )zsAfter the function finishes, resets the value of ``mpmath.mp.dps`` to
the value it had before the function was run.r   Nc                     > TR                   R                  n T" U 0 UD6UTR                   l        $ ! UTR                   l        f = fr   )mpdps)r   r   r2   r   mpmaths      r   func_wrapper)conserve_mpmath_dps.<locals>.func_wrapperZ   s9    iimm	 ((FIIMCFIIMs	   2 A)r3   r   )r   r4   r3   s   ` @r   conserve_mpmath_dpsr6   U   s!       ",5Lr   c                   (    \ rS rSrSrS rSS jrSrg)no_attrs_in_subclasse   a  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                     Xl         X l        g r   clsr   )selfr<   r   s      r   __init__no_attrs_in_subclass.__init__x   s    r   Nc                     X R                   :X  aB  [        U R                  S5      (       a  U R                  R                  X5      $ U R                  $ [        e)N__get__)r<   hasattrr   rA   AttributeError)r=   instanceowners      r   rA   no_attrs_in_subclass.__get__|   s?    HHtvvy))vv~~h6666Mr   r;   r   )__name__
__module____qualname____firstlineno____doc__r>   rA   __static_attributes__r   r   r   r8   r8   e   s    $r   r8   c                 x   ^^ 0 mU b  U TS'   Ub  UTS'   Ub  UTS'   Ub  UTS'   Ub  UTS'   U4S jmUU4S jnU$ )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                  x   > SSK Jn JnJn  U" 5       nU" US 5      n UR                  " S0 TD6  g! U  a     gf = f)Nr   )DependencyErrorSymPyDocTestsPyTestReporterFTr   )sympy.testing.runtestsrT   rU   rV   _check_dependencies)rT   rU   rV   rtdependenciess        r   	skiptests%doctest_depends_on.<locals>.skiptests   sL    YY!T"	!!1L1   		s   0 99c                    > TU l         TU l        [        R                  " U 5      (       a4  [	        X R                   5      U l        [	        X R                  5      U l        U $ r   )_doctest_depends_on__doctest_skip__inspectisclassr8   _doctest_depdends_on)fnr[   r\   s    r   depends_on_deco+doctest_depends_on.<locals>.depends_on_deco   sS    !-'??2&:**',B#"6''#)B	r   r   )exerO   rP   rQ   rR   re   r[   r\   s         @@r   doctest_depends_onrh      sm     L
&)]#")Y"*9&'!)7%&'3^$		 r   objreturnc                    [        U [        R                  5      (       a  U R                  nU R                  nOf[        U [        [
        5      [
        45      (       a4  [        R                  U R                     R                  nU R                  nO[        SU -  5      eSU;  a  U/US'   U $ US   R                  U5        U $ )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__rG   typesysrO   rH   __dict__r   append)ri   nsnames      r   publicrv      s    @ #u))**__||	C$t*d+	,	,[[(11||@3FGG9 J 	9T"Jr   c                 |   ^ ^^ ST R                   -   m[        5       m[        T 5      UU U4S j5       n[        U5      $ )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                 V   > [        U TT5      nUTL a  T" U 5      n[        U TU5        U$ r   )getattrsetattr)r=   valattrnamepropfuncsentinels     r   accessor"memoize_property.<locals>.accessor   s2    dHh/(?4.CD(C(
r   )rG   objectr   property)r~   r   r}   r   s   ` @@r   memoize_propertyr      s?     X&&&HxH
8_  Hr      )
stacklevelc                &   ^ ^^ UUS.mUU U4S jnU$ )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 S5      (       a$   " UUUU 4S jST 5      nT R                  Ul        U$ [        T 5      UUUU 4S j5       nT Ul        U$ )N__mro__c                      >^  \ rS rSr YR                  r YR                  r YrS YR                  ;   a  U UUU4S jrSr	U =r
$ U UUU4S jrSr	U =r
$ )9deprecated.<locals>.deprecated_decorator.<locals>.wrapperi?  __new__c                 L   > [        T40 TDST0D6  [        TU ]  " U /UQ70 UD6$ Nr   )r   superr   )r<   r   r   r   decorator_kwargsmessager   s      r   r   Adeprecated.<locals>.deprecated_decorator.<locals>.wrapper.__new__D  s0    1'e=MeZde$wsDTDVDDr   c                 F   > [        T40 TDST0D6  [        TU ]  " U0 UD6  g r   )r   r   r>   )r=   r   r   r   r   r   r   s      r   r>   Bdeprecated.<locals>.deprecated_decorator.<locals>.wrapper.__init__H  s)    1'e=MeZde($9&9r   r   )rG   rH   rI   rJ   rK   _sympy_deprecated_funcrr   r   r>   rL   __classcell__)r   r   r   r   wrappeds   @r   wrapperr   ?  sA    !//$//
)0& 0 00E E: :r   r   c                  4   > [        T40 TDST0D6  T" U 0 UD6$ r   r   )r   r   r   r   r   r   s     r   r   r   M  s'    )']5E]R\]///r   )rB   rG   r   r   )r   r   r   r   r   s   ` r   deprecated_decorator(deprecated.<locals>.deprecated_decorator=  s_    7I&&: :' :  '//G  7^0 0 .5G*r   r   )r   r   r   r   r   r   s   `  ` @r   
deprecatedr      s#    @ 5M-GI,  r   )NNNNN)rK   typingr   rq   rm   ra   	functoolsr   r   sympy.utilities.exceptionsr   r   r(   r,   r.   r6   r8   rh   rv   r   r   r   r   r   <module>r      sz    !  
   + @ CL :(()(  > @D9=1h. .a .b& 78X r   