zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
U
O±d8­ã@sÎdZddlmZddlZddlmZddlmZddlm    Z    m
Z
m Z m Z m Z mZmZmZddlmZmZmZmZmZmZddlZer¨dd    lmZmZmZmZddlmZddlZ dd
lm!Z!Gd d „d ƒZ"dS) 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Ú_numeric_dtypesÚ _result_typeÚ_dtype_categories)Ú TYPE_CHECKINGÚOptionalÚTupleÚUnionÚAnyÚ SupportsIndex)rÚ    PyCapsuleÚDeviceÚDtype)Ú    array_apics@eZdZUdZded<e‡fdd„ƒZdd„Zddd    œd
d „Zddd    œd d „Z    d½dddœdd„Z
dddddœdd„Z dd„Z e ddœdd„ƒZdd„Zddd    œd d!„Zdd"dd#œd$d%„Zdd&dd#œd'd(„Zdd)œdd*d+d,œd-d.„Zdd/d    œd0d1„Zdd2œdd3d4d5œd6d7„Zdd8d    œd9d:„Zdd;dd#œd<d=„Zdd>d    œd?d@„Zdd"dd#œdAdB„Zdd"dd#œdCdD„ZddEddFœdGdH„Zdd"dd#œdIdJ„ZddKd    œdLdM„ZddKd    œdNdO„Zddd    œdPdQ„Zdd"dd#œdRdS„Z ddTdd#œdUdV„Z!dd"dd#œdWdX„Z"dddd#œdYdZ„Z#dd"dd#œd[d\„Z$dd"dd#œd]d^„Z%dd;dd#œd_d`„Z&ddd    œdadb„Z'dd&dd#œdcdd„Z(ddd    œdedf„Z)dd"dd#œdgdh„Z*ddTdd#œdidj„Z+dEd;d3dkœdldm„Z,dd"dd#œdndo„Z-ddpdd#œdqdr„Z.dd&dd#œdsdt„Z/dd"dd#œdudv„Z0dd"dd#œdwdx„Z1dd&dd#œdydz„Z2dd&dd#œd{d|„Z3dd"dd#œd}d~„Z4dd"dd#œdd€„Z5ddTdd#œdd‚„Z6ddTdd#œdƒd„„Z7dddd#œd…d†„Z8dddd#œd‡dˆ„Z9dd"dd#œd‰dŠ„Z:dd"dd#œd‹dŒ„Z;dd"dd#œddŽ„Z<dd"dd#œdd„Z=dd&dd#œd‘d’„Z>dd&dd#œd“d”„Z?dd"dd#œd•d–„Z@dd"dd#œd—d˜„ZAddTdd#œd™dš„ZBddTdd#œd›dœ„ZCdd"dd#œddž„ZDdd"dd#œdŸd „ZEddpdd#œd¡d¢„ZFddpdd#œd£d¤„ZGdd&dd#œd¥d¦„ZHdd&dd#œd§d¨„ZId¾d3dd©ddªœd«d¬„ZJeKd­dœd®d¯„ƒZLeKd©dœd°d±„ƒZMeKddœd²d³„ƒZNeKdKdœd´dµ„ƒZOeKd¶dœd·d¸„ƒZPeKdKdœd¹dº„ƒZQeKddœd»d¼„ƒZR‡ZSS)¿Ú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Ú_arraycsHtƒ |¡}t|tjƒr"t |¡}|jtkr>td|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ÚnpZgenericrÚdtyperÚ    TypeErrorr)ÚclsÚxÚobj©Ú    __class__©úTd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\numpy/array_api/_array_object.pyÚ_new?s  
 
 ÿz
Array._newcOs tdƒ‚dS)Nz{The array_api Array object should not be instantiated directly. Use an array creation function, such as asarray(), instead.)r )r!ÚargsÚkwargsr&r&r'rWsÿz Array.__new__Ústr)ÚselfÚreturncCs|j ¡ dd¡S)z1
        Performs the operation __str__.
        Úarrayr)rÚ__str__Úreplace©r,r&r&r'r/_sz Array.__str__cCsNd|jj›d}d|jkr*d}t|jƒ}nd}tj|jd||d}|||S)z2
        Performs the operation __repr__.
        z, dtype=ú)rzempty(zArray(z, )Ú    separatorÚprefixÚsuffix)rÚnameÚshaper+rZ array2stringr)r,r5r4Zmidr&r&r'Ú__repr__es
 zArray.__repr__NzNone | np.dtype[Any]znpt.NDArray[Any])rr-cCstj|j|d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)rrr)r,rr&r&r'Ú    __array__tszArray.__array__zbool | int | float | Array)ÚotherÚdtype_categoryÚopr-cCs´|jt|kr"td|›d|›ƒ‚t|tttfƒr>| |¡}n2t|tƒrl|jt|krptd|›d|›ƒ‚nt    St
