🧪 testax
testax provides runtime assertions for JAX through the testing interface familiar to NumPy users.
>>> import jax
>>> from jax import numpy as jnp
>>> import testax
>>>
>>> def safe_log(x):
... testax.assert_array_less(0, x)
... return jnp.log(x)
>>>
>>> safe_log(jnp.arange(2))
Traceback (most recent call last):
...
jax._src.checkify.JaxRuntimeError:
Arrays are not less-ordered
<BLANKLINE>
Mismatched elements: 1 / 2 (50%)
Max absolute difference: 1
Max relative difference: 1
x: Array(0, dtype=int32, weak_type=True)
y: Array([0, 1], dtype=int32)
testax assertions are jit-able, although errors need to be functionalized to conform to JAX’s requirement that functions are pure and do not have side effects (see the checkify guide for details). In short, a checkify-d function returns a tuple (error, value). The first element is an error that may have occurred, and the second is the return value of the original function.
>>> jitted = jax.jit(safe_log)
>>> checkified = testax.checkify(jitted)
>>> error, y = checkified(jnp.arange(2))
>>> error.throw()
Traceback (most recent call last):
...
jax._src.checkify.JaxRuntimeError:
Arrays are not less-ordered
<BLANKLINE>
Mismatched elements: 1 / 2 (50%)
Max absolute difference: 1
Max relative difference: 1
x: Array(0, dtype=int32, weak_type=True)
y: Array([0, 1], dtype=int32)
>>> y
Array([-inf, 0.], dtype=float32)
Installation
testax is pip-installable and can be installed by running
pip install testax
Interface
testax mirrors the testing interface familiar to NumPy users, such as assert_allclose.
Metadata
Release files for testax 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| testax-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for testax-0.2.0-py3-none-any.whl |
Release files / testax-0.2.0-py3-none-any.whl
| Download URL | testax-0.2.0-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bb12effbaf68a5b650e8d832bda3606dbe18c4e63aa67e2948ef4e6ea5167990
|
|
BLAKE2b-256 checksum How to use checksums |
7f3226900c5e740fb82564716b82d589ffb43803be2d5058f2902f26ff924281
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.9
|
Security for testax 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.