You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spec/API_specification/array_object.md
+31Lines changed: 31 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -179,6 +179,7 @@ For the expected numerical behaviour, see their left-hand equivalents.
179
179
180
180
<!-- NOTE: please keep the attributes in alphabetical order -->
181
181
182
+
(attribute-dtype)=
182
183
### dtype
183
184
184
185
Data type of the array elements.
@@ -189,6 +190,7 @@ Data type of the array elements.
189
190
190
191
- array data type.
191
192
193
+
(attribute-ndim)=
192
194
### ndim
193
195
194
196
Number of array dimensions (axes).
@@ -201,6 +203,7 @@ Number of array dimensions (axes).
201
203
202
204
_TODO: need to more carefully consider this in order to accommodate, e.g., graph tensors where the number of dimensions may be dynamic._
203
205
206
+
(attribute-shape)=
204
207
### shape
205
208
206
209
Array dimensions.
@@ -213,6 +216,7 @@ Array dimensions.
213
216
214
217
_TODO: need to more carefully consider this in order to accommodate, e.g., graph tensors where a shape may be dynamic._
215
218
219
+
(attribute-size)=
216
220
### size
217
221
218
222
Number of elements in an array. This should equal the product of the array's dimensions.
@@ -225,6 +229,7 @@ Number of elements in an array. This should equal the product of the array's dim
225
229
226
230
_TODO: need to more carefully consider this in order to accommodate, e.g., graph tensors where the number of elements may be dynamic._
227
231
232
+
(attribute-T)=
228
233
### T
229
234
230
235
Transpose of the array.
@@ -241,6 +246,7 @@ Transpose of the array.
241
246
242
247
<!-- NOTE: please keep the methods in alphabetical order -->
243
248
249
+
(method-__abs__)=
244
250
### \_\_abs\_\_(x, /)
245
251
246
252
Calculates the absolute value for each element `x_i` of an array instance `x` (i.e., the element-wise result has the same magnitude as the respective element in `x` but has positive sign).
@@ -268,6 +274,7 @@ Calculates the absolute value for each element `x_i` of an array instance `x` (i
268
274
Element-wise results must equal the results returned by the equivalent element-wise function [`abs(x)`](elementwise_functions.md#absx-).
269
275
```
270
276
277
+
(method-__add__)=
271
278
### \_\_add\_\_(x1, x2, /)
272
279
273
280
Calculates the sum for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`. For floating-point arithmetic,
@@ -318,6 +325,7 @@ Floating-point addition is a commutative operation, but not always associative.
318
325
Element-wise results must equal the results returned by the equivalent element-wise function [`add(x1, x2)`](elementwise_functions.md#addx1-x2-).
319
326
```
320
327
328
+
(method-__and__)=
321
329
### \_\_and\_\_(x1, x2, /)
322
330
323
331
Evaluates `x1_i & x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
@@ -343,6 +351,7 @@ Evaluates `x1_i & x2_i` for each element `x1_i` of an array instance `x1` with t
343
351
Element-wise results must equal the results returned by the equivalent element-wise function [`bitwise_and(x1, x2)`](elementwise_functions.md#logical_andx1-x2-).
344
352
``
9E88
`
345
353
354
+
(method-__eq__)=
346
355
### \_\_eq\_\_(x1, x2, /)
347
356
348
357
Computes the truth value of `x1_i == x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
@@ -368,6 +377,7 @@ Computes the truth value of `x1_i == x2_i` for each element `x1_i` of an array i
368
377
Element-wise results must equal the results returned by the equivalent element-wise function [`equal(x1, x2)`](elementwise_functions.md#equalx1-x2-).
369
378
```
370
379
380
+
(method-__floordiv__)=
371
381
### \_\_floordiv\_\_(x1, x2, /)
372
382
373
383
Evaluates `x1_i // x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
@@ -393,6 +403,7 @@ Evaluates `x1_i // x2_i` for each element `x1_i` of an array instance `x1` with
393
403
Element-wise results must equal the results returned by the equivalent element-wise function [`floor_divide(x1, x2)`](elementwise_functions.md#floor_dividex1-x2-).
394
404
```
395
405
406
+
(method-__ge__)=
396
407
### \_\_ge\_\_(x1, x2, /)
397
408
398
409
Computes the truth value of `x1_i >= x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
@@ -418,10 +429,12 @@ Computes the truth value of `x1_i >= x2_i` for each element `x1_i` of an array i
418
429
Element-wise results must equal the results returned by the equivalent element-wise function [`greater_equal(x1, x2)`](elementwise_functions.md#greater_equalx1-x2-).
419
430
```
420
431
432
+
(method-__getitem__)=
421
433
### \_\_getitem\_\_(x, key, /)
422
434
423
435
_TODO: dependent on the indexing specification._
424
436
437
+
(method-__gt__)=
425
438
### \_\_gt\_\_(x1, x2, /)
426
439
427
440
Computes the truth value of `x1_i > x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
@@ -447,6 +460,7 @@ Computes the truth value of `x1_i > x2_i` for each element `x1_i` of an array in
447
460
Element-wise results must equal the results returned by the equivalent element-wise function [`greater(x1, x2)`](elementwise_functions.md#greaterx1-x2-).
448
461
```
449
462
463
+
(method-__invert__)=
450
464
### \_\_invert\_\_(x, /)
451
465
452
466
Evaluates `~x_i` for each element `x_i` of an array instance `x`.
@@ -468,6 +482,7 @@ Evaluates `~x_i` for each element `x_i` of an array instance `x`.
468
482
Element-wise results must equal the results returned by the equivalent element-wise function [`bitwise_invert(x)`](elementwise_functions.md#bitwise_invertx-).
469
483
```
470
484
485
+
(method-__le__)=
471
486
### \_\_le\_\_(x1, x2, /)
472
487
473
488
Computes the truth value of `x1_i <= x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
@@ -493,10 +508,12 @@ Computes the truth value of `x1_i <= x2_i` for each element `x1_i` of an array i
493
508
Element-wise results must equal the results returned by the equivalent element-wise function [`less_equal(x1, x2)`](elementwise_functions.md#less_equalx1-x2-).
494
509
```
495
510
511
+
(method-__len__)=
496
512
### \_\_len\_\_(x, /)
497
513
498
514
_TODO: need to more carefully consider this in order to accommodate, e.g., graph tensors where a shape may be dynamic._
499
515
516
+
(method-__lshift__)=
500
517
### \_\_lshift\_\_(x1, x2, /)
501
518
502
519
Evaluates `x1_i << x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
@@ -522,6 +539,7 @@ Evaluates `x1_i << x2_i` for each element `x1_i` of an array instance `x1` with
522
539
Element-wise results must equal the results returned by the equivalent element-wise function [`less_equal(x1, x2)`](elementwise_functions.md#bitwise_left_shiftx1-x2-).
523
540
```
524
541
542
+
(method-__lt__)=
525
543
### \_\_lt\_\_(x1, x2, /)
526
544
527
545
Computes the truth value of `x1_i < x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
@@ -547,6 +565,7 @@ Computes the truth value of `x1_i < x2_i` for each element `x1_i` of an array in
547
565
Element-wise results must equal the results returned by the equivalent element-wise function [`less(x1, x2)`](elementwise_functions.md#lessx1-x2-).
Evaluates `x1_i % x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
@@ -592,6 +612,7 @@ Evaluates `x1_i % x2_i` for each element `x1_i` of an array instance `x1` with t
592
612
Element-wise results must equal the results returned by the equivalent element-wise function [`remainder(x1, x2)`](elementwise_functions.md#remainderx1-x2-).
593
613
```
594
614
615
+
(method-__mul__)=
595
616
### \_\_mul\_\_(x1, x2, /)
596
617
597
618
Calculates the product for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`. For floating-point arithmetic,
@@ -634,6 +655,7 @@ Floating-point multiplication is not always associative due to finite precision.
634
655
Element-wise results must equal the results returned by the equivalent element-wise function [`multiply(x1, x2)`](elementwise_functions.md#multiplyx1-x2-).
635
656
```
636
657
658
+
(method-__ne__)=
637
659
### \_\_ne\_\_(x1, x2, /)
638
660
639
661
Computes the truth value of `x1_i != x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
@@ -659,6 +681,7 @@ Computes the truth value of `x1_i != x2_i` for each element `x1_i` of an array i
659
681
Element-wise results must equal the results returned by the equivalent element-wise function [`not_equal(x1, x2)`](elementwise_functions.md#not_equalx1-x2-).
660
682
```
661
683
684
+
(method-__neg__)=
662
685
### \_\_neg\_\_(x, /)
663
686
664
687
Evaluates `-x_i` for each element `x_i` of an array instance `x`.
@@ -680,6 +703,7 @@ Evaluates `-x_i` for each element `x_i` of an array instance `x`.
680
703
Element-wise results must equal the results returned by the equivalent element-wise function [`negative(x)`](elementwise_functions.md#negativex-).
681
704
```
682
705
706
+
(method-__or__)=
683
707
### \_\_or\_\_(x1, x2, /)
684
708
685
709
Evaluates `x1_i | x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
@@ -705,6 +729,7 @@ Evaluates `x1_i | x2_i` for each element `x1_i` of an array instance `x1` with t
705
729
Element-wise results must equal the results returned by the equivalent element-wise function [`positive(x1, x2)`](elementwise_functions.md#bitwise_orx1-x2-).
706
730
```
707
731
732
+
(method-__pos__)=
708
733
### \_\_pos\_\_(x, /)
709
734
710
735
Evaluates `+x_i` for each element `x_i` of an array instance `x`.
@@ -726,6 +751,7 @@ Evaluates `+x_i` for each element `x_i` of an array instance `x`.
726
751
Element-wise results must equal the results returned by the equivalent element-wise function [`positive(x)`](elementwise_functions.md#positivex-).
727
752
```
728
753
754
+
(method-__pow__)=
729
755
### \_\_pow\_\_(x1, x2, /)
730
756
731
757
Calculates an implementation-dependent approximation of exponentiation by raising each element `x1_i` (the base) of an array instance `x1` to the power of `x2_i` (the exponent), where `x2_i` is the corresponding element of the array `x2`.
@@ -778,6 +804,7 @@ Calculates an implementation-dependent approximation of exponentiation by raisin
778
804
Element-wise results must equal the results returned by the equivalent element-wise function [`pow(x1, x2)`](elementwise_functions.md#powx1-x2-).
779
805
```
780
806
807
+
(method-__rshift__)=
781
808
### \_\_rshift\_\_(x1, x2, /)
782
809
783
810
Evaluates `x1_i >> x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
@@ -803,10 +830,12 @@ Evaluates `x1_i >> x2_i` for each element `x1_i` of an array instance `x1` with
803
830
Element-wise results must equal the results returned by the equivalent element-wise function [`bitwise_right_shift(x1, x2)`](elementwise_functions.md#bitwise_right_shiftx1-x2-).
804
831
```
805
832
833
+
(method-__setitem__)=
806
834
### \_\_setitem\_\_(x, key, value, /)
807
835
808
836
_TODO: dependent on the indexing specification._
809
837
838
+
(method-__sub__)=
810
839
### \_\_sub\_\_(x1, x2, /)
811
840
812
841
Calculates the difference for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`. The result of `x1_i - x2_i` must be the same as `x1_i + (-x2_i)` and is thus governed by the same floating-point rules as addition (see [`__add__()`](#__add__x1-x2-)).
@@ -832,6 +861,7 @@ Calculates the difference for each element `x1_i` of an array instance `x1` with
832
861
Element-wise results must equal the results returned by the equivalent element-wise function [`subtract(x1, x2)`](elementwise_functions.md#subtractx1-x2-).
833
862
```
834
863
864
+
(method-__truediv__)=
835
865
### \_\_truediv\_\_(x1, x2, /)
836
866
837
867
Evaluates `x1_i / x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`. For floating-point arithmetic,
@@ -882,6 +912,7 @@ Evaluates `x1_i / x2_i` for each element `x1_i` of an array instance `x1` with t
882
912
Element-wise results must equal the results returned by the equivalent element-wise function [`divide(x1, x2)`](elementwise_functions.md#dividex1-x2-).
883
913
```
884
914
915
+
(method-__xor__)=
885
916
### \_\_xor\_\_(x1, x2, /)
886
917
887
918
Evaluates `x1_i ^ x2_i` for each element `x1_i` of an array instance `x1` with the respective element `x2_i` of the array `x2`.
0 commit comments