|j|jƒ}|  d¡r°||jkr°td|›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
        zOnly z dtypes are allowed in Z__izCannot perform z  with dtypes ú and ) rr r rÚintÚfloatÚboolÚ_promote_scalarrÚNotImplementedr Ú
startswith)r,r:r;r<Z    res_dtyper&r&r'Ú_check_allowed_dtypess  
 
    
ÿzArray._check_allowed_dtypescCsvt|tƒr|jtkrbtdƒ‚nDt|tƒr<|jtkrbtdƒ‚n&t|tƒrZ|jtkrbtdƒ‚ntdƒ‚t     t
  ||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 arrayszEPython float scalars can only be promoted with floating-point arrays.z 'scalar' must be a Python scalar) rr@rrr r>r?r
rr(rr.)r,Zscalarr&r&r'rA«s"
 
ÿ
 
ÿ
 
ÿ    zArray._promote_scalarzTuple[Array, Array])r-cCsR|jdkr&|jdkr&t |jd¡}n$|jdkrJ|jdkrJt |jd¡}||fS)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.
        rN)Úndimrr(r)Úx1Zx2r&r&r'Ú_normalize_two_argsÑs
zArray._normalize_two_argsc Csšt|tƒr|n|f}|D]b}t|tƒs`t|tƒst|tƒs|tks|dkst|tƒst|tjƒst    d|›dt
|ƒ›dƒ‚qg}g}d}d}|D]b}|dk    r|  |¡t|tƒs¼t|tjƒrÖ|j t krÊd}|  |¡q|tkrè|d7}q|  |¡qt|ƒ}|dkr
dS|dkr>|s>||jkr>t    d    |j›d
|›d ƒ‚|dkrP|j}    n~d}
t|ƒD]8\} }t|tƒs\t|tjƒs\|tkr\| }
q–q\|
dk    s¤t‚|j||
} |jd|
…|j| d…}    t||    ƒD]º\}} t|tƒrú| dkrþd }nd | ›d| d›d}|jdk    r†zt |j¡}Wntk
rFYn@X| |krb| ks†nt    d|›d|›d|›d| ›d    ƒ‚|jdk    r’zt |j¡}Wntk
r¸Yn@X| |krÔ| ks’nt    d|›d|›d|›d| ›d    ƒ‚n˜t|tƒrv|j t krLt|ƒdkrLt|tƒs0t‚t    d|›dt|ƒ›dƒ‚n(|j tkr’|jdkr’t    d|›dƒ‚nt|tƒrØt    d|›dƒ‚qØdS)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.
 
        NzSingle-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.rFTrz
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 -r=z
 (or None)zSlice 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Útupler@rÚsliceÚEllipsisrrZndarrayÚ
IndexErrorÚtypeÚappendrrÚlenrEr7Ú    enumerateÚAssertionErrorÚzipÚstartÚoperatorÚindexr Ústopr)r,ÚkeyÚ_keyÚiZnonexpanding_keyZ single_axesZ
n_ellipsisZ key_has_maskZ n_single_axesZ indexed_shapeZellipsis_startÚposZ ellipsis_endZsideZf_rangerRrUr&r&r'Ú_validate_indexös²/
ÿþýüû
úÿ
 
 
 
 
ÿ    
 
 
ÿ 
 ÿ ÿ ÿ
ÿ 
ÿzArray._validate_indexcCs(|jtkrtdƒ‚|j ¡}|j |¡S)z1
        Performs the operation __abs__.
        z*Only numeric dtypes are allowed in __abs__)rr r rÚ__abs__r%r(©r,Úresr&r&r'r[œs
 
z Array.__abs__zUnion[int, float, Array])r,r:r-cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z1
        Performs the operation __add__.
        ÚnumericÚ__add__)rDrBrGrr_r%r(©r,r:r]r&r&r'r_¥s z Array.__add__zUnion[int, bool, Array]cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z1
        Performs the operation __and__.
        úinteger or booleanÚ__and__)rDrBrGrrbr%r(r`r&r&r'rb°s z Array.__and__)Ú api_versionz Optional[str]ztypes.ModuleType)r,rcr-cCs$|dk    r | d¡s td|›ƒ‚tS)Nz2021.z Unrecognized array API version: )rCÚ
