Skip to content

Commit be9f4b4

Browse files
committed
Require __pow__ and __truediv__ to have floating-point inputs
Previously it was any numeric dtype, but this was inconsistent with the functions pow() and divide(). Integer inputs are problematic because they would either always have to be cast to float or use value-based casting depending on, e.g., the sign of the exponent for __pow__. Furthermore, in order to properly correspond to Python conventions, __truediv__ should always return a float (integer division should be implemented by __floordiv__). This was discussed in data-apis#173.
1 parent e14d9a7 commit be9f4b4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

spec/API_specification/array_object.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ The `matmul` function must implement the same semantics as the built-in `@` oper
780780

781781
- **self**: _<array>_
782782

783-
- array instance. Should have a numeric data type. Must have at least one dimension. If `self` is one-dimensional having shape `(M)` and `other` has more than one dimension, `self` must be promoted to a two-dimensional array by prepending `1` to its dimensions (i.e., must have shape `(1, M)`). After matrix multiplication, the prepended dimensions in the returned array must be removed. If `self` has more than one dimension (including after vector-to-matrix promotion), `self` must be compatible with `other` (see {ref}`broadcasting`). If `self` has shape `(..., M, K)`, the innermost two dimensions form matrices on which to perform matrix multiplication.
783+
- array instance. Should have a numeric data type. Must have at least one dimension. If `self` is one-dimensional having shape `(M)` and `other` has more than one dimension, `self` must be promoted to a two-dimensional array by prepending `1` to its dimensions (i.e., must have shape `(1, M)`). After matrix multiplication, the prepended dimensions in the returned array must be removed. If `self` has more than one dimension (including after vector-to-matrix promotion), `self` must be compatible with `other` (see {ref}`broadcasting`). If `self` has shape `(..., M, K)`, the innermost two dimensions form matrices on which to perform matrix multiplication.
784784

785785
- **other**: _<array>_
786786

@@ -809,7 +809,7 @@ The `matmul` function must implement the same semantics as the built-in `@` oper
809809
810810
- if either `self` or `other` is a zero-dimensional array.
811811
- if `self` is a one-dimensional array having shape `(N)`, `other` is a one-dimensional array having shape `(M)`, and `N != M`.
812-
- if `self` is an array having shape `(..., M, K)`, `other` is an array having shape `(..., L, N)`, and `K != L`.
812+
- if `self` is an array having shape `(..., M, K)`, `other` is an array having shape `(..., L, N)`, and `K != L`.
813813
814814
(method-__mod__)=
815815
### \_\_mod\_\_(self, other, /)
@@ -1016,11 +1016,11 @@ For floating-point operands, let `self` equal `x1` and `other` equal `x2`.
10161016

10171017
- **self**: _<array>_
10181018

1019-
- array instance whose elements correspond to the exponentiation base. Should have a numeric data type.
1019+
- array instance whose elements correspond to the exponentiation base. Should have a floating-point data type.
10201020

10211021
- **other**: _Union\[ int, float, <array> ]_
10221022

1023-
- other array whose elements correspond to the exponentiation exponent. Must be compatible with `self` (see {ref}`broadcasting`). Should have a numeric data type.
1023+
- other array whose elements correspond to the exponentiation exponent. Must be compatible with `self` (see {ref}`broadcasting`). Should have a floating-point data type.
10241024

10251025
#### Returns
10261026

@@ -1149,11 +1149,11 @@ For floating-point operands, let `self` equal `x1` and `other` equal `x2`.
11491149

11501150
- **self**: _<array>_
11511151

1152-
- array instance. Should have a numeric data type.
1152+
- array instance. Should have a floating-point data type.
11531153

11541154
- **other**: _Union\[ int, float, <array> ]_
11551155

1156-
- other array. Must be compatible with `self` (see {ref}`broadcasting`). Should have a numeric data type.
1156+
- other array. Must be compatible with `self` (see {ref}`broadcasting`). Should have a floating-point data type.
11571157

11581158
#### Returns
11591159

0 commit comments

Comments
 (0)