Skip to content

Commit 2783a15

Browse files
committed
Small cleanups to implementation notes
1 parent e328261 commit 2783a15

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

docs/dev/implementation-notes.md

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,32 +39,34 @@ should be taken into account:
3939
array-api-compat. The addition of functions that are not part of the array
4040
API standard is currently out-of-scope for this package.
4141

42-
- *No side-effects*. array_api_compat behavior should be localized to only the
42+
- *No Side-effects*. array-api-compat behavior should be localized to only the
4343
specific code that imports and uses it. It should be invisible to end-users
44-
or users of dependent codes. This specifically applies to the next two
44+
or users of dependent codes. This in particular implies to the next two
4545
points.
4646

4747
- *No Monkey Patching.* `array-api-compat` should not attempt to modify
4848
anything about the underlying library. It is a *wrapper* library only.
4949

50-
- *No modifying the array object.* The array (or tensor) object of the array
51-
library cannot be modified. Attempting to wrap or subclass a library's array
52-
object would break the localized wrapping goal.
50+
- *No Modifying the Array Object.* The array (or tensor) object of the array
51+
library cannot be modified. This also precludes the creation of array
52+
subclasses or wrapper classes.
5353

5454
Any behavior that is built-in to the array object, such as the behavior of
5555
[array
56-
methods](https://data-apis.org/array-api/latest/API_specification/array_object.html)
56+
methods](https://data-apis.org/array-api/latest/API_specification/array_object.html),
5757
is therefore left unwrapped. Users can workaround issues by using
5858
corresponding [elementwise
5959
functions](https://data-apis.org/array-api/latest/API_specification/elementwise_functions.html)
60-
instead of operators, and using the [helper
61-
functions](../helper-functions.md) provided by array-api-compat instead of
62-
methods like `to_device`.
60+
instead of
61+
[operators](https://data-apis.org/array-api/latest/API_specification/array_object.html#operators),
62+
and by using the [helper functions](../helper-functions.md) provided by
63+
array-api-compat instead of attributes or methods like `x.to_device()`.
6364

64-
- *Avoid Restricting Behavior Outside the Scope of the Standard.* All array
65-
libraries have functions and behaviors that are outside of the scope of what
66-
is specified by the standard. These behaviors should be left intact whenever
67-
possible, unless the standard explicitly disallows something. This means
65+
- *Avoid Restricting Behavior that is Outside the Scope of the Standard.* All
66+
array libraries have functions and behaviors that are outside of the scope
67+
of what is specified by the standard. These behaviors should be left intact
68+
whenever possible, unless the standard explicitly disallows something. This
69+
means
6870

6971
- All namespaces are *extended* with wrapper functions. You may notice the
7072
extensive use of `import *` in various files in `array_api_compat`. While
@@ -74,8 +76,16 @@ should be taken into account:
7476

7577
- All wrapper functions pass `**kwargs` through to the wrapped function.
7678

77-
The onus is on users of array-api-compat to ensure they are only using
78-
portable array API behavior, e.g., by testing against [array-api-strict](array-api-strict).
79+
- Input types not supported by the standard should work if they work in the
80+
underlying wrapped function (for instance, Python scalars or `np.ndarray`
81+
subclasses).
82+
83+
By keeping underlying behaviors intact, it is easier for libraries to swap
84+
out NumPy or other array libraries for array-api-compat, and it is easier
85+
for libraries to write array library-specific code paths.
86+
87+
The onus is on users of array-api-compat to ensure their array API code is
88+
portable, e.g., by testing against [array-api-strict](array-api-strict).
7989

8090

8191
## Avoiding Code Duplication

0 commit comments

Comments
 (0)