ValueErrorr)r,rcr&r&r'Ú__array_namespace__»szArray.__array_namespace__r@cCs4|jjdkrtdƒ‚|jtkr&tdƒ‚|j ¡}|S)z2
        Performs the operation __bool__.
        rz0bool is only allowed on arrays with 0 dimensionsz&bool is only allowed on boolean arrays)rrEr rrrdÚ__bool__r\r&r&r'rfÂs  
 
zArray.__bool__©ÚstreamÚNoner)r,rhr-cCs|jj|dS)z4
        Performs the operation __dlpack__.
        rg)rÚ
__dlpack__)r,rhr&r&r'rjÎszArray.__dlpack__zTuple[IntEnum, int]cCs
|j ¡S)z;
        Performs the operation __dlpack_device__.
        )rÚ__dlpack_device__r1r&r&r'rkÔszArray.__dlpack_device__zUnion[int, float, bool, Array]cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z0
        Performs the operation __eq__.
        ÚallÚ__eq__)rDrBrGrrmr%r(r`r&r&r'rmÛs z Array.__eq__r?cCs4|jjdkrtdƒ‚|jtkr&tdƒ‚|j ¡}|S)z3
        Performs the operation __float__.
        rz1float is only allowed on arrays with 0 dimensionsz.float is only allowed on floating-point arrays)rrEr rr
rdÚ    __float__r\r&r&r'rnès  
 
zArray.__float__cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z6
        Performs the operation __floordiv__.
        r^Ú __floordiv__)rDrBrGrror%r(r`r&r&r'roôs zArray.__floordiv__cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z0
        Performs the operation __ge__.
        r^Ú__ge__)rDrBrGrrpr%r(r`r&r&r'rpÿs z Array.__ge__zKUnion[int, slice, ellipsis, Tuple[Union[int, slice, ellipsis], ...], Array])r,rVr-cCs0| |¡t|tƒr|j}|j |¡}| |¡S)z5
        Performs the operation __getitem__.
        )rZrrrÚ __getitem__r()r,rVr]r&r&r'rq
s
 
 
 zArray.__getitem__cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z0
        Performs the operation __gt__.
        r^Ú__gt__)rDrBrGrrrr%r(r`r&r&r'rrs z Array.__gt__r>cCs4|jjdkrtdƒ‚|jtkr&tdƒ‚|j ¡}|S)z1
        Performs the operation __int__.
        rz/int is only allowed on arrays with 0 dimensionsz%int is only allowed on integer arrays)rrEr rrrdÚ__int__r\r&r&r'rs(s  
 
z Array.__int__cCs|j ¡}|S)z3
        Performs the operation __index__.
        )rÚ    __index__r\r&r&r'rt4s
zArray.__index__cCs(|jtkrtdƒ‚|j ¡}|j |¡S)z4
        Performs the operation __invert__.
        z8Only integer or boolean dtypes are allowed in __invert__)rr    r rÚ
__invert__r%r(r\r&r&r'ru;s
 
zArray.__invert__cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z0
        Performs the operation __le__.
        r^Ú__le__)rDrBrGrrvr%r(r`r&r&r'rvDs z Array.__le__zUnion[int, Array]cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z4
        Performs the operation __lshift__.
        ÚintegerÚ
__lshift__)rDrBrGrrxr%r(r`r&r&r'rxOs zArray.__lshift__cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z0
        Performs the operation __lt__.
        r^Ú__lt__)rDrBrGrryr%r(r`r&r&r'ryZs z Array.__lt__cCs4| |dd¡}|tkr|S|j |j¡}|j |¡S)z4
        Performs the operation __matmul__.
        r^Ú
__matmul__)rDrBrrzr%r(r`r&r&r'rzes
zArray.__matmul__cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z1
        Performs the operation __mod__.
        r^Ú__mod__)rDrBrGrr{r%r(r`r&r&r'r{qs z Array.__mod__cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z1
        Performs the operation __mul__.
        r^Ú__mul__)rDrBrGrr|r%r(r`r&r&r'r||s z Array.__mul__cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z0
        Performs the operation __ne__.
        rlÚ__ne__)rDrBrGrr}r%r(r`r&r&r'r}‡s z Array.__ne__cCs(|jtkrtdƒ‚|j ¡}|j |¡S)z1
        Performs the operation __neg__.
        z*Only numeric dtypes are allowed in __neg__)rr r rÚ__neg__r%r(r\r&r&r'r~’s
 
z Array.__neg__cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z0
        Performs the operation __or__.
        raÚ__or__)rDrBrGrrr%r(r`r&r&r'r›s z Array.__or__cCs(|jtkrtdƒ‚|j ¡}|j |¡S)z1
        Performs the operation __pos__.
        z*Only numeric dtypes are allowed in __pos__)rr r rÚ__pos__r%r(r\r&r&r'r€¦s
 
z Array.__pos__cCs0ddlm}| |dd¡}|tkr&|S|||ƒS)z1
        Performs the operation __pow__.
        r©Úpowr^Ú__pow__©Z_elementwise_functionsr‚rDrB©r,r:r‚r&r&r'rƒ¯s
 z Array.__pow__cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z4
        Performs the operation __rshift__.
        rwÚ
