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
+7-29
Original file line number
Diff line number
Diff line change
@@ -183,7 +183,6 @@ an array object supporting the following reflected operators:
183
183
The results of applying reflected operators must match their non-reflected equivalents.
184
184
185
185
```{note}
186
-
187
186
All operators for which `array <op> scalar` is implemented must have an equivalent reflected operator implementation.
188
187
```
189
188
@@ -259,11 +258,17 @@ _TODO: need to more carefully consider this in order to accommodate, e.g., graph
259
258
260
259
Transpose of the array.
261
260
261
+
The array instance must be two-dimensional. If the array instance is not two-dimensional, an error should be raised.
262
+
263
+
```{note}
264
+
Limiting the transpose to two-dimensional arrays (matrices) deviates from the NumPy et al practice of reversing all axes for arrays having more than two-dimensions. This is intentional, as reversing all axes was found to be problematic (e.g., conflicting with the mathematical definition of a transpose which is limited to matrices; not operating on batches of matrices; et cetera). In order to reverse all axes, one is recommended to use the functional `permute` interface found in this specification.
265
+
```
266
+
262
267
#### Returns
263
268
264
269
-**out**: _<array>_
265
270
266
-
- array whose dimensions (axes) are permuted in reverse order relative to original array. The returned array must have the same data type as the original array.
271
+
-two-dimensional array whose first and last dimensions (axes) are permuted in reverse order relative to original array. The returned array must have the same data type as the original array.
267
272
268
273
* * *
269
274
@@ -297,7 +302,6 @@ For floating-point operands, let `self` equal `x`.
297
302
- an array containing the element-wise absolute value. The returned array must have the same data type as `self`.
298
303
299
304
```{note}
300
-
301
305
Element-wise results must equal the results returned by the equivalent element-wise function [`abs(x)`](elementwise_functions.md#absx-).
302
306
```
303
307
@@ -329,7 +333,6 @@ For floating-point operands, let `self` equal `x1` and `other` equal `x2`.
329
333
- In the remaining cases, when neither `infinity`, `+0`, `-0`, nor a `NaN` is involved, and the operands have the same mathematical sign or have different magnitudes, the sum must be computed and rounded to the nearest representable value according to IEEE 754-2019 and a supported round mode. If the magnitude is too large to represent, the operation overflows and the result is an `infinity` of appropriate mathematical sign.
330
334
331
335
```{note}
332
-
333
336
Floating-point addition is a commutative operation, but not always associative.
334
337
```
335
338
@@ -350,7 +353,6 @@ Floating-point addition is a commutative operation, but not always associative.
350
353
- an array containing the element-wise sums. The returned array must have a data type determined by {ref}`type-promotion`.
351
354
352
355
```{note}
353
-
354
356
Element-wise results must equal the results returned by the equivalent element-wise function [`add(x1, x2)`](elementwise_functions.md#addx1-x2-).
355
357
```
356
358
@@ -376,7 +378,6 @@ Evaluates `self_i & other_i` for each element of an array instance with the resp
376
378
- an array containing the element-wise results. The returned array must have a data type determined by {ref}`type-promotion`.
377
379
378
380
```{note}
379
-
380
381
Element-wise results must equal the results returned by the equivalent element-wise function [`bitwise_and(x1, x2)`](elementwise_functions.md#logical_andx1-x2-).
381
382
```
382
383
@@ -524,7 +525,6 @@ Computes the truth value of `self_i == other_i` for each element of an array ins
524
525
- an array containing the element-wise results. The returned array must have a data type of `bool`.
525
526
526
527
```{note}
527
-
528
528
Element-wise results must equal the results returned by the equivalent element-wise function [`equal(x1, x2)`](elementwise_functions.md#equalx1-x2-).
529
529
```
530
530
@@ -567,7 +567,6 @@ Evaluates `self_i // other_i` for each element of an array instance with the res
567
567
- an array containing the element-wise results. The returned array must have a data type determined by {ref}`type-promotion`.
568
568
569
569
```{note}
570
-
571
570
Element-wise results must equal the results returned by the equivalent element-wise function [`floor_divide(x1, x2)`](elementwise_functions.md#floor_dividex1-x2-).
572
571
```
573
572
@@ -593,7 +592,6 @@ Computes the truth value of `self_i >= other_i` for each element of an array ins
593
592
- an array containing the element-wise results. The returned array must have a data type of `bool`.
594
593
595
594
```{note}
596
-
597
595
Element-wise results must equal the results returned by the equivalent element-wise function [`greater_equal(x1, x2)`](elementwise_functions.md#greater_equalx1-x2-).
598
596
```
599
597
@@ -640,7 +638,6 @@ Computes the truth value of `self_i > other_i` for each element of an array inst
640
638
- an array containing the element-wise results. The returned array must have a data type of `bool`.
641
639
642
640
```{note}
643
-
644
641
Element-wise results must equal the results returned by the equivalent element-wise function [`greater(x1, x2)`](elementwise_functions.md#greaterx1-x2-).
645
642
```
646
643
@@ -679,7 +676,6 @@ Evaluates `~self_i` for each element of an array instance.
679
676
- an array containing the element-wise results. The returned array must have the same data type as `self`.
680
677
681
678
```{note}
682
-
683
679
Element-wise results must equal the results returned by the equivalent element-wise function [`bitwise_invert(x)`](elementwise_functions.md#bitwise_invertx-).
684
680
```
685
681
@@ -705,7 +701,6 @@ Computes the truth value of `self_i <= other_i` for each element of an array ins
705
701
- an array containing the element-wise results. The returned array must have a data type of `bool`.
706
702
707
703
```{note}
708
-
709
704
Element-wise results must equal the results returned by the equivalent element-wise function [`less_equal(x1, x2)`](elementwise_functions.md#less_equalx1-x2-).
710
705
```
711
706
@@ -736,7 +731,6 @@ Evaluates `self_i << other_i` for each element of an array instance with the res
736
731
- an array containing the element-wise results. The returned array must have the same data type as `self`.
737
732
738
733
```{note}
739
-
740
734
Element-wise results must equal the results returned by the equivalent element-wise function [`bitwise_left_shift(x1, x2)`](elementwise_functions.md#bitwise_left_shiftx1-x2-).
741
735
```
742
736
@@ -762,7 +756,6 @@ Computes the truth value of `self_i < other_i` for each element of an array inst
762
756
- an array containing the element-wise results. The returned array must have a data type of `bool`.
763
757
764
758
```{note}
765
-
766
759
Element-wise results must equal the results returned by the equivalent element-wise function [`less(x1, x2)`](elementwise_functions.md#lessx1-x2-).
767
760
```
768
761
@@ -772,7 +765,6 @@ Element-wise results must equal the results returned by the equivalent element-w
772
765
Computes the matrix product.
773
766
774
767
```{note}
775
-
776
768
The `matmul` function must implement the same semantics as the built-in `@` operator (see [PEP 465](https://www.python.org/dev/peps/pep-0465)).
777
769
```
778
770
@@ -801,7 +793,6 @@ The `matmul` function must implement the same semantics as the built-in `@` oper
801
793
The returned array must have a data type determined by {ref}`type-promotion`.
802
794
803
795
```{note}
804
-
805
796
Results must equal the results returned by the equivalent function [`matmul(x1, x2)`](linear_algebra_functions.md#matmulx1-x2-).
806
797
```
807
798
@@ -833,7 +824,6 @@ Evaluates `self_i % other_i` for each element of an array instance with the resp
833
824
- an array containing the element-wise results. Each element-wise result must have the same sign as the respective element `other_i`. The returned array must have a floating-point data type determined by {ref}`type-promotion`.
834
825
835
826
```{note}
836
-
837
827
Element-wise results must equal the results returned by the equivalent element-wise function [`remainder(x1, x2)`](elementwise_functions.md#remainderx1-x2-).
838
828
```
839
829
@@ -857,7 +847,6 @@ For floating-point operands, let `self` equal `x1` and `other` equal `x2`.
857
847
- In the remaining cases, where neither `infinity` nor `NaN` is involved, the product must be computed and rounded to the nearest representable value according to IEEE 754-2019 and a supported rounding mode. If the magnitude is too large to represent, the result is an `infinity` of appropriate mathematical sign. If the magnitude is too small to represent, the result is a zero of appropriate mathematical sign.
858
848
859
849
```{note}
860
-
861
850
Floating-point multiplication is not always associative due to finite precision.
862
851
```
863
852
@@ -878,7 +867,6 @@ Floating-point multiplication is not always associative due to finite precision.
878
867
- an array containing the element-wise products. The returned array must have a data type determined by {ref}`type-promotion`.
879
868
880
869
```{note}
881
-
882
870
Element-wise results must equal the results returned by the equivalent element-wise function [`multiply(x1, x2)`](elementwise_functions.md#multiplyx1-x2-).
883
871
```
884
872
@@ -904,7 +892,6 @@ Computes the truth value of `self_i != other_i` for each element of an array ins
904
892
- an array containing the element-wise results. The returned array must have a data type of `bool` (i.e., must be a boolean array).
905
893
906
894
```{note}
907
-
908
895
Element-wise results must equal the results returned by the equivalent element-wise function [`not_equal(x1, x2)`](elementwise_functions.md#not_equalx1-x2-).
909
896
```
910
897
@@ -926,7 +913,6 @@ Evaluates `-self_i` for each element of an array instance.
926
913
- an array containing the evaluated result for each element in `self`. The returned array must have a data type determined by {ref}`type-promotion`.
927
914
928
915
```{note}
929
-
930
916
Element-wise results must equal the results returned by the equivalent element-wise function [`negative(x)`](elementwise_functions.md#negativex-).
931
917
```
932
918
@@ -952,7 +938,6 @@ Evaluates `self_i | other_i` for each element of an array instance with the resp
952
938
- an array containing the element-wise results. The returned array must have a data type determined by {ref}`type-promotion`.
953
939
954
940
```{note}
955
-
956
941
Element-wise results must equal the results returned by the equivalent element-wise function [`bitwise_or(x1, x2)`](elementwise_functions.md#bitwise_orx1-x2-).
957
942
```
958
943
@@ -974,7 +959,6 @@ Evaluates `+self_i` for each element of an array instance.
974
959
- an array containing the evaluated result for each element. The returned array must have the same data type as `self`.
975
960
976
961
```{note}
977
-
978
962
Element-wise results must equal the results returned by the equivalent element-wise function [`positive(x)`](elementwise_functions.md#positivex-).
979
963
```
980
964
@@ -1029,7 +1013,6 @@ For floating-point operands, let `self` equal `x1` and `other` equal `x2`.
1029
1013
- an array containing the element-wise results. The returned array must have a data type determined by {ref}`type-promotion`.
1030
1014
1031
1015
```{note}
1032
-
1033
1016
Element-wise results must equal the results returned by the equivalent element-wise function [`pow(x1, x2)`](elementwise_functions.md#powx1-x2-).
1034
1017
```
1035
1018
@@ -1055,7 +1038,6 @@ Evaluates `self_i >> other_i` for each element of an array instance with the res
1055
1038
- an array containing the element-wise results. The returned array must have the same data type as `self`.
1056
1039
1057
1040
```{note}
1058
-
1059
1041
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-).
1060
1042
```
1061
1043
@@ -1079,7 +1061,6 @@ Sets `self[key]` to `value`.
1079
1061
- value(s) to set. Must be compatible with `self[key]` (see {ref}`broadcasting`).
1080
1062
1081
1063
```{note}
1082
-
1083
1064
Setting array values must not affect the data type of `self`.
1084
1065
1085
1066
When `value` is a Python scalar (i.e., `int`, `float`, `bool`), behavior must follow specification guidance on mixing arrays with Python scalars (see {ref}`type-promotion`).
@@ -1109,7 +1090,6 @@ Calculates the difference for each element of an array instance with the respect
1109
1090
- an array containing the element-wise differences. The returned array must have a data type determined by {ref}`type-promotion`.
1110
1091
1111
1092
```{note}
1112
-
1113
1093
Element-wise results must equal the results returned by the equivalent element-wise function [`subtract(x1, x2)`](elementwise_functions.md#subtractx1-x2-).
1114
1094
```
1115
1095
@@ -1162,7 +1142,6 @@ For floating-point operands, let `self` equal `x1` and `other` equal `x2`.
1162
1142
- an array containing the element-wise results. The returned array must have a data type determined by {ref}`type-promotion`.
1163
1143
1164
1144
```{note}
1165
-
1166
1145
Element-wise results must equal the results returned by the equivalent element-wise function [`divide(x1, x2)`](elementwise_functions.md#dividex1-x2-).
1167
1146
```
1168
1147
@@ -1188,6 +1167,5 @@ Evaluates `self_i ^ other_i` for each element of an array instance with the resp
1188
1167
- an array containing the element-wise results. The returned array must have a data type determined by {ref}`type-promotion`.
1189
1168
1190
1169
```{note}
1191
-
1192
1170
Element-wise results must equal the results returned by the equivalent element-wise function [`bitwise_xor(x1, x2)`](elementwise_functions.md#bitwise_xorx1-x2-).
0 commit comments