Name | ndonnx JSON |
Version |
0.14.0
JSON |
| download |
home_page | None |
Summary | ONNX backed array library compliant with Array API standard. |
upload_time | 2025-07-21 21:45:11 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | None |
keywords |
numpy
onnx
array-api
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# ndonnx
[](https://github.com/quantco/ndonnx/actions/workflows/ci.yml)
[](https://ndonnx.readthedocs.io/en/latest/?badge=latest)
[](https://anaconda.org/conda-forge/ndonnx)
[](https://pypi.org/project/ndonnx)
An ONNX-backed array library that is compliant with the [Array API](https://data-apis.org/array-api/) standard.
## Installation
Releases are available on PyPI and conda-forge.
```bash
# using pip
pip install ndonnx
# using conda
conda install ndonnx
# using pixi
pixi add ndonnx
```
## Development
You can install the package in development mode using:
```bash
git clone https://github.com/quantco/ndonnx
cd ndonnx
# For Array API tests
git submodule update --init --recursive
pixi shell
pre-commit run -a
pip install --no-build-isolation --no-deps -e .
pytest tests -n auto
```
## Quick start
`ndonnx` is an ONNX based python array library.
It has a couple of key features:
- It implements the [`Array API`](https://data-apis.org/array-api/) standard. Standard compliant code can be executed without changes across numerous backends such as like NumPy, JAX and now ndonnx.
```python
import numpy as np
import ndonnx as ndx
import jax.numpy as jnp
def mean_drop_outliers(a, low=-5, high=5):
xp = a.__array_namespace__()
return xp.mean(a[(low < a) & (a < high)])
np_result = mean_drop_outliers(np.asarray([-10, 0.5, 1, 5]))
jax_result = mean_drop_outliers(jnp.asarray([-10, 0.5, 1, 5]))
onnx_result = mean_drop_outliers(ndx.asarray([-10, 0.5, 1, 5]))
assert np_result == onnx_result.to_numpy() == jax_result == 0.75
```
- It supports ONNX export. This allows you persist your logic into an ONNX computation graph.
```python
import ndonnx as ndx
import onnx
# Instantiate placeholder ndonnx array
x = ndx.array(shape=("N",), dtype=ndx.float32)
y = mean_drop_outliers(x)
# Build and save ONNX model to disk
model = ndx.build({"x": x}, {"y": y})
onnx.save(model, "mean_drop_outliers.onnx")
```
You can then make predictions using a runtime of your choice.
```python
import onnxruntime as ort
import numpy as np
inference_session = ort.InferenceSession("mean_drop_outliers.onnx")
prediction, = inference_session.run(None, {
"x": np.array([-10, 0.5, 1, 5], dtype=np.float32),
})
assert prediction == 0.75
```
In the future we will be enabling a stable API for an extensible data type system. This will allow users to define their own data types and operations on arrays with these data types.
## Array API coverage
Array API compatibility tested against the official `array-api-tests` suite.
Missing coverage is tracked in the `skips.txt` file.
Contributions are welcome!
Run the tests with:
```bash
pixi run arrayapitests
```
Raw data
{
"_id": null,
"home_page": null,
"name": "ndonnx",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "numpy, onnx, array-api",
"author": null,
"author_email": "Aditya Goel <agoel4512@gmail.com>, Christian Bourjau <christian.bourjau@quantco.com>",
"download_url": "https://files.pythonhosted.org/packages/ca/f5/407f1f676fd8df5753fd458b95c5b59893b9717d5a5a60668d65d12b4edb/ndonnx-0.14.0.tar.gz",
"platform": null,
"description": "# ndonnx\n\n[](https://github.com/quantco/ndonnx/actions/workflows/ci.yml)\n[](https://ndonnx.readthedocs.io/en/latest/?badge=latest)\n[](https://anaconda.org/conda-forge/ndonnx)\n[](https://pypi.org/project/ndonnx)\n\nAn ONNX-backed array library that is compliant with the [Array API](https://data-apis.org/array-api/) standard.\n\n## Installation\n\nReleases are available on PyPI and conda-forge.\n\n```bash\n# using pip\npip install ndonnx\n# using conda\nconda install ndonnx\n# using pixi\npixi add ndonnx\n```\n\n## Development\n\nYou can install the package in development mode using:\n\n```bash\ngit clone https://github.com/quantco/ndonnx\ncd ndonnx\n\n# For Array API tests\ngit submodule update --init --recursive\n\npixi shell\npre-commit run -a\npip install --no-build-isolation --no-deps -e .\npytest tests -n auto\n```\n\n## Quick start\n\n`ndonnx` is an ONNX based python array library.\n\nIt has a couple of key features:\n\n- It implements the [`Array API`](https://data-apis.org/array-api/) standard. Standard compliant code can be executed without changes across numerous backends such as like NumPy, JAX and now ndonnx.\n\n ```python\n import numpy as np\n import ndonnx as ndx\n import jax.numpy as jnp\n\n def mean_drop_outliers(a, low=-5, high=5):\n xp = a.__array_namespace__()\n return xp.mean(a[(low < a) & (a < high)])\n\n np_result = mean_drop_outliers(np.asarray([-10, 0.5, 1, 5]))\n jax_result = mean_drop_outliers(jnp.asarray([-10, 0.5, 1, 5]))\n onnx_result = mean_drop_outliers(ndx.asarray([-10, 0.5, 1, 5]))\n\n assert np_result == onnx_result.to_numpy() == jax_result == 0.75\n ```\n\n- It supports ONNX export. This allows you persist your logic into an ONNX computation graph.\n\n ```python\n import ndonnx as ndx\n import onnx\n\n # Instantiate placeholder ndonnx array\n x = ndx.array(shape=(\"N\",), dtype=ndx.float32)\n y = mean_drop_outliers(x)\n\n # Build and save ONNX model to disk\n model = ndx.build({\"x\": x}, {\"y\": y})\n onnx.save(model, \"mean_drop_outliers.onnx\")\n ```\n\n You can then make predictions using a runtime of your choice.\n\n ```python\n import onnxruntime as ort\n import numpy as np\n\n inference_session = ort.InferenceSession(\"mean_drop_outliers.onnx\")\n prediction, = inference_session.run(None, {\n \"x\": np.array([-10, 0.5, 1, 5], dtype=np.float32),\n })\n assert prediction == 0.75\n ```\n\nIn the future we will be enabling a stable API for an extensible data type system. This will allow users to define their own data types and operations on arrays with these data types.\n\n## Array API coverage\n\nArray API compatibility tested against the official `array-api-tests` suite.\nMissing coverage is tracked in the `skips.txt` file.\nContributions are welcome!\n\nRun the tests with:\n\n```bash\npixi run arrayapitests\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "ONNX backed array library compliant with Array API standard.",
"version": "0.14.0",
"project_urls": {
"repository": "https://github.com/quantco/ndonnx"
},
"split_keywords": [
"numpy",
" onnx",
" array-api"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "47e98a0841444eebd89bdbb3a5412df9ddc9eef534fab5a8ad29bfedc88f5dff",
"md5": "58a6a67cccdd5aa28bb562121b14c84b",
"sha256": "b13e18211297fd416da345513761783629b4133ce060534451cb5c7291d40fbe"
},
"downloads": -1,
"filename": "ndonnx-0.14.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "58a6a67cccdd5aa28bb562121b14c84b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 80879,
"upload_time": "2025-07-21T21:45:10",
"upload_time_iso_8601": "2025-07-21T21:45:10.526697Z",
"url": "https://files.pythonhosted.org/packages/47/e9/8a0841444eebd89bdbb3a5412df9ddc9eef534fab5a8ad29bfedc88f5dff/ndonnx-0.14.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "caf5407f1f676fd8df5753fd458b95c5b59893b9717d5a5a60668d65d12b4edb",
"md5": "5cfa64edd30d1eb70a59c8ee6dc8e267",
"sha256": "f491c01a541a4299b7f4aeac9173327fff55252f69e94e4371025fa5d11392b1"
},
"downloads": -1,
"filename": "ndonnx-0.14.0.tar.gz",
"has_sig": false,
"md5_digest": "5cfa64edd30d1eb70a59c8ee6dc8e267",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 346752,
"upload_time": "2025-07-21T21:45:11",
"upload_time_iso_8601": "2025-07-21T21:45:11.860577Z",
"url": "https://files.pythonhosted.org/packages/ca/f5/407f1f676fd8df5753fd458b95c5b59893b9717d5a5a60668d65d12b4edb/ndonnx-0.14.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-21 21:45:11",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "quantco",
"github_project": "ndonnx",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "ndonnx"
}