unxt-hypothesis 0.1.dev410__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,165 @@
1
+ # -----------------------------------------------
2
+ # Project-Specific
3
+
4
+ # Version files
5
+ _version.py
6
+
7
+
8
+ # -----------------------------------------------
9
+ # General
10
+
11
+ # Byte-compiled / optimized / DLL files
12
+ __pycache__/
13
+ *.py[cod]
14
+ *$py.class
15
+
16
+ # C extensions
17
+ *.so
18
+
19
+ # Distribution / packaging
20
+ .Python
21
+ build/
22
+ develop-eggs/
23
+ dist/
24
+ downloads/
25
+ eggs/
26
+ .eggs/
27
+ lib/
28
+ lib64/
29
+ parts/
30
+ sdist/
31
+ var/
32
+ wheels/
33
+ share/python-wheels/
34
+ *.egg-info/
35
+ .installed.cfg
36
+ *.egg
37
+ MANIFEST
38
+
39
+ # PyInstaller
40
+ # Usually these files are written by a python script from a template
41
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
42
+ *.manifest
43
+ *.spec
44
+
45
+ # Installer logs
46
+ pip-log.txt
47
+ pip-delete-this-directory.txt
48
+
49
+ # Unit test / coverage reports
50
+ htmlcov/
51
+ .tox/
52
+ .nox/
53
+ .coverage
54
+ .coverage.*
55
+ .cache
56
+ nosetests.xml
57
+ coverage.xml
58
+ *.cover
59
+ *.py,cover
60
+ .hypothesis/
61
+ .pytest_cache/
62
+ cover/
63
+
64
+ # Translations
65
+ *.mo
66
+ *.pot
67
+
68
+ # Django stuff:
69
+ *.log
70
+ local_settings.py
71
+ db.sqlite3
72
+ db.sqlite3-journal
73
+
74
+ # Flask stuff:
75
+ instance/
76
+ .webassets-cache
77
+
78
+ # Scrapy stuff:
79
+ .scrapy
80
+
81
+ # Sphinx documentation
82
+ docs/_build/
83
+
84
+ # PyBuilder
85
+ .pybuilder/
86
+ target/
87
+
88
+ # Jupyter Notebook
89
+ .ipynb_checkpoints
90
+
91
+ # IPython
92
+ profile_default/
93
+ ipython_config.py
94
+
95
+ # pyenv
96
+ # For a library or package, you might want to ignore these files since the code is
97
+ # intended to run in multiple environments; otherwise, check them in:
98
+ # .python-version
99
+
100
+ # pipenv
101
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
102
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
103
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
104
+ # install all needed dependencies.
105
+ #Pipfile.lock
106
+
107
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
108
+ __pypackages__/
109
+
110
+ # Celery stuff
111
+ celerybeat-schedule
112
+ celerybeat.pid
113
+
114
+ # SageMath parsed files
115
+ *.sage.py
116
+
117
+ # Environments
118
+ .env
119
+ .venv
120
+ env/
121
+ venv/
122
+ ENV/
123
+ env.bak/
124
+ venv.bak/
125
+
126
+ # Spyder project settings
127
+ .spyderproject
128
+ .spyproject
129
+
130
+ # Rope project settings
131
+ .ropeproject
132
+
133
+ # mkdocs documentation
134
+ /site
135
+
136
+ # mypy
137
+ .mypy_cache/
138
+ .dmypy.json
139
+ dmypy.json
140
+
141
+ # Pyre type checker
142
+ .pyre/
143
+
144
+ # pytype static type analyzer
145
+ .pytype/
146
+
147
+ # Cython debug symbols
148
+ cython_debug/
149
+
150
+ # ruff
151
+ .ruff_cache/
152
+
153
+ # OS specific stuff
154
+ .DS_Store
155
+ .DS_Store?
156
+ ._*
157
+ .Spotlight-V100
158
+ .Trashes
159
+ ehthumbs.db
160
+ Thumbs.db
161
+
162
+ # Common editor files
163
+ *~
164
+ *.swp
165
+ /.codspeed
@@ -0,0 +1,166 @@
1
+ Metadata-Version: 2.4
2
+ Name: unxt-hypothesis
3
+ Version: 0.1.dev410
4
+ Summary: Hypothesis strategies for unxt
5
+ Project-URL: Bug Tracker, https://github.com/GalacticDynamics/unxt/issues
6
+ Project-URL: Homepage, https://github.com/GalacticDynamics/unxt
7
+ Author-email: GalacticDynamics <nstarman@users.noreply.github.com>, Nathaniel Starkman <nstarman@users.noreply.github.com>
8
+ License: BSD-3-Clause
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: License :: OSI Approved :: BSD License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Scientific/Engineering
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.11
23
+ Requires-Dist: hypothesis[numpy]>=6.138.14
24
+ Requires-Dist: jax>=0.5.3
25
+ Requires-Dist: unxt
26
+ Description-Content-Type: text/markdown
27
+
28
+ # unxt-hypothesis
29
+
30
+ Hypothesis strategies for [unxt](https://github.com/GalacticDynamics/unxt) -
31
+ unitful quantities in JAX.
32
+
33
+ This package provides [Hypothesis](https://hypothesis.readthedocs.io/)
34
+ strategies for generating `unxt` objects for for property-based testing.
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ uv add unxt-hypothesis
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ ```python
45
+ from hypothesis import given
46
+
47
+ import unxt_hypothesis as ust
48
+
49
+
50
+ @given(q=ust.quantities(unit="km/s"))
51
+ def test_quantity_property(q):
52
+ # Test some property of quantities
53
+ assert q.value is not None
54
+ assert q.unit is not None
55
+
56
+
57
+ @given(u=ust.units("length"))
58
+ def test_unit_property(u):
59
+ # Test some property of units
60
+ assert u is not None
61
+
62
+
63
+ @given(sys=ust.unitsystems("m", "s", "kg", "rad"))
64
+ def test_unitsystem_property(sys):
65
+ # Test some property of unit systems
66
+ assert len(sys) == 4
67
+ ```
68
+
69
+ ### Custom strategies
70
+
71
+ You can customize the strategies:
72
+
73
+ ```python
74
+ from hypothesis import strategies as st
75
+
76
+ import unxt as u
77
+ import unxt_hypothesis as ust
78
+
79
+
80
+ # Generate quantities with specific shapes
81
+ @given(q=ust.quantities(unit="m", shape=st.just((3, 3))))
82
+ def test_matrix_quantity(q):
83
+ assert q.shape == (3, 3)
84
+
85
+
86
+ # Generate quantities with specific dimensions
87
+ @given(q=ust.quantities(unit=ust.units("length")))
88
+ def test_length_quantity(q):
89
+ assert u.dimension_of(q) == u.dimension("length")
90
+ ```
91
+
92
+ ## API
93
+
94
+ ### `quantities(draw, *, shape=None, dtype=None, unit=None)`
95
+
96
+ Generate random `Quantity` objects.
97
+
98
+ **Parameters:**
99
+
100
+ - `draw`: Hypothesis draw function
101
+ - `shape`: Strategy for array shapes (optional, defaults to small arrays)
102
+ - `dtype`: Strategy for array dtypes (optional, defaults to float32)
103
+ - `unit`: Strategy for unit strings (optional, defaults to common units)
104
+
105
+ **Returns:** A `unxt.Quantity` instance
106
+
107
+ ### `units(draw, dimension=None, *, max_complexity=2, allow_non_integer_powers=False)`
108
+
109
+ Generate random `Unit` objects.
110
+
111
+ **Parameters:**
112
+
113
+ - `draw`: Hypothesis draw function
114
+ - `dimension`: Physical dimension (optional, e.g., `"length"`, `"velocity"`)
115
+ - `max_complexity`: Maximum complexity of compound units (default: 2)
116
+ - `allow_non_integer_powers`: Allow non-integer powers (default: False)
117
+
118
+ **Returns:** A `unxt.AbstractUnit` instance
119
+
120
+ ### `unitsystems(*units)`
121
+
122
+ Generate random `UnitSystem` objects.
123
+
124
+ **Parameters:**
125
+
126
+ - `*units`: Variable number of unit specifications. Each can be:
127
+ - `str`: Fixed unit string (e.g., `"m"`, `"kg"`)
128
+ - `unxt.AbstractUnit`: Fixed unit object
129
+ - Strategy: A Hypothesis strategy that generates units
130
+
131
+ **Returns:** A `unxt.AbstractUnitSystem` instance
132
+
133
+ **Example:**
134
+
135
+ ```python
136
+ from hypothesis import given
137
+
138
+ import unxt_hypothesis as ust
139
+
140
+
141
+ # Fixed unit system
142
+ @given(sys=ust.unitsystems("m", "s", "kg", "rad"))
143
+ def test_mks_system(sys):
144
+ assert len(sys) == 4
145
+
146
+
147
+ # Varying length unit, other units fixed
148
+ @given(sys=ust.unitsystems(ust.units("length"), "s", "kg", "rad"))
149
+ def test_varying_length(sys):
150
+ assert len(sys) == 4
151
+ ```
152
+
153
+ ## Documentation
154
+
155
+ For comprehensive documentation, examples, and guides, see the
156
+ [unxt documentation](https://unxt.readthedocs.io/en/latest/guides/testing.html).
157
+
158
+ ## License
159
+
160
+ BSD 3-Clause License. See [LICENSE](../../LICENSE) for details.
161
+
162
+ ## Contributing
163
+
164
+ Contributions are welcome! Please see the main
165
+ [unxt repository](https://github.com/GalacticDynamics/unxt) for contributing
166
+ guidelines.
@@ -0,0 +1,139 @@
1
+ # unxt-hypothesis
2
+
3
+ Hypothesis strategies for [unxt](https://github.com/GalacticDynamics/unxt) -
4
+ unitful quantities in JAX.
5
+
6
+ This package provides [Hypothesis](https://hypothesis.readthedocs.io/)
7
+ strategies for generating `unxt` objects for for property-based testing.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ uv add unxt-hypothesis
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```python
18
+ from hypothesis import given
19
+
20
+ import unxt_hypothesis as ust
21
+
22
+
23
+ @given(q=ust.quantities(unit="km/s"))
24
+ def test_quantity_property(q):
25
+ # Test some property of quantities
26
+ assert q.value is not None
27
+ assert q.unit is not None
28
+
29
+
30
+ @given(u=ust.units("length"))
31
+ def test_unit_property(u):
32
+ # Test some property of units
33
+ assert u is not None
34
+
35
+
36
+ @given(sys=ust.unitsystems("m", "s", "kg", "rad"))
37
+ def test_unitsystem_property(sys):
38
+ # Test some property of unit systems
39
+ assert len(sys) == 4
40
+ ```
41
+
42
+ ### Custom strategies
43
+
44
+ You can customize the strategies:
45
+
46
+ ```python
47
+ from hypothesis import strategies as st
48
+
49
+ import unxt as u
50
+ import unxt_hypothesis as ust
51
+
52
+
53
+ # Generate quantities with specific shapes
54
+ @given(q=ust.quantities(unit="m", shape=st.just((3, 3))))
55
+ def test_matrix_quantity(q):
56
+ assert q.shape == (3, 3)
57
+
58
+
59
+ # Generate quantities with specific dimensions
60
+ @given(q=ust.quantities(unit=ust.units("length")))
61
+ def test_length_quantity(q):
62
+ assert u.dimension_of(q) == u.dimension("length")
63
+ ```
64
+
65
+ ## API
66
+
67
+ ### `quantities(draw, *, shape=None, dtype=None, unit=None)`
68
+
69
+ Generate random `Quantity` objects.
70
+
71
+ **Parameters:**
72
+
73
+ - `draw`: Hypothesis draw function
74
+ - `shape`: Strategy for array shapes (optional, defaults to small arrays)
75
+ - `dtype`: Strategy for array dtypes (optional, defaults to float32)
76
+ - `unit`: Strategy for unit strings (optional, defaults to common units)
77
+
78
+ **Returns:** A `unxt.Quantity` instance
79
+
80
+ ### `units(draw, dimension=None, *, max_complexity=2, allow_non_integer_powers=False)`
81
+
82
+ Generate random `Unit` objects.
83
+
84
+ **Parameters:**
85
+
86
+ - `draw`: Hypothesis draw function
87
+ - `dimension`: Physical dimension (optional, e.g., `"length"`, `"velocity"`)
88
+ - `max_complexity`: Maximum complexity of compound units (default: 2)
89
+ - `allow_non_integer_powers`: Allow non-integer powers (default: False)
90
+
91
+ **Returns:** A `unxt.AbstractUnit` instance
92
+
93
+ ### `unitsystems(*units)`
94
+
95
+ Generate random `UnitSystem` objects.
96
+
97
+ **Parameters:**
98
+
99
+ - `*units`: Variable number of unit specifications. Each can be:
100
+ - `str`: Fixed unit string (e.g., `"m"`, `"kg"`)
101
+ - `unxt.AbstractUnit`: Fixed unit object
102
+ - Strategy: A Hypothesis strategy that generates units
103
+
104
+ **Returns:** A `unxt.AbstractUnitSystem` instance
105
+
106
+ **Example:**
107
+
108
+ ```python
109
+ from hypothesis import given
110
+
111
+ import unxt_hypothesis as ust
112
+
113
+
114
+ # Fixed unit system
115
+ @given(sys=ust.unitsystems("m", "s", "kg", "rad"))
116
+ def test_mks_system(sys):
117
+ assert len(sys) == 4
118
+
119
+
120
+ # Varying length unit, other units fixed
121
+ @given(sys=ust.unitsystems(ust.units("length"), "s", "kg", "rad"))
122
+ def test_varying_length(sys):
123
+ assert len(sys) == 4
124
+ ```
125
+
126
+ ## Documentation
127
+
128
+ For comprehensive documentation, examples, and guides, see the
129
+ [unxt documentation](https://unxt.readthedocs.io/en/latest/guides/testing.html).
130
+
131
+ ## License
132
+
133
+ BSD 3-Clause License. See [LICENSE](../../LICENSE) for details.
134
+
135
+ ## Contributing
136
+
137
+ Contributions are welcome! Please see the main
138
+ [unxt repository](https://github.com/GalacticDynamics/unxt) for contributing
139
+ guidelines.
@@ -0,0 +1,11 @@
1
+ # API Reference
2
+
3
+ Complete API documentation for all `unxt-hypothesis` strategies.
4
+
5
+ ```{eval-rst}
6
+
7
+ .. currentmodule:: unxt_hypothesis
8
+
9
+ .. automodule:: unxt_hypothesis
10
+
11
+ ```