Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

unxt-hypothesis

Hypothesis strategies for unxt - unitful quantities in JAX.

This package provides Hypothesis strategies for generating unxt objects for for property-based testing.

Installation

uv add unxt-hypothesis

Usage

from hypothesis import given

import unxt_hypothesis as ust


@given(q=ust.quantities(unit="km/s"))
def test_quantity_property(q):
    # Test some property of quantities
    assert q.value is not None
    assert q.unit is not None


@given(u=ust.units("length"))
def test_unit_property(u):
    # Test some property of units
    assert u is not None


@given(sys=ust.unitsystems("m", "s", "kg", "rad"))
def test_unitsystem_property(sys):
    # Test some property of unit systems
    assert len(sys) == 4

Custom strategies

You can customize the strategies:

from hypothesis import strategies as st

import unxt as u
import unxt_hypothesis as ust


# Generate quantities with specific shapes
@given(q=ust.quantities(unit="m", shape=st.just((3, 3))))
def test_matrix_quantity(q):
    assert q.shape == (3, 3)


# Generate quantities with specific dimensions
@given(q=ust.quantities(unit=ust.units("length")))
def test_length_quantity(q):
    assert u.dimension_of(q) == u.dimension("length")

API

quantities(draw, *, shape=None, dtype=None, unit=None)

Generate random Quantity objects.

Parameters:

  • draw: Hypothesis draw function
  • shape: Strategy for array shapes (optional, defaults to small arrays)
  • dtype: Strategy for array dtypes (optional, defaults to float32)
  • unit: Strategy for unit strings (optional, defaults to common units)

Returns: A unxt.Quantity instance

units(draw, dimension=None, *, max_complexity=2, allow_non_integer_powers=False)

Generate random Unit objects.

Parameters:

  • draw: Hypothesis draw function
  • dimension: Physical dimension (optional, e.g., "length", "velocity")
  • max_complexity: Maximum complexity of compound units (default: 2)
  • allow_non_integer_powers: Allow non-integer powers (default: False)

Returns: A unxt.AbstractUnit instance

unitsystems(*units)

Generate random UnitSystem objects.

Parameters:

  • *units: Variable number of unit specifications. Each can be:
    • str: Fixed unit string (e.g., "m", "kg")
    • unxt.AbstractUnit: Fixed unit object
    • Strategy: A Hypothesis strategy that generates units

Returns: A unxt.AbstractUnitSystem instance

Example:

from hypothesis import given

import unxt_hypothesis as ust


# Fixed unit system
@given(sys=ust.unitsystems("m", "s", "kg", "rad"))
def test_mks_system(sys):
    assert len(sys) == 4


# Varying length unit, other units fixed
@given(sys=ust.unitsystems(ust.units("length"), "s", "kg", "rad"))
def test_varying_length(sys):
    assert len(sys) == 4

Documentation

For comprehensive documentation, examples, and guides, see the unxt documentation.

License

BSD 3-Clause License. See LICENSE for details.

Contributing

Contributions are welcome! Please see the main unxt repository for contributing guidelines.

Metadata

Release files for unxt-hypothesis 0.1.dev410

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unxt-hypothesis 0.1.dev410
File Size Uploaded
unxt_hypothesis-0.1.dev410.tar.gz 20.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for unxt-hypothesis 0.1.dev410
File Interpreter ABI Platform
unxt_hypothesis-0.1.dev410-py3-none-any.whl Python 3 none any Details

Total release size: 29.8 kB

Release files / unxt_hypothesis-0.1.dev410.tar.gz

Download URL unxt_hypothesis-0.1.dev410.tar.gz
Size 20.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e5c30693907e2a789708a5aa1e207d2752a9c9e8ce6e47bef412207e9b4b5e82
BLAKE2b-256 checksum
How to use checksums
0eb6f5375eb83fa7cbcd10cc68252d4cd990fc1dffaf95113ce30e92c61c1378
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 20, 2025.

Transparency log

Release files / unxt_hypothesis-0.1.dev410-py3-none-any.whl

Download URL unxt_hypothesis-0.1.dev410-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fbdc06776fdf479e7971b1e39b1896aa81a218f8f07f17beeb112d96f6a167f0
BLAKE2b-256 checksum
How to use checksums
baeb192f78d8a7bbdba7b8d80fb0a6433b717492a167d8a37afe5281d098881e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 20, 2025.

Transparency log

Release history Release notifications | RSS feed

2.0.0

2 release files

1.11.0

2 release files

1.10.1

2 release files

1.10.0

2 release files

1.9.2

2 release files

1.9.1

2 release files

1.9.0

2 release files

1.8.2

2 release files

1.8.1

2 release files

1.8.0

2 release files

This release

0.1.dev410 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page