__rshift__)rDrBrGrr†r%r(r`r&r&r'r†¼s zArray.__rshift__)rVÚvaluer-cCs2| |¡t|tƒr|j}|j |t|ƒj¡dS)z5
        Performs the operation __setitem__.
        N)rZrrrÚ __setitem__r)r,rVr‡r&r&r'rˆÇs
 
zArray.__setitem__cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z1
        Performs the operation __sub__.
        r^Ú__sub__)rDrBrGrr‰r%r(r`r&r&r'r‰Ús z Array.__sub__zUnion[float, Array]cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z5
        Performs the operation __truediv__.
        úfloating-pointÚ __truediv__)rDrBrGrr‹r%r(r`r&r&r'r‹çs zArray.__truediv__cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z1
        Performs the operation __xor__.
        raÚ__xor__)rDrBrGrrŒr%r(r`r&r&r'rŒòs z Array.__xor__cCs,| |dd¡}|tkr|S|j |j¡|S)z2
        Performs the operation __iadd__.
        r^Ú__iadd__)rDrBrr©r,r:r&r&r'rýs
zArray.__iadd__cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z2
        Performs the operation __radd__.
        r^Ú__radd__)rDrBrGrrr%r(r`r&r&r'rs zArray.__radd__cCs,| |dd¡}|tkr|S|j |j¡|S)z2
        Performs the operation __iand__.
        raÚ__iand__)rDrBrrrŽr&r&r'rs
zArray.__iand__cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z2
        Performs the operation __rand__.
        raÚ__rand__)rDrBrGrr‘r%r(r`r&r&r'r‘s zArray.__rand__cCs,| |dd¡}|tkr|S|j |j¡|S)z7
        Performs the operation __ifloordiv__.
        r^Ú __ifloordiv__)rDrBrr’rŽr&r&r'r’'s
zArray.__ifloordiv__cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z7
        Performs the operation __rfloordiv__.
        r^Ú __rfloordiv__)rDrBrGrr“r%r(r`r&r&r'r“1s zArray.__rfloordiv__cCs,| |dd¡}|tkr|S|j |j¡|S)z5
        Performs the operation __ilshift__.
        rwÚ __ilshift__)rDrBrr”rŽr&r&r'r”<s
zArray.__ilshift__cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z5
        Performs the operation __rlshift__.
        rwÚ __rlshift__)rDrBrGrr•r%r(r`r&r&r'r•Fs zArray.__rlshift__cCsz| |dd¡}|tkr|S|j}|jdks2|dkr:tdƒ‚t|ƒdksV|d|dkr^tdƒ‚|j |j¡|jd    d    …<|S)
z5
        Performs the operation __imatmul__.
        r^Ú __imatmul__r&z"@= requires at least one dimensionréÿÿÿÿéþÿÿÿz-@= cannot change the shape of the input arrayN)rDrBr7rdrNrrz)r,r:Z other_shaper&r&r'r–QszArray.__imatmul__cCs4| |dd¡}|tkr|S|j |j¡}|j |¡S)z5
        Performs the operation __rmatmul__.
        r^Ú __rmatmul__)rDrBrr™r%r(r`r&r&r'r™gs
zArray.__rmatmul__cCs,| |dd¡}|tkr|S|j |j¡|S)z2
        Performs the operation __imod__.
        r^Ú__imod__)rDrBrršrŽr&r&r'ršss
zArray.__imod__cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z2
        Performs the operation __rmod__.
        r^Ú__rmod__)rDrBrGrr›r%r(r`r&r&r'r›}s zArray.__rmod__cCs,| |dd¡}|tkr|S|j |j¡|S)z2
        Performs the operation __imul__.
        r^Ú__imul__)rDrBrrœrŽr&r&r'rœˆs
zArray.__imul__cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z2
        Performs the operation __rmul__.
        r^Ú__rmul__)rDrBrGrrr%r(r`r&r&r'r’s zArray.__rmul__cCs,| |dd¡}|tkr|S|j |j¡|S)z1
        Performs the operation __ior__.
        raÚ__ior__)rDrBrržrŽr&r&r'ržs
z Array.__ior__cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z1
        Performs the operation __ror__.
        raÚ__ror__)rDrBrGrrŸr%r(r`r&r&r'rŸ§s z Array.__ror__cCs,| |dd¡}|tkr|S|j |j¡|S)z2
        Performs the operation __ipow__.
        r^Ú__ipow__)rDrBrr rŽr&r&r'r ²s
