Skip to content

Commit f4fb0f2

Browse files
authored
Update guidance for pow and divide concerning arrays with integer dtypes (#330)
1 parent 02fae2c commit f4fb0f2

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

spec/API_specification/array_object.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,12 @@ Element-wise results must equal the results returned by the equivalent element-w
10751075

10761076
Calculates an implementation-dependent approximation of exponentiation by raising each element (the base) of an array instance to the power of `other_i` (the exponent), where `other_i` is the corresponding element of the array `other`.
10771077

1078+
```{note}
1079+
If both `self` and `other` have integer data types, the result of `__pow__` when `other_i` is negative (i.e., less than zero) is unspecified and thus implementation-dependent.
1080+
1081+
If `self` has an integer data type and `other` has a floating-point data type, behavior is implementation-dependent (type promotion between data type "kinds" (integer versus floating-point) is unspecified).
1082+
```
1083+
10781084
#### Special Cases
10791085

10801086
For floating-point operands, let `self` equal `x1` and `other` equal `x2`.
@@ -1247,7 +1253,7 @@ For floating-point operands, let `self` equal `x1` and `other` equal `x2`.
12471253

12481254
- **out**: _<array>_
12491255

1250-
- an array containing the element-wise results. The returned array must have a data type determined by {ref}`type-promotion`.
1256+
- an array containing the element-wise results. The returned array should have a floating-point data type determined by {ref}`type-promotion`.
12511257

12521258
```{note}
12531259
Element-wise results must equal the results returned by the equivalent element-wise function [`divide(x1, x2)`](elementwise_functions.md#dividex1-x2-).

spec/API_specification/elementwise_functions.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -559,11 +559,11 @@ For floating-point operands,
559559

560560
- **x1**: _<array>_
561561

562-
- dividend input array. Should have a floating-point data type.
562+
- dividend input array. Should have a numeric data type.
563563

564564
- **x2**: _<array>_
565565

566-
- divisor input array. Must be compatible with `x1` (see {ref}`broadcasting`). Should have a floating-point data type.
566+
- divisor input array. Must be compatible with `x1` (see {ref}`broadcasting`). Should have a numeric data type.
567567

568568
#### Returns
569569

@@ -1183,6 +1183,12 @@ Computes the numerical positive of each element `x_i` (i.e., `y_i = +x_i`) of th
11831183

11841184
Calculates an implementation-dependent approximation of exponentiation by raising each element `x1_i` (the base) of the input array `x1` to the power of `x2_i` (the exponent), where `x2_i` is the corresponding element of the input array `x2`.
11851185

1186+
```{note}
1187+
If both `x1` and `x2` have integer data types, the result of `pow` when `x2_i` is negative (i.e., less than zero) is unspecified and thus implementation-dependent.
1188+
1189+
If `x1` has an integer data type and `x2` has a floating-point data type, behavior is implementation-dependent (type promotion between data type "kinds" (integer versus floating-point) is unspecified).
1190+
```
1191+
11861192
#### Special Cases
11871193

11881194
For floating-point operands,
@@ -1216,11 +1222,11 @@ For floating-point operands,
12161222

12171223
- **x1**: _<array>_
12181224

1219-
- first input array whose elements correspond to the exponentiation base. Should have a floating-point data type.
1225+
- first input array whose elements correspond to the exponentiation base. Should have a numeric data type.
12201226

12211227
- **x2**: _<array>_
12221228

1223-
- second input array whose elements correspond to the exponentiation exponent. Must be compatible with `x1` (see {ref}`broadcasting`). Should have a floating-point data type.
1229+
- second input array whose elements correspond to the exponentiation exponent. Must be compatible with `x1` (see {ref}`broadcasting`). Should have a numeric data type.
12241230

12251231
#### Returns
12261232

0 commit comments

Comments
 (0)