diff --git a/spec/API_specification/array_object.md b/spec/API_specification/array_object.md index 66418395e..3779b250a 100644 --- a/spec/API_specification/array_object.md +++ b/spec/API_specification/array_object.md @@ -377,6 +377,29 @@ Evaluates `x1_i & x2_i` for each element `x1_i` of an array instance `x1` with t Element-wise results must equal the results returned by the equivalent element-wise function [`bitwise_and(x1, x2)`](elementwise_functions.md#logical_andx1-x2-). ``` + +(method-__array_namespace__)= +### \_\_array_namespace\_\_(self, /, *, api_version=None) + +Returns an object that has all the array API functions on it. + +#### Parameters + +- **self**: _<array>_ + + - array instance. + +- **api_version**: _<Optional\[str\]>_ + + - string representing the version of the array API specification to be returned, in `'YYYY.MM'` form, for example, `'2020.10'`. If it is `None`, it should return the namespace corresponding to latest version of the array API specification. If the given version is invalid or not implemented for the given module, an error should be raised. Default: `None`. + +#### Returns + +- **out**: _<object>_ + + - an object representing the array API namespace. It should have every top-level function defined in the specification as an attribute. It may contain other public names as well, but it is recommended to only include those names that are part of the specification. + + (method-__bool__)= ### \_\_bool\_\_(x, /) diff --git a/spec/purpose_and_scope.md b/spec/purpose_and_scope.md index 17eb6020a..a8fb596c6 100644 --- a/spec/purpose_and_scope.md +++ b/spec/purpose_and_scope.md @@ -335,7 +335,8 @@ namespace (e.g. `import package_name.array_api`). This has two issues though: {ref}`api-versioning`). To address both issues, a uniform way must be provided by a conforming -implementation to access the API namespace, namely a method on the array object: +implementation to access the API namespace, namely a [method on the array +object](method-__array_namespace__): ``` xp = x.__array_namespace__() @@ -362,11 +363,10 @@ standard can become final. We prefer to delay this decision, to see how NEP 37 adoption will work out. ``` -The `xp` namespace must contain the array object and all functionality -specified in {ref}`api-specification`. It may contain other functionality, -however it is recommended not to add other functions or objects, because that -may make it harder for users to write code that will work with multiple array -libraries. +The `xp` namespace must contain all functionality specified in +{ref}`api-specification`. It may contain other functionality, however it is +recommended not to add other functions or objects, because that may make it +harder for users to write code that will work with multiple array libraries. * * *