Skip to content

Commit bb5da85

Browse files
committed
Add an example to the get_namespace docstring
1 parent 5ff7366 commit bb5da85

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

array_api_compat/common/_helpers.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ def get_namespace(*xs, _use_compat=True):
5454
Get the array API compatible namespace for the arrays `xs`.
5555
5656
`xs` should contain one or more arrays.
57+
58+
Typical usage is
59+
60+
def your_function(x, y):
61+
xp = array_api_compat.get_namespace(x, y)
62+
# Now use xp as the array library namespace
63+
return xp.mean(x, axis=0) + 2*xp.std(y, axis=0)
5764
"""
5865
namespaces = set()
5966
for x in xs:

0 commit comments

Comments
 (0)