Skip to content

Commit af5ad37

Browse files
Switch to readthedocs (#4)
1 parent bd94b71 commit af5ad37

File tree

2 files changed

+33
-23
lines changed

2 files changed

+33
-23
lines changed

.readthedocs.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
build:
3+
os: "ubuntu-22.04"
4+
commands:
5+
- curl -fsSL https://pixi.sh/install.sh | bash
6+
- chmod +x ~/.pixi/bin/pixi
7+
- ~/.pixi/bin/pixi run -e docs postinstall
8+
- ~/.pixi/bin/pixi run -e docs docs
9+
- mkdir -p $READTHEDOCS_OUTPUT/html/
10+
- cp -r docs/_build/html/** $READTHEDOCS_OUTPUT/html/

README.md

+23-23
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
[![CI](https://img.shields.io/github/actions/workflow/status/quantco/ndonnx/ci.yml?style=flat-square&branch=main)](https://github.com/quantco/ndonnx/actions/workflows/ci.yml)
44
[![Documentation](https://readthedocs.org/projects/ndonnx/badge/?version=latest)](https://ndonnx.readthedocs.io/en/latest/?badge=latest)
5-
[![conda-forge](https://img.shields.io/conda/pn/conda-forge/ndonnx?style=flat-square&logoColor=white&logo=conda-forge)](https://prefix.dev/channels/conda-forge/packages/ndonnx)
5+
[![conda-forge](https://img.shields.io/conda/vn/conda-forge/ndonnx?style=flat-square&logoColor=white&logo=conda-forge)](https://anaconda.org/conda-forge/ndonnx)
6+
[![pypi](https://img.shields.io/pypi/v/ndonnx.svg?logo=pypi&logoColor=white)](https://pypi.org/project/ndonnx)
67

78
An ONNX-backed array library that is compliant with the [Array API](https://data-apis.org/array-api/) standard.
89

@@ -53,46 +54,45 @@ It has a couple of key features:
5354
xp = a.__array_namespace__()
5455
return xp.mean(a[(low < a) & (a < high)])
5556

56-
arr = [-12.12, 1.12, 2.12, 2.13, 123.,]
57+
np_result = mean_drop_outliers(npx.asarray([-10, 0.5, 1, 5]))
58+
jax_result = mean_drop_outliers(jxp.asarray([-10, 0.5, 1, 5]))
59+
onnx_result = mean_drop_outliers(ndx.asarray([-10, 0.5, 1, 5]))
5760

58-
np_result = mean_drop_outliers(npx.asarray(arr))
59-
jax_result = mean_drop_outliers(jxp.asarray(arr))
60-
ndx_result = mean_drop_outliers(ndx.asarray(arr))
61-
print(np_result) # 1.79
62-
print(jax_result) # 1.79
63-
print(ndx_result) # Array(1.79, dtype=ndx.Float64)
64-
assert np_result == ndx_result.to_numpy()
61+
assert np_result == onnx_result.to_numpy() == jax_result == 0.75
6562
```
6663

67-
- It supports ONNX export. This allows you persist your logic into an ONNX computation graph for convenient and performant inference.
64+
- It supports ONNX export. This allows you persist your logic into an ONNX computation graph.
6865

6966
```python
70-
import onnx
7167
import ndonnx as ndx
68+
import onnx
69+
70+
# Instantiate placeholder ndonnx array
71+
x = ndx.array(shape=("N",), dtype=ndx.float32)
72+
y = mean_drop_outliers(x)
7273

73-
a = ndx.array(shape=("N",), dtype=ndx.float64)
74-
b = ndx.array(shape=("N",), dtype=ndx.float64)
75-
out = a[:2] + b[:2]
76-
model_proto = ndx.build({"a": a, "b": b}, {"c": out})
77-
onnx.save(model_proto, "model.onnx")
74+
# Build and save ONNX model to disk
75+
model = ndx.build({"x": x}, {"y": y})
76+
onnx.save(model, "mean_drop_outliers.onnx")
77+
```
78+
79+
You can then make predictions using a runtime of your choice.
7880

79-
# Having serialised your model to disk, perform
80-
# inference using a runtime of your choosing.
81+
```python
8182
import onnxruntime as ort
8283
import numpy as np
83-
inference_session = ort.InferenceSession("model.onnx")
84+
inference_session = ort.InferenceSession("mean_drop_outliers.onnx")
8485
prediction, = inference_session.run(None, {
85-
"a": np.array([1, 2, 3], dtype=np.float64),
86-
"b": np.array([4, 5, 6], dtype=np.float64),
86+
"x": np.array([-10, 0.5, 1, 5], dtype=np.float32),
8787
})
88-
print(prediction) # array([5., 7.])
88+
assert prediction == 0.75
8989
```
9090

9191
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.
9292

9393
## Array API coverage
9494

95-
Array API compatibility is tracked in the array-api coverage test suite in `api-coverage-tests`. Missing coverage is tracked in the `skips.txt` file. Contributions are welcome!
95+
Array API compatibility is tracked in `api-coverage-tests`. Missing coverage is tracked in the `skips.txt` file. Contributions are welcome!
9696

9797
Summary(1119 total):
9898

0 commit comments

Comments
 (0)