
    Icg                        d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	m
Z
mZmZmZmZmZmZmZ ddlmZmZmZmZmZmZ ddlZerdd	lmZmZmZmZ ddlmZ ddl Z!dd
l m"Z"  G d d      Z#y)al  
Wrapper class around the ndarray object for the array API standard.

The array API standard defines some behaviors differently than ndarray, in
particular, type promotion rules are different (the standard has no
value-based casting). The standard also specifies a more limited subset of
array methods and functionalities than are implemented on ndarray. Since the
goal of the array_api namespace is to be a minimal implementation of the array
API standard, we need to define a separate wrapper class for the array_api
namespace.

The standard compliant class is only a wrapper class. It is *not* a subclass
of ndarray.
    )annotationsN)IntEnum   )asarray)	_all_dtypes_boolean_dtypes_integer_dtypes_integer_or_boolean_dtypes_floating_dtypes_complex_floating_dtypes_numeric_dtypes_result_type_dtype_categories)TYPE_CHECKINGOptionalTupleUnionAnySupportsIndex)r   	PyCapsuleDeviceDtype)	array_apic                      e Zd ZU dZded<   e fd       Zd ZdSdZdSdZ	dTdUd	Z
dVd
Zd ZedWd       Zd ZdXdZdYdZdZdZdd	 	 	 	 	 d[dZd\dZd]dZddd^dZd_dZd`dZdadZdYdZdYdZ	 	 	 	 	 	 dbdZdYdZdcdZdcdZdXd Z dYd!Z!ddd"Z"dYd#Z#ded$Z$dYd%Z%dYd&Z&d`d'Z'dXd(Z(dZd)Z)dXd*Z*dYd+Z+ddd,Z,	 	 	 	 	 	 dfd-Z-dYd.Z.dgd/Z/dZd0Z0dYd1Z1dYd2Z2dZd3Z3dZd4Z4dYd5Z5dYd6Z6ddd7Z7ddd8Z8ded9Z9ded:Z:dYd;Z;dYd<Z<dYd=Z=dYd>Z>dZd?Z?dZd@Z@dYdAZAdYdBZBdddCZCdddDZDdYdEZEdYdFZFdgdGZGdgdHZHdZdIZIdZdJZJdTdhdKZKeLdidL       ZMeLdjdM       ZNeLdkdN       ZOeLdldO       ZPeLdmdP       ZQeLdldQ       ZReLdkdR       ZS xZTS )nArraya)  
    n-d array object for the array API namespace.

    See the docstring of :py:obj:`np.ndarray <numpy.ndarray>` for more
    information.

    This is a wrapper around numpy.ndarray that restricts the usage to only
    those things that are required by the array API namespace. Note,
    attributes on this object that start with a single underscore are not part
    of the API specification and should only be used internally. This object
    should not be constructed directly. Rather, use one of the creation
    functions, such as asarray().

    znp.ndarray[Any, Any]_arrayc                   t         |   |       }t        |t        j                        rt        j
                  |      }|j                  t        vrt        d|j                   d      ||_	        |S )a  
        This is a private method for initializing the array API Array
        object.

        Functions outside of the array_api submodule should not use this
        method. Use one of the creation functions instead, such as
        ``asarray``.

        z4The array_api namespace does not support the dtype '')
super__new__
isinstancenpgenericr   dtyper   	TypeErrorr   )clsxobj	__class__s      X/var/www/html/bid-api/venv/lib/python3.12/site-packages/numpy/array_api/_array_object.py_newz
Array._new@   se     goc"a$

1A77+%FqwwiqQ  

    c                    t        d      )Nz{The array_api Array object should not be instantiated directly. Use an array creation function, such as asarray(), instead.)r%   )r&   argskwargss      r*   r    zArray.__new__X   s     J
 	
r,   c               V    | j                   j                         j                  dd      S )z1
        Performs the operation __str__.
        arrayr   )r   __str__replaceselfs    r*   r2   zArray.__str__`   s$     {{""$,,Wg>>r,   c                   d| j                   j                   d}d| j                  v rd}t        | j                        }n%d}t	        j
                  | j                  d||      }||z   |z   S )z2
        Performs the operation __repr__.
        z, dtype=)r   zempty(zArray(z, )	separatorprefixsuffix)r$   nameshapestrr"   array2stringr   )r5   r:   r9   mids       r*   __repr__zArray.__repr__f   se     DJJOO,A.

?Fdjj/CF//$++fU[\C|f$$r,   Nc                D    t        j                  | j                  |      S )z
        Warning: this method is NOT part of the array API spec. Implementers
        of other libraries need not include it, and users should not assume it
        will be present in other implementations.

        )r$   )r"   r   r   )r5   r$   s     r*   	__array__zArray.__array__u   s     zz$++U33r,   c                   | j                   t        |   vrt        d| d|       t        |t        t
        t        t        f      r| j                  |      }n<t        |t              r&|j                   t        |   vrt        d| d|       t        S t        | j                   |j                         }|j                  d      r7|| j                   k7  r(t        d| d| j                    d|j                          |S )z
        Helper function for operators to only allow specific input dtypes

        Use like

            other = self._check_allowed_dtypes(other, 'numeric', '__add__')
            if other is NotImplemented:
                return other
        zOnly z dtypes are allowed in __izCannot perform z with dtypes  and )r$   r   r%   r!   intcomplexfloatbool_promote_scalarr   NotImplementedr   
startswith)r5   otherdtype_categoryop	res_dtypes        r*   _check_allowed_dtypeszArray._check_allowed_dtypes   s     ::.~>>eN#33J2$OPPec7E489((/Eu%{{"3N"CC%'77Nrd STT!!
 !U[[9	== DJJ&%bTtzzl%}U  r,   c                   t        |t              r| j                  t        vrt	        d      t        |t
              r| j                  t        v rt	        d      | j                  t        v rt        j                  | j                        }|j                  |cxk  r|j                  k  s|t        d       t        d      t        |t              r| j                  t        vrCt	        d      t        |t              r| j                  t        vrt	        d      t	        d      t         j#                  t        j$                  || j                              S )aR  
        Returns a promoted version of a Python scalar appropriate for use with
        operations on self.

        This may raise an OverflowError in cases where the scalar is an
        integer that is too large to fit in a NumPy integer dtype, or
        TypeError when the scalar type is incompatible with the dtype of self.
        z9Python bool scalars can only be promoted with bool arraysz6Python int scalars cannot be promoted with bool arrayszLPython int scalars must be within the bounds of the dtype for integer arrayszEPython float scalars can only be promoted with floating-point arrays.zOPython complex scalars can only be promoted with complex floating-point arrays.z 'scalar' must be a Python scalar)r!   rI   r$   r   r%   rF   r	   r"   iinfominmaxOverflowErrorrH   r   rG   r   r   r+   r1   )r5   scalarinfos      r*   rJ   zArray._promote_scalar   s,    fd#zz0O  $zz_,L  zz_,xx

+F6dhh6'f  7'f  &zz!11[  (zz!99e  >?? zz"((64::677r,   c                   | j                   dk(  r5|j                   dk7  r&t        j                  | j                  d         } | |fS |j                   dk(  r1| j                   dk7  r"t        j                  |j                  d         }| |fS )a  
        Normalize inputs to two arg functions to fix type promotion rules

        NumPy deviates from the spec type promotion rules in cases where one
        argument is 0-dimensional and the other is not. For example:

        >>> import numpy as np
        >>> a = np.array([1.0], dtype=np.float32)
        >>> b = np.array(1.0, dtype=np.float64)
        >>> np.add(a, b) # The spec says this should be float64
        array([2.], dtype=float32)

        To fix this, we add a dimension to the 0-dimension array before passing it
        through. This works because a dimension would be added anyway from
        broadcasting, so the resulting shape is the same, but this prevents NumPy
        from not promoting the dtype.
        r   N)ndimr   r+   r   )x1x2s     r*   _normalize_two_argszArray._normalize_two_args   sr    2 77a<BGGqL
 BIIdO,B Bx WW\bgglBIIdO,BBxr,   c                |   t        |t              r|n|f}|D ]  }t        |t              s[t        |t              r$t        |t              r5|t
        k(  r?|Bt        |t              rSt        |t        j                        rnt        d| dt        |      d       g }g }d}d}|D ]  }||j                  |       t        |t              st        |t        j                        r&|j                  t        v rd}|j                  |       g|t
        k(  r|dz  }v|j                  |        t        |      }|dkD  ry|dk(  r-|s+|| j                  k  rt        d	| j                  d
| d      |dk(  r| j                   }	nd}
t#        |      D ]>  \  }}t        |t              rt        |t        j                        r2|t
        k(  s<|}
 n |
J | j                  ||
z
  z
  }| j                   d|
 | j                   |d z   }	t%        ||	      D ]  \  }}t        |t              r|dk(  rd}nd| d|dz
   d}|j&                  F	 t)        j*                  |j&                        }| |cxk  r|k  sn t        d| d|d| d| d	      |j.                  	 t)        j*                  |j.                        }| |cxk  r|k  rn t        d| d|d| d| d	      t        |t              r|j                  t        v r;t        |      dk7  r-t        |t              sJ t        d| dt        |      d      |j                  t0        v sB|j                  dk7  sSt        d| d      t        |t              stt        d| d       y# t,        $ r Y w xY w# t,        $ r Y w xY w)a  
        Validate an index according to the array API.

        The array API specification only requires a subset of indices that are
        supported by NumPy. This function will reject any index that is
        allowed by NumPy but not required by the array API specification. We
        always raise ``IndexError`` on such indices (the spec does not require
        any specific behavior on them, but this makes the NumPy array API
        namespace a minimal implementation of the spec). See
        https://data-apis.org/array-api/latest/API_specification/indexing.html
        for the full list of required indexing behavior

        This function raises IndexError if the index ``key`` is invalid. It
        only raises ``IndexError`` on indices that are not already rejected by
        NumPy, as NumPy will already raise the appropriate error on such
        indices. ``shape`` may be None, in which case, only cases that are
        independent of the array shape are checked.

        The following cases are allowed by NumPy, but not specified by the array
        API specification:

        - Indices to not include an implicit ellipsis at the end. That is,
          every axis of an array must be explicitly indexed or an ellipsis
          included. This behaviour is sometimes referred to as flat indexing.

        - The start and stop of a slice may not be out of bounds. In
          particular, for a slice ``i:j:k`` on an axis of size ``n``, only the
          following are allowed:

          - ``i`` or ``j`` omitted (``None``).
          - ``-n <= i <= max(0, n - 1)``.
          - For ``k > 0`` or ``k`` omitted (``None``), ``-n <= j <= n``.
          - For ``k < 0``, ``-n - 1 <= j <= max(0, n - 1)``.

        - Boolean array indices are not allowed as part of a larger tuple
          index.

        - Integer array indices are not allowed (with the exception of 0-D
          arrays, which are treated the same as scalars).

        Additionally, it should be noted that indices that would return a
        scalar in NumPy will return a 0-D array. Array scalars are not allowed
        in the specification, only 0-D arrays. This is done in the
        ``Array._new`` constructor, not this function.

        NzSingle-axes index z has type(i)=z, but only integers, slices (:), ellipsis (...), newaxis (None), zero-dimensional integer arrays and boolean arrays are specified in the Array API.r   FTr   z
self.ndim=z*, but the multi-axes index only specifies z dimensions. If this was intentional, add a trailing ellipsis (...) which expands into as many slices (:) as necessary - this is what np.ndarray arrays implicitly do, but such flat indexing behaviour is not specified in the Array API.z0 (or None)z	between -rE   z
 (or None)zSlice z contains start=z, but should be z for an axis of size z: (out-of-bounds starts are not specified in the Array API)z contains stop=z9 (out-of-bounds stops are not specified in the Array API)z! is a boolean array and len(key)=zR, but masking is only specified in the Array API when the array is the sole index.zj is a non-zero-dimensional integer array, but advanced integer indexing is not specified in the Array API.zI is a tuple, but nested tuple indices are not specified in the Array API.)r!   tuplerI   r   sliceEllipsisr   r"   ndarray
IndexErrortypeappendr$   r   lenrZ   r<   	enumeratezipstartoperatorindexr%   stopr	   )r5   key_keyinonexpanding_keysingle_axes
n_ellipsiskey_has_maskn_single_axesindexed_shapeellipsis_startposellipsis_endsidef_rangeri   rl   s                    r*   _validate_indexzArray._validate_index  s    ^ !e,s3&A!T"1m,a'=9a'a, (>a
 ;6 6    
A} ''*a':a+Dww/1'+&&q) H}"a
#**1-  K(>1_  MDII$= !tyyl"L$o &22  ? JJM!N#$45Q"1e,
1bjj0IH}),	 6
 "---99(FGL

?N+djj.GG  ;6GAt!U#19+G )$uTAXJjIG77& (qww 7 "& 6$ 6","(+<eX=M#*)+@ G1!1#  66%'~~aff5 "& 5 5","(+;dW<L#*)+@ G1!1#  Au%77o-#d)q.%c5111$,QC 0%s8+ &FF 
 WW/AFFaK$,QC 06 6 
 Au% ( ,B B _ 7 %  % s$   N$N.	N+*N+.	N;:N;c                   | j                   t        vrt        d      | j                  j	                         }| j
                  j                  |      S )z1
        Performs the operation __abs__.
        z*Only numeric dtypes are allowed in __abs__)r$   r   r%   r   __abs__r)   r+   r5   ress     r*   r}   zArray.__abs__  C     ::_,HIIkk!!#~~""3''r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z1
        Performs the operation __add__.
        numeric__add__)rQ   rK   r]   r   r   r)   r+   r5   rM   r   s      r*   r   zArray.__add__  h     **5)YGN"L..tU;ekk!!%,,/~~""3''r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z1
        Performs the operation __and__.
        integer or boolean__and__)rQ   rK   r]   r   r   r)   r+   r   s      r*   r   zArray.__and__  i     **52F	RN"L..tU;ekk!!%,,/~~""3''r,   )api_versionc              P    ||j                  d      st        d|      t        S )Nz2021.z Unrecognized array API version: )rL   
ValueErrorr   )r5   r   s     r*   __array_namespace__zArray.__array_namespace__  s0     ";+A+A'+J?OPPr,   c                   | j                   j                  dk7  rt        d      | j                   j                         }|S )z2
        Performs the operation __bool__.
        r   z0bool is only allowed on arrays with 0 dimensions)r   rZ   r%   __bool__r~   s     r*   r   zArray.__bool__  s9    
 ;;q NOOkk""$
r,   c                   | j                   j                  dk7  rt        d      | j                   j                         }|S )z5
        Performs the operation __complex__.
        r   z3complex is only allowed on arrays with 0 dimensions)r   rZ   r%   __complex__r~   s     r*   r   zArray.__complex__  s9    
 ;;q QRRkk%%'
r,   streamc              :    | j                   j                  |      S )z4
        Performs the operation __dlpack__.
        r   )r   
__dlpack__)r5   r   s     r*   r   zArray.__dlpack__  s     {{%%V%44r,   c               6    | j                   j                         S )z;
        Performs the operation __dlpack_device__.
        )r   __dlpack_device__r4   s    r*   r   zArray.__dlpack_device__  s    
 {{,,..r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z0
        Performs the operation __eq__.
        all__eq__)rQ   rK   r]   r   r   r)   r+   r   s      r*   r   zArray.__eq__  sh     **5%BN"L..tU;ekk  .~~""3''r,   c                   | j                   j                  dk7  rt        d      | j                  t        v rt        d      | j                   j                         }|S )z3
        Performs the operation __float__.
        r   z1float is only allowed on arrays with 0 dimensionsz5float is not allowed on complex floating-point arrays)r   rZ   r%   r$   r   	__float__r~   s     r*   r   zArray.__float__  sR    
 ;;q OPP::11STTkk##%
r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z6
        Performs the operation __floordiv__.
        real numeric__floordiv__)rQ   rK   r]   r   r   r)   r+   r   s      r*   r   zArray.__floordiv__	  sh     **5..QN"L..tU;ekk&&u||4~~""3''r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z0
        Performs the operation __ge__.
        r   __ge__)rQ   rK   r]   r   r   r)   r+   r   s      r*   r   zArray.__ge__  h     **5.(KN"L..tU;ekk  .~~""3''r,   c                   | j                  |       t        |t              r|j                  }| j                  j	                  |      }| j                  |      S )z5
        Performs the operation __getitem__.
        )r{   r!   r   r   __getitem__r+   )r5   rm   r   s      r*   r   zArray.__getitem__  sG      	S!c5!**Ckk%%c*yy~r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z0
        Performs the operation __gt__.
        r   __gt__)rQ   rK   r]   r   r   r)   r+   r   s      r*   r   zArray.__gt__6  r   r,   c                   | j                   j                  dk7  rt        d      | j                  t        v rt        d      | j                   j                         }|S )z1
        Performs the operation __int__.
        r   z/int is only allowed on arrays with 0 dimensionsz3int is not allowed on complex floating-point arrays)r   rZ   r%   r$   r   __int__r~   s     r*   r   zArray.__int__A  sR    
 ;;q MNN::11QRRkk!!#
r,   c               :    | j                   j                         }|S )z3
        Performs the operation __index__.
        )r   	__index__r~   s     r*   r   zArray.__index__M  s     kk##%
r,   c                   | j                   t        vrt        d      | j                  j	                         }| j
                  j                  |      S )z4
        Performs the operation __invert__.
        z8Only integer or boolean dtypes are allowed in __invert__)r$   r
   r%   r   
__invert__r)   r+   r~   s     r*   r   zArray.__invert__T  sD     ::77VWWkk$$&~~""3''r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z0
        Performs the operation __le__.
        r   __le__)rQ   rK   r]   r   r   r)   r+   r   s      r*   r   zArray.__le__]  r   r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z4
        Performs the operation __lshift__.
        integer
__lshift__)rQ   rK   r]   r   r   r)   r+   r   s      r*   r   zArray.__lshift__h  h     **5)\JN"L..tU;ekk$$U\\2~~""3''r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z0
        Performs the operation __lt__.
        r   __lt__)rQ   rK   r]   r   r   r)   r+   r   s      r*   r   zArray.__lt__s  r   r,   c                   | j                  |dd      }|t        u r|S | j                  j                  |j                        }| j                  j                  |      S )z4
        Performs the operation __matmul__.
        r   
__matmul__)rQ   rK   r   r   r)   r+   r   s      r*   r   zArray.__matmul__~  sR     **5)\JN"Lkk$$U\\2~~""3''r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z1
        Performs the operation __mod__.
        r   __mod__)rQ   rK   r]   r   r   r)   r+   r   s      r*   r   zArray.__mod__  sh     **5.)LN"L..tU;ekk!!%,,/~~""3''r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z1
        Performs the operation __mul__.
        r   __mul__)rQ   rK   r]   r   r   r)   r+   r   s      r*   r   zArray.__mul__  r   r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z0
        Performs the operation __ne__.
        r   __ne__)rQ   rK   r]   r   r   r)   r+   r   s      r*   r   zArray.__ne__  sh     **5%BN"L..tU;ekk  .~~""3''r,   c                   | j                   t        vrt        d      | j                  j	                         }| j
                  j                  |      S )z1
        Performs the operation __neg__.
        z*Only numeric dtypes are allowed in __neg__)r$   r   r%   r   __neg__r)   r+   r~   s     r*   r   zArray.__neg__  r   r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z0
        Performs the operation __or__.
        r   __or__)rQ   rK   r]   r   r   r)   r+   r   s      r*   r   zArray.__or__  si     **52FQN"L..tU;ekk  .~~""3''r,   c                   | j                   t        vrt        d      | j                  j	                         }| j
                  j                  |      S )z1
        Performs the operation __pos__.
        z*Only numeric dtypes are allowed in __pos__)r$   r   r%   r   __pos__r)   r+   r~   s     r*   r   zArray.__pos__  r   r,   c               Z    ddl m} | j                  |dd      }|t        u r|S  || |      S )z1
        Performs the operation __pow__.
        r   powr   __pow___elementwise_functionsr   rQ   rK   r5   rM   r   s      r*   r   zArray.__pow__  s7     	0**5)YGN"L 4r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z4
        Performs the operation __rshift__.
        r   
__rshift__)rQ   rK   r]   r   r   r)   r+   r   s      r*   r   zArray.__rshift__  r   r,   c                   | j                  |       t        |t              r|j                  }| j                  j	                  |t        |      j                         y)z5
        Performs the operation __setitem__.
        N)r{   r!   r   r   __setitem__r   )r5   rm   values      r*   r   zArray.__setitem__  sC     	S!c5!**CWU^%:%:;r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z1
        Performs the operation __sub__.
        r   __sub__)rQ   rK   r]   r   r   r)   r+   r   s      r*   r   zArray.__sub__  r   r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z5
        Performs the operation __truediv__.
        floating-point__truediv__)rQ   rK   r]   r   r   r)   r+   r   s      r*   r   zArray.__truediv__   si     **52BMRN"L..tU;ekk%%ell3~~""3''r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z1
        Performs the operation __xor__.
        r   __xor__)rQ   rK   r]   r   r   r)   r+   r   s      r*   r   zArray.__xor__  r   r,   c                   | j                  |dd      }|t        u r|S | j                  j                  |j                         | S )z2
        Performs the operation __iadd__.
        r   __iadd__)rQ   rK   r   r   r5   rM   s     r*   r   zArray.__iadd__  @     **5)ZHN"LU\\*r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z2
        Performs the operation __radd__.
        r   __radd__)rQ   rK   r]   r   r   r)   r+   r   s      r*   r   zArray.__radd__   h     **5)ZHN"L..tU;ekk""5<<0~~""3''r,   c                   | j                  |dd      }|t        u r|S | j                  j                  |j                         | S )z2
        Performs the operation __iand__.
        r   __iand__)rQ   rK   r   r   r   s     r*   r   zArray.__iand__+  A     **52F
SN"LU\\*r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z2
        Performs the operation __rand__.
        r   __rand__)rQ   rK   r]   r   r   r)   r+   r   s      r*   r   zArray.__rand__5  i     **52F
SN"L..tU;ekk""5<<0~~""3''r,   c                   | j                  |dd      }|t        u r|S | j                  j                  |j                         | S )z7
        Performs the operation __ifloordiv__.
        r   __ifloordiv__)rQ   rK   r   r   r   s     r*   r   zArray.__ifloordiv__@  s@     **5./RN"L!!%,,/r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z7
        Performs the operation __rfloordiv__.
        r   __rfloordiv__)rQ   rK   r]   r   r   r)   r+   r   s      r*   r   zArray.__rfloordiv__J  sh     **5./RN"L..tU;ekk''5~~""3''r,   c                   | j                  |dd      }|t        u r|S | j                  j                  |j                         | S )z5
        Performs the operation __ilshift__.
        r   __ilshift__)rQ   rK   r   r   r   s     r*   r   zArray.__ilshift__U  @     **5)]KN"L-r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z5
        Performs the operation __rlshift__.
        r   __rlshift__)rQ   rK   r]   r   r   r)   r+   r   s      r*   r   zArray.__rlshift___  h     **5)]KN"L..tU;ekk%%ell3~~""3''r,   c                   | j                  |dd      }|t        u r|S | j                  j                  |j                        }| j                  j                  |      S )z5
        Performs the operation __imatmul__.
        r   __imatmul__)rQ   rK   r   r   r)   r+   r   s      r*   r   zArray.__imatmul__j  R     **5)]KN"Lkk%%ell3~~""3''r,   c                   | j                  |dd      }|t        u r|S | j                  j                  |j                        }| j                  j                  |      S )z5
        Performs the operation __rmatmul__.
        r   __rmatmul__)rQ   rK   r   r   r)   r+   r   s      r*   r   zArray.__rmatmul__v  r   r,   c                   | j                  |dd      }|t        u r|S | j                  j                  |j                         | S )z2
        Performs the operation __imod__.
        r   __imod__)rQ   rK   r   r   r   s     r*   r   zArray.__imod__  s@     **5.*MN"LU\\*r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z2
        Performs the operation __rmod__.
        r   __rmod__)rQ   rK   r]   r   r   r)   r+   r   s      r*   r   zArray.__rmod__  sh     **5.*MN"L..tU;ekk""5<<0~~""3''r,   c                   | j                  |dd      }|t        u r|S | j                  j                  |j                         | S )z2
        Performs the operation __imul__.
        r   __imul__)rQ   rK   r   r   r   s     r*   r   zArray.__imul__  r   r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z2
        Performs the operation __rmul__.
        r   __rmul__)rQ   rK   r]   r   r   r)   r+   r   s      r*   r   zArray.__rmul__  r   r,   c                   | j                  |dd      }|t        u r|S | j                  j                  |j                         | S )z1
        Performs the operation __ior__.
        r   __ior__)rQ   rK   r   r   r   s     r*   r   zArray.__ior__  sA     **52F	RN"LELL)r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z1
        Performs the operation __ror__.
        r   __ror__)rQ   rK   r]   r   r   r)   r+   r   s      r*   r   zArray.__ror__  r   r,   c                   | j                  |dd      }|t        u r|S | j                  j                  |j                         | S )z2
        Performs the operation __ipow__.
        r   __ipow__)rQ   rK   r   r   r   s     r*   r   zArray.__ipow__  r   r,   c               Z    ddl m} | j                  |dd      }|t        u r|S  |||       S )z2
        Performs the operation __rpow__.
        r   r   r   __rpow__r   r   s      r*   r  zArray.__rpow__  s7     	0**5)ZHN"L 5$r,   c                   | j                  |dd      }|t        u r|S | j                  j                  |j                         | S )z5
        Performs the operation __irshift__.
        r   __irshift__)rQ   rK   r   r  r   s     r*   r  zArray.__irshift__  r   r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z5
        Performs the operation __rrshift__.
        r   __rrshift__)rQ   rK   r]   r   r  r)   r+   r   s      r*   r  zArray.__rrshift__  r   r,   c                   | j                  |dd      }|t        u r|S | j                  j                  |j                         | S )z2
        Performs the operation __isub__.
        r   __isub__)rQ   rK   r   r  r   s     r*   r  zArray.__isub__  r   r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z2
        Performs the operation __rsub__.
        r   __rsub__)rQ   rK   r]   r   r	  r)   r+   r   s      r*   r	  zArray.__rsub__  r   r,   c                   | j                  |dd      }|t        u r|S | j                  j                  |j                         | S )z6
        Performs the operation __itruediv__.
        r   __itruediv__)rQ   rK   r   r  r   s     r*   r  zArray.__itruediv__  sA     **52BNSN"L  .r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z6
        Performs the operation __rtruediv__.
        r   __rtruediv__)rQ   rK   r]   r   r  r)   r+   r   s      r*   r  zArray.__rtruediv__  si     **52BNSN"L..tU;ekk&&u||4~~""3''r,   c                   | j                  |dd      }|t        u r|S | j                  j                  |j                         | S )z2
        Performs the operation __ixor__.
        r   __ixor__)rQ   rK   r   r  r   s     r*   r  zArray.__ixor__  r   r,   c                   | j                  |dd      }|t        u r|S | j                  | |      \  } }| j                  j	                  |j                        }| j
                  j                  |      S )z2
        Performs the operation __rxor__.
        r   __rxor__)rQ   rK   r]   r   r  r)   r+   r   s      r*   r  zArray.__rxor__!  r   r,   c               F    |t        d      |dk(  r| S t        d|      )Nz3The stream argument to to_device() is not supportedcpuzUnsupported device )r   )r5   devicer   s      r*   	to_devicezArray.to_device,  s3    RSSU?K.vj9::r,   c                .    | j                   j                  S )z
        Array API compatible wrapper for :py:meth:`np.ndarray.dtype <numpy.ndarray.dtype>`.

        See its docstring for more information.
        )r   r$   r4   s    r*   r$   zArray.dtype3       {{   r,   c                     y)Nr   r4   s    r*   r  zArray.device<  s    r,   c                    ddl m}  ||       S )Nr   )matrix_transpose)linalgr  )r5   r  s     r*   mTzArray.mTA  s    ,%%r,   c                .    | j                   j                  S )z
        Array API compatible wrapper for :py:meth:`np.ndarray.ndim <numpy.ndarray.ndim>`.

        See its docstring for more information.
        )r   rZ   r4   s    r*   rZ   z
Array.ndimF       {{r,   c                .    | j                   j                  S )z
        Array API compatible wrapper for :py:meth:`np.ndarray.shape <numpy.ndarray.shape>`.

        See its docstring for more information.
        )r   r<   r4   s    r*   r<   zArray.shapeO  r  r,   c                .    | j                   j                  S )z
        Array API compatible wrapper for :py:meth:`np.ndarray.size <numpy.ndarray.size>`.

        See its docstring for more information.
        )r   sizer4   s    r*   r"  z
Array.sizeX  r  r,   c                    | j                   dk7  rt        d      | j                  j                  | j                  j
                        S )z
        Array API compatible wrapper for :py:meth:`np.ndarray.T <numpy.ndarray.T>`.

        See its docstring for more information.
           zwx.T requires x to have 2 dimensions. Use x.mT to transpose stacks of matrices and permute_dims() to permute dimensions.)rZ   r   r)   r+   r   Tr4   s    r*   r%  zArray.Ta  sA     99>  W  X  X~~""4;;==11r,   )r5   r   returnr=   )N)r$   zNone | np.dtype[Any]r&  znpt.NDArray[Any])rM   zbool | int | float | ArrayrN   r=   rO   r=   r&  r   )r&  zTuple[Array, Array])r5   r   r&  r   )r5   r   rM   zUnion[int, float, Array]r&  r   )r5   r   rM   zUnion[int, bool, Array]r&  r   )r5   r   r   zOptional[str]r&  ztypes.ModuleType)r5   r   r&  rI   )r5   r   r&  rG   )r5   r   r   Noner&  r   )r5   r   r&  zTuple[IntEnum, int])r5   r   rM   Union[int, float, bool, Array]r&  r   )r5   r   r&  rH   )r5   r   rm   zQUnion[int, slice, ellipsis, Tuple[Union[int, slice, ellipsis, None], ...], Array]r&  r   )r5   r   r&  rF   )r5   r   rM   zUnion[int, Array]r&  r   )r5   r   rM   r   r&  r   )rm   zKUnion[int, slice, ellipsis, Tuple[Union[int, slice, ellipsis], ...], Array]r   r(  r&  r'  )r5   r   rM   zUnion[float, Array]r&  r   )r   r'  r5   r   r  r   r&  r   )r&  r   )r&  r   )r&  r   )r&  rF   )r&  zTuple[int, ...])U__name__
__module____qualname____doc____annotations__classmethodr+   r    r2   r@   rB   rQ   rJ   staticmethodr]   r{   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r	  r  r  r  r  r  propertyr$   r  r  rZ   r<   r"  r%  __classcell__)r)   s   @r*   r   r   -   st    !   .
?%4'T08d    HbL(	(	( 9=(5	 6: 5/(
	(	(
 
.	(
(	(	(	(
(	(	(	((	(( 	(<
<
 .< 
<&	(	(	(	(	(	(	(
(
(	(	(	( 	(	(	(	(; ! !   & &     ! !     2 2r,   r   )$r,  
__future__r   rj   enumr   _creation_functionsr   _dtypesr   r   r	   r
   r   r   r   r   r   typingr   r   r   r   r   r   types_typingr   r   r   numpy.typingnptnumpyr"   r   r   r  r,   r*   <module>r<     sQ    #   (
 
 
 M L 66  @2 @2r,   