zArray.__ipow__cCs0ddlm}| |dd¡}|tkr&|S|||ƒS)z2
        Performs the operation __rpow__.
        rrr^Ú__rpow__r„r…r&r&r'r¡¼s
 zArray.__rpow__cCs,| |dd¡}|tkr|S|j |j¡|S)z5
        Performs the operation __irshift__.
        rwÚ __irshift__)rDrBrr¢rŽr&r&r'r¢És
zArray.__irshift__cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z5
        Performs the operation __rrshift__.
        rwÚ __rrshift__)rDrBrGrr£r%r(r`r&r&r'r£Ós zArray.__rrshift__cCs,| |dd¡}|tkr|S|j |j¡|S)z2
        Performs the operation __isub__.
        r^Ú__isub__)rDrBrr¤rŽr&r&r'r¤Þs
zArray.__isub__cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z2
        Performs the operation __rsub__.
        r^Ú__rsub__)rDrBrGrr¥r%r(r`r&r&r'r¥ès zArray.__rsub__cCs,| |dd¡}|tkr|S|j |j¡|S)z6
        Performs the operation __itruediv__.
        rŠÚ __itruediv__)rDrBrr¦rŽr&r&r'r¦ós
zArray.__itruediv__cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z6
        Performs the operation __rtruediv__.
        rŠÚ __rtruediv__)rDrBrGrr§r%r(r`r&r&r'r§ýs zArray.__rtruediv__cCs,| |dd¡}|tkr|S|j |j¡|S)z2
        Performs the operation __ixor__.
        raÚ__ixor__)rDrBrr¨rŽr&r&r'r¨s
zArray.__ixor__cCsD| |dd¡}|tkr|S| ||¡\}}|j |j¡}|j |¡S)z2
        Performs the operation __rxor__.
        raÚ__rxor__)rDrBrGrr©r%r(r`r&r&r'r©s zArray.__rxor__r)rhr,Údevicer-cCs.|dk    rtdƒ‚|dkr|Std|›ƒ‚dS)Nz3The stream argument to to_device() is not supportedÚcpuzUnsupported device )rd)r,rªrhr&r&r'Ú    to_devices
zArray.to_devicercCs|jjS)z–
        Array API compatible wrapper for :py:meth:`np.ndarray.dtype <numpy.ndarray.dtype>`.
 
        See its docstring for more information.
        )rrr1r&r&r'r$sz Array.dtypecCsdS)Nr«r&r1r&r&r'rª-sz Array.devicecCsddlm}||ƒS)Nr)Úmatrix_transpose)Zlinalgr­)r,r­r&r&r'ÚmT2s zArray.mTcCs|jjS)z”
        Array API compatible wrapper for :py:meth:`np.ndarray.ndim <numpy.ndarray.ndim>`.
 
        See its docstring for more information.
        )rrEr1r&r&r'rE7sz
Array.ndimzTuple[int, ...]cCs|jjS)z–
        Array API compatible wrapper for :py:meth:`np.ndarray.shape <numpy.ndarray.shape>`.
 
        See its docstring for more information.
        )rr7r1r&r&r'r7@sz Array.shapecCs|jjS)z”
        Array API compatible wrapper for :py:meth:`np.ndarray.size <numpy.ndarray.size>`.
 
        See its docstring for more information.
        )rÚsizer1r&r&r'r¯Isz
Array.sizecCs"|jdkrtdƒ‚|j |jj¡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.)rErdr%r(rÚTr1r&r&r'r±Rs
 
zArray.T)N)N)TÚ__name__Ú
__module__Ú __qualname__Ú__doc__Ú__annotations__Ú classmethodr(rr/r8r9rDrAÚ staticmethodrGrZr[r_rbrerfrjrkrmrnrorprqrrrsrtrurvrxryrzr{r|r}r~rr€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¬Úpropertyrrªr®rEr7r¯r±Ú __classcell__r&r&r$r'r,s°
 *&$'      ÿ                                
 
 
 
 
 
 
 
 
 
 
 
 r)#rµÚ
__future__rrSÚenumrZ_creation_functionsrZ_dtypesrrrr    r
r r r ÚtypingrrrrrrÚtypesÚ_typingrrrZ numpy.typingZnptÚnumpyrrrr&r&r&r'Ú<module>s   (