Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
mixins.cpython-313.pyc104 linesDownload Raw Back to __pycache__
1�

2z�j���R�SrSSKJr S/rSrSrSrSrSr	S	r3"S4S5rg)zG5Mixin classes for custom array types that don't inherit from ndarray.6�)�umath�NDArrayOperatorsMixinc�@�URSL$![a gf=f)z)True when __array_ufunc__ is set to None.NF)�__array_ufunc__�AttributeError)�objs �VD:\code\apps\devtools\python\user_packages\Python313\site-packages\numpy/lib/mixins.py�_disables_array_ufuncr7	s*����"�"�d�*�*������s�
�8�c�*^�U4SjnSUS3UlU$)z>Implement a forward binary method with a ufunc, e.g., __add__.c�@>�[U5(a[$T"X5$�N�r9�NotImplemented��self�other�ufuncs  �r	�func�_binary_method.<locals>.funcs��� ��'�'�!�!��T�!�!��__��__name__�r�namers`  r	�_binary_methodrs���"����b�M�D�M��Krc�*^�U4SjnSUS3UlU$)zAImplement a reflected binary method with a ufunc, e.g., __radd__.c�@>�[U5(a[$T"X5$r
rrs  �r	r�&_reflected_binary_method.<locals>.funcs��� ��'�'�!�!��U�!�!r�__rrrrs`  r	�_reflected_binary_methodr!s���"��$��r�N�D�M��Krc�*^�U4SjnSUS3UlU$)zAImplement an in-place binary method with a ufunc, e.g., __iadd__.c�>�T"XU4S9$)N)�out�rs  �r	r�$_inplace_binary_method.<locals>.func's����T�t�g�.�.r�__irrrs`  r	�_inplace_binary_methodr(%s���/��$��r�N�D�M��Krc�B�[X5[X5[X54$)zEImplement forward, reflected and inplace binary methods with a ufunc.)rr!r()rrs  r	�_numeric_methodsr*-s$���5�'�$�U�1�"�5�/�1�1rc�*^�U4SjnSUS3UlU$)z.Implement a unary special method with a ufunc.c�>�T"U5$r
r%)rrs �r	r�_unary_method.<locals>.func6s
����T�{�rrrrs`  r	�
_unary_methodr.4s�������b�M�D�M��Krc�:�\rSrSrSrSr\"\RS5r	\"\RS5r\"\RS5r
\"\RS5r\"\R S5r\"\R$S	5r\"\R*S105urrr\"\R2S5urrr\"\R:S5urrr \"\RBS
5ur"r#r$\"\RJS5ur&r'r(\"\RRS5ur*r+r,\"\RZS5ur.r/r0\"\RbS5r2\3"\RbS5r4\"\RjS5ur6r7r8\"\RrS5ur:r;r<\"\RzS5ur>r?r@\"\R�S5urBrCrD\"\R�S5urFrGrH\"\R�S5urJrKrL\M"\R�S5rO\M"\R�S5rQ\M"\R�S5rS\M"\R�S5rUSrVg)r�<a�Mixin defining all operator special methods using __array_ufunc__.11 12This class implements the special methods for almost all of Python's13builtin operators defined in the `operator` module, including comparisons14(``==``, ``>``, etc.) and arithmetic (``+``, ``*``, ``-``, etc.), by15deferring to the ``__array_ufunc__`` method, which subclasses must16implement.17 18It is useful for writing classes that do not inherit from `numpy.ndarray`,19but that should support arithmetic and numpy universal functions like20arrays as described in :external+neps:doc:`nep-0013-ufunc-overrides`.21 22As a trivial example, consider this implementation of an ``ArrayLike``23class that simply wraps a NumPy array and ensures that the result of any24arithmetic operation is also an ``ArrayLike`` object:25 26    >>> import numbers27    >>> class ArrayLike(np.lib.mixins.NDArrayOperatorsMixin):28    ...     def __init__(self, value):29    ...         self.value = np.asarray(value)30    ...31    ...     # One might also consider adding the built-in list type to this32    ...     # list, to support operations like np.add(array_like, list)33    ...     _HANDLED_TYPES = (np.ndarray, numbers.Number)34    ...35    ...     def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):36    ...         out = kwargs.get('out', ())37    ...         for x in inputs + out:38    ...             # Only support operations with instances of39    ...             # _HANDLED_TYPES. Use ArrayLike instead of type(self)40    ...             # for isinstance to allow subclasses that don't41    ...             # override __array_ufunc__ to handle ArrayLike objects.42    ...             if not isinstance(43    ...                 x, self._HANDLED_TYPES + (ArrayLike,)44    ...             ):45    ...                 return NotImplemented46    ...47    ...         # Defer to the implementation of the ufunc48    ...         # on unwrapped values.49    ...         inputs = tuple(x.value if isinstance(x, ArrayLike) else x50    ...                     for x in inputs)51    ...         if out:52    ...             kwargs['out'] = tuple(53    ...                 x.value if isinstance(x, ArrayLike) else x54    ...                 for x in out)55    ...         result = getattr(ufunc, method)(*inputs, **kwargs)56    ...57    ...         if type(result) is tuple:58    ...             # multiple return values59    ...             return tuple(type(self)(x) for x in result)60    ...         elif method == 'at':61    ...             # no return value62    ...             return None63    ...         else:64    ...             # one return value65    ...             return type(self)(result)66    ...67    ...     def __repr__(self):68    ...         return '%s(%r)' % (type(self).__name__, self.value)69 70In interactions between ``ArrayLike`` objects and numbers or numpy arrays,71the result is always another ``ArrayLike``:72 73    >>> x = ArrayLike([1, 2, 3])74    >>> x - 175    ArrayLike(array([0, 1, 2]))76    >>> 1 - x77    ArrayLike(array([ 0, -1, -2]))78    >>> np.arange(3) - x79    ArrayLike(array([-1, -1, -1]))80    >>> x - np.arange(3)81    ArrayLike(array([1, 1, 1]))82 83Note that unlike ``numpy.ndarray``, ``ArrayLike`` does not allow operations84with arbitrary, unrecognized types. This ensures that interactions with85ArrayLike preserve a well-defined casting hierarchy.86 87r%�lt�le�eq�ne�gt�ge�add�sub�mul�matmul�truediv�floordiv�mod�divmod�pow�lshift�rshift�and�xor�or�neg�pos�abs�invertN)Wr�88__module__�__qualname__�__firstlineno__�__doc__�	__slots__r�um�less�__lt__�89less_equal�__le__�equal�__eq__�	not_equal�__ne__�greater�__gt__�
greater_equal�__ge__r*r7�__add__�__radd__�__iadd__�subtract�__sub__�__rsub__�__isub__�multiply�__mul__�__rmul__�__imul__r:�90__matmul__�__rmatmul__�__imatmul__�true_divide�__truediv__�__rtruediv__�__itruediv__�floor_divide�__floordiv__�
__rfloordiv__�
__ifloordiv__�	remainder�__mod__�__rmod__�__imod__r>�91__divmod__r!�__rdivmod__�power�__pow__�__rpow__�__ipow__�92left_shift�93__lshift__�__rlshift__�__ilshift__�right_shift�94__rshift__�__rrshift__�__irshift__�bitwise_and�__and__�__rand__�__iand__�bitwise_xor�__xor__�__rxor__�__ixor__�95bitwise_or�__or__�__ror__�__ior__r.�negative�__neg__�positive�__pos__�absolute�__abs__rH�96__invert__�__static_attributes__r%rr	rr<s��M�^�I�97�B�G�G�T�
*�F�
�B�M�M�4�
0�F�
�B�H�H�d�
+�F�
�B�L�L�$�
/�F�
�B�J�J��
-�F�
�B�,�,�d�
3�F�#3�2�6�6�5�"A��G�X�x�"2�2�;�;��"F��G�X�x�"2�2�;�;��"F��G�X�x�+;�98�	�	�8�,�(�J��[�.>�99���	�/#�+�K��|�1A�100����2%�.�L�-��"2�2�<�<��"G��G�X�x���	�	�8�4�J�*�2�9�9�h�?�K�#3�2�8�8�U�"C��G�X�x�+;�101�
�
�x�,!�(�J��[�+;�102����,"�(�J��[�"2�2�>�>�5�"I��G�X�x�"2�2�>�>�5�"I��G�X�x�/��
�
�t�D��F�G�W��B�K�K��/�G��B�K�K��/�G��B�K�K��/�G��r�y�y�(�3�JrN)rL�numpy._corerrN�__all__r103rr!r(r*r.rr%rr	�<module>r�sA���$�"�104#������1��x4�x4r
codekingpro/portable-devtools · Team Ai