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/set_functions.md
+29-2Lines changed: 29 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,17 @@ The shapes of two of the output arrays for this function depend on the data valu
23
23
24
24
Returns the unique elements of an input array `x`.
25
25
26
+
```{note}
27
+
Uniqueness should be determined based on value equality (i.e., `x_i == x_j`). For input arrays having floating-point data types, value-based equality implies the following behavior.
28
+
29
+
- As `nan` values compare as `False`, `nan` values should be considered distinct.
30
+
- As `-0` and `+0` compare as `True`, signed zeros should not be considered distinct, and the corresponding unique element will be implementation-dependent (e.g., an implementation could choose to return `-0` if `-0` occurs before `+0`).
31
+
32
+
As signed zeros are not distinct, using `inverse_indices` to reconstruct the input array is not guaranteed to return an array having the exact same values.
33
+
34
+
Each `nan` value should have a count of one, while the counts for signed zeros should be aggregated as a single count.
35
+
```
36
+
26
37
#### Parameters
27
38
28
39
-**x**: _<array>_
@@ -47,14 +58,23 @@ Returns the unique elements of an input array `x`.
47
58
(function-unique-inverse)=
48
59
### unique_inverse(x, /)
49
60
50
-
Returns the unique elements of an input array `x` and the indices from the set of unique elements that reconstruct `x`.
51
-
52
61
:::{admonition} Data-dependent output shape
53
62
:class: important
54
63
55
64
The shape of one of the output arrays for this function depends on the data values in the input array; hence, array libraries which build computation graphs (e.g., JAX, Dask, etc.) may find this function difficult to implement without knowing array values. Accordingly, such libraries may choose to omit this function. See {ref}`data-dependent-output-shapes` section for more details.
56
65
:::
57
66
67
+
Returns the unique elements of an input array `x` and the indices from the set of unique elements that reconstruct `x`.
68
+
69
+
```{note}
70
+
Uniqueness should be determined based on value equality (i.e., `x_i == x_j`). For input arrays having floating-point data types, value-based equality implies the following behavior.
71
+
72
+
- As `nan` values compare as `False`, `nan` values should be considered distinct.
73
+
- As `-0` and `+0` compare as `True`, signed zeros should not be considered distinct, and the corresponding unique element will be implementation-dependent (e.g., an implementation could choose to return `-0` if `-0` occurs before `+0`).
74
+
75
+
As signed zeros are not distinct, using `inverse_indices` to reconstruct the input array is not guaranteed to return an array having the exact same values.
76
+
```
77
+
58
78
#### Parameters
59
79
60
80
-**x**: _<array>_
@@ -85,6 +105,13 @@ The shape of the output array for this function depends on the data values in th
85
105
86
106
Returns the unique elements of an input array `x`.
87
107
108
+
```{note}
109
+
Uniqueness should be determined based on value equality (i.e., `x_i == x_j`). For input arrays having floating-point data types, value-based equality implies the following behavior.
110
+
111
+
- As `nan` values compare as `False`, `nan` values should be considered distinct.
112
+
- As `-0` and `+0` compare as `True`, signed zeros should not be considered distinct, and the corresponding unique element will be implementation-dependent (e.g., an implementation could choose to return `-0` if `-0` occurs before `+0`).
0 commit comments