@@ -39,32 +39,34 @@ should be taken into account:
39
39
array-api-compat. The addition of functions that are not part of the array
40
40
API standard is currently out-of-scope for this package.
41
41
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
43
43
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
45
45
points.
46
46
47
47
- * No Monkey Patching.* ` array-api-compat ` should not attempt to modify
48
48
anything about the underlying library. It is a * wrapper* library only.
49
49
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 .
53
53
54
54
Any behavior that is built-in to the array object, such as the behavior of
55
55
[ 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 ) ,
57
57
is therefore left unwrapped. Users can workaround issues by using
58
58
corresponding [ elementwise
59
59
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() ` .
63
64
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
68
70
69
71
- All namespaces are * extended* with wrapper functions. You may notice the
70
72
extensive use of ` import * ` in various files in ` array_api_compat ` . While
@@ -74,8 +76,16 @@ should be taken into account:
74
76
75
77
- All wrapper functions pass ` **kwargs ` through to the wrapped function.
76
78
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 ) .
79
89
80
90
81
91
## Avoiding Code Duplication
0 commit comments