Skip to content

Commit fa99036

Browse files
asmeurerkgryte
andauthored
Clarify guidance regarding non-boolean input array dtypes in the logical_* functions (#251)
* Clarify some text in the logical_* functions Only boolean data types are required in these functions, so the zero-nonzero bool equivalence is only for implementations that choose to implement non-boolean inputs. * Move clarifications to notes Co-authored-by: Athan <kgryte@gmail.com>
1 parent 38bbea7 commit fa99036

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

spec/API_specification/elementwise_functions.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,11 @@ For floating-point operands,
968968
(function-logical_and)=
969969
### logical_and(x1, x2, /)
970970

971-
Computes the logical AND for each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`. Zeros are considered the equivalent of `False`, while non-zeros are considered the equivalent of `True`.
971+
Computes the logical AND for each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`.
972+
973+
```{note}
974+
While this specification recommends that this function only accept input arrays having a boolean data type, specification-compliant array libraries may choose to accept input arrays having numeric data types. If non-boolean data types are supported, zeros must be considered the equivalent of `False`, while non-zeros must be considered the equivalent of `True`.
975+
```
972976

973977
#### Parameters
974978

@@ -989,7 +993,11 @@ Computes the logical AND for each element `x1_i` of the input array `x1` with th
989993
(function-logical_not)=
990994
### logical_not(x, /)
991995

992-
Computes the logical NOT for each element `x_i` of the input array `x`. Zeros are considered the equivalent of `False`, while non-zeros are considered the equivalent of `True`.
996+
Computes the logical NOT for each element `x_i` of the input array `x`.
997+
998+
```{note}
999+
While this specification recommends that this function only accept input arrays having a boolean data type, specification-compliant array libraries may choose to accept input arrays having numeric data types. If non-boolean data types are supported, zeros must be considered the equivalent of `False`, while non-zeros must be considered the equivalent of `True`.
1000+
```
9931001

9941002
#### Parameters
9951003

@@ -1006,7 +1014,11 @@ Computes the logical NOT for each element `x_i` of the input array `x`. Zeros ar
10061014
(function-logical_or)=
10071015
### logical_or(x1, x2, /)
10081016

1009-
Computes the logical OR for each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`. Zeros are considered the equivalent of `False`, while non-zeros are considered the equivalent of `True`.
1017+
Computes the logical OR for each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`.
1018+
1019+
```{note}
1020+
While this specification recommends that this function only accept input arrays having a boolean data type, specification-compliant array libraries may choose to accept input arrays having numeric data types. If non-boolean data types are supported, zeros must be considered the equivalent of `False`, while non-zeros must be considered the equivalent of `True`.
1021+
```
10101022

10111023
#### Parameters
10121024

@@ -1027,7 +1039,11 @@ Computes the logical OR for each element `x1_i` of the input array `x1` with the
10271039
(function-logical_xor)=
10281040
### logical_xor(x1, x2, /)
10291041

1030-
Computes the logical XOR for each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`. Zeros are considered the equivalent of `False`, while non-zeros are considered the equivalent of `True`.
1042+
Computes the logical XOR for each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`.
1043+
1044+
```{note}
1045+
While this specification recommends that this function only accept input arrays having a boolean data type, specification-compliant array libraries may choose to accept input arrays having numeric data types. If non-boolean data types are supported, zeros must be considered the equivalent of `False`, while non-zeros must be considered the equivalent of `True`.
1046+
```
10311047

10321048
#### Parameters
10331049

0 commit comments

Comments
 (0)