### Install array-api-compat using pip Source: https://github.com/data-apis/array-api-compat/blob/main/docs/index.md Install the library using pip for use in your Python environment. ```bash python -m pip install array-api-compat ``` -------------------------------- ### Install array-api-compat using conda Source: https://github.com/data-apis/array-api-compat/blob/main/docs/index.md Install the library using conda-forge for use in your conda environment. ```bash conda install --channel conda-forge array-api-compat ``` -------------------------------- ### Get Array API namespace Source: https://github.com/data-apis/array-api-compat/blob/main/docs/index.md Obtain the array API compliant namespace for input arrays to use with array library functions. ```python import array_api_compat def your_function(x, y): xp = array_api_compat.array_namespace(x, y) # Now use xp as the array library namespace return xp.mean(x, axis=0) + 2*xp.std(y, axis=0) ``` -------------------------------- ### Vendor array-api-compat library Source: https://github.com/data-apis/array-api-compat/blob/main/docs/index.md Copy the library into your project for vendoring, allowing for custom naming. ```bash cp -R array_api_compat/ mylib/vendored/array_api_compat ``` -------------------------------- ### Create Release Tag Source: https://github.com/data-apis/array-api-compat/blob/main/docs/dev/releasing.md Create an annotated Git tag for the release. Tag names are not prefixed with version numbers. ```shell git tag -a ``` -------------------------------- ### Test CuPy Source: https://github.com/data-apis/array-api-compat/blob/main/docs/dev/releasing.md Run the CuPy test script on a machine with a CUDA GPU. This is a manual step as it is not covered by CI. ```shell ./test_cupy.sh ``` -------------------------------- ### Import PyTorch compatible namespace Source: https://github.com/data-apis/array-api-compat/blob/main/docs/index.md Import the PyTorch-compatible namespace from the array-api-compat library. ```python import array_api_compat.torch as torch ``` -------------------------------- ### Import CuPy compatible namespace Source: https://github.com/data-apis/array-api-compat/blob/main/docs/index.md Import the CuPy-compatible namespace from the array-api-compat library. ```python import array_api_compat.cupy as cp ``` -------------------------------- ### Import Dask compatible namespace Source: https://github.com/data-apis/array-api-compat/blob/main/docs/index.md Import the Dask-compatible namespace from the array-api-compat library. ```python import array_api_compat.dask as da ``` -------------------------------- ### Import NumPy compatible namespace Source: https://github.com/data-apis/array-api-compat/blob/main/docs/index.md Import the NumPy-compatible namespace from the array-api-compat library. ```python import array_api_compat.numpy as np ``` -------------------------------- ### Referencing Other Wrapped Functions Source: https://github.com/data-apis/array-api-compat/blob/main/docs/dev/implementation-notes.md Demonstrates how to call another wrapped function by first obtaining the array namespace using `array_namespace`. ```python wrapped_xp = array_namespace(x) wrapped_xp.wrapped_func(...) ``` -------------------------------- ### Push Release Tag Source: https://github.com/data-apis/array-api-compat/blob/main/docs/dev/releasing.md Push the created tag to GitHub. This action automatically triggers the build and publish process for the release. ```shell git push origin ``` -------------------------------- ### Common Wrapper Implementation Source: https://github.com/data-apis/array-api-compat/blob/main/docs/dev/implementation-notes.md Defines a shared wrapper function in the common module that accepts an array namespace (`xp`) as an argument. ```python # In array_api_compat/common/_aliases.py def acos(x, /, xp): return xp.arccos(x) ``` -------------------------------- ### CuPy Specific Wrapper with Decorator Source: https://github.com/data-apis/array-api-compat/blob/main/docs/dev/implementation-notes.md Applies the `@get_xp` decorator to a common wrapper function to automatically inject the CuPy namespace. ```python # In array_api_compat/cupy/_aliases.py from ..common import _aliases import cupy as cp acos = get_xp(cp)(_aliases.acos) ``` -------------------------------- ### NumPy Specific Wrapper with Decorator Source: https://github.com/data-apis/array-api-compat/blob/main/docs/dev/implementation-notes.md Applies the `@get_xp` decorator to a common wrapper function to automatically inject the NumPy namespace. ```python # In array_api_compat/numpy/_aliases.py from ..common import _aliases import numpy as np acos = get_xp(np)(_aliases.acos) ``` -------------------------------- ### Merge Release Branch into Main Source: https://github.com/data-apis/array-api-compat/blob/main/docs/dev/releasing.md Ensure the release branch is fully synchronized with the main branch before proceeding. ```shell git checkout main git pull git checkout release git merge main ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.