Commit ebbec41
authored
Add support for ArviZ <1.0, on top of existing >1.0 support (#22)
* Support both xr.DataTree and arviz.InferenceData via duck-typing
Add _get_group() and _has_group() private helpers that dispatch on
hasattr(dt, 'children') to support both arviz >=1.0 DataTree and
arviz <1.0 InferenceData with zero public API changes.
- Rename _datatree_group_to_df → _group_to_df (no longer datatree-specific)
- Route all group access through the two helpers
- Loosen arviz pin from >=1.0 to any version
- Update docstrings and error messages for dual-type support
Closes #21
* Add backend dispatch tests covering both DataTree and InferenceData paths
Parametrized tests verify parameter_draws, compare_draws, and
prediction_draws work identically with xr.DataTree and a duck-type
InferenceData mock (attribute-access groups, no .children).
42 new tests, 100% pass rate against both backends.
* Add arviz<1.0 CI matrix and real-InferenceData fixture
The legacy az.InferenceData dispatch branch was only exercised by the
_InferenceDataMock duck-type; on arviz>=1.0 az.InferenceData aliases to
DataTree so the getattr(dt, group) path was unreachable in CI.
- ci.yml: matrix.arviz=[locked, legacy]; legacy job pins arviz<1.0
and runs tests with --no-sync so the downgrade is not reverted.
- test_backend_compat.py: add real_inferencedata variant to parameter,
compare, and prediction fixtures. Skips on arviz>=1.0 (DetectionWarning
path), runs same assertions against real az.InferenceData on arviz<1.0.
Verified: 92 passed/21 skipped on arviz 1.2.0; 63 passed/0 skipped on
arviz 0.23.4 (real legacy branch exercised).
* docs: add GitHub install instructions for pre-release testing
Lets users test main-branch functionality before a PyPI release:
pip install git+https://github.com/drbenvincent/tidydraws.git
uv add git+https://github.com/drbenvincent/tidydraws.git
Added to both README.md and index.qmd install sections.
* Address review non-blocking items: type annotations, pin, error msg, docs
- _extract.py: widen dt annotations from xr.DataTree to a PEP 695
ArviZData = xr.DataTree | az.InferenceData union alias. az is imported
only under TYPE_CHECKING; the alias rhs is lazy so no runtime arviz
import is needed (matches the PR's no-import design). Applied to all
three public functions and the _get_group/_has_group/_group_to_df helpers.
- pyproject.toml: pin arviz>=0.12 (was bare 'arviz'), matching the PR's
stated out-of-scope (arviz<0.12 not supported).
- _extract.py: restore 'constant_data_group' parameter name in the
prediction_draws missing-data error message (AGENTS.md Hard Rule 3).
- 04-showcase.qmd: fix stale _datatree_group_to_df -> _group_to_df ref.
Verified: 92 passed/21 skipped; pre-commit (ruff, mypy v1.15.0, format)
passes; arviz not imported at runtime; ArviZData is a lazy TypeAliasType.1 parent 42fd6b6 commit ebbec41
10 files changed
Lines changed: 481 additions & 41 deletions
File tree
- .github/workflows
- docs/examples
- tests
- tidydraws
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
18 | 27 | | |
19 | 28 | | |
20 | 29 | | |
| |||
25 | 34 | | |
26 | 35 | | |
27 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
28 | 42 | | |
29 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
30 | 46 | | |
31 | 47 | | |
32 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
29 | 41 | | |
30 | 42 | | |
31 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
305 | 305 | | |
306 | 306 | | |
307 | 307 | | |
308 | | - | |
| 308 | + | |
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
315 | 315 | | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
316 | 322 | | |
317 | 323 | | |
318 | 324 | | |
319 | 325 | | |
320 | 326 | | |
321 | 327 | | |
322 | | - | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
323 | 335 | | |
324 | 336 | | |
325 | 337 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
0 commit comments