Download source/examples/fast_array_service.py from PureOne/Qyxo-Zhaenivoth-Guard: direct link, hf CLI and curl.
- Browser
- Download file 880 Bytes
-
https://huggingface.co/datasets/PureOne/Qyxo-Zhaenivoth-Guard/resolve/main/source/examples/fast_array_service.py
- Command line
-
hf download hf://datasets/PureOne/Qyxo-Zhaenivoth-Guard/source/examples/fast_array_service.py
-
curl -L -o fast_array_service.py https://huggingface.co/datasets/PureOne/Qyxo-Zhaenivoth-Guard/resolve/main/source/examples/fast_array_service.py
880 Bytes
| """Recommended performance-sensitive interface: already-existing real ndarrays. | |
| This is an integration example, not a benchmark or a production certificate. | |
| """ | |
| from pathlib import Path | |
| import sys | |
| sys.path.insert(0, str(Path(__file__).resolve().parents[1])) | |
| import numpy as np | |
| from qzguard import PreparedBank | |
| x = np.linspace(-1.0, 1.0, 4096, dtype=np.float64) | |
| values = np.column_stack((x, x + 0.25, x - 0.5, 2*x)) | |
| bank = PreparedBank(values - 0.01, values + 0.01, backend='filtered') | |
| threshold = np.array([-0.2, 0.05, -0.7, -0.4], dtype=np.float64) | |
| for step in range(3): | |
| lower = np.ones(len(x), dtype=np.float64) | |
| upper = lower * (1.1 + step * 0.05) | |
| result = bank.evaluate(lower, upper, threshold, relation='>=') | |
| assert result.all_guaranteed | |
| print({'step': step, 'backend': result.backend, | |
| 'guaranteed': result.guaranteed, 'modes': result.modes}) | |