Skip to content

Auto-detect dimension names from DataArray, remove bracket-spec API - #17

Merged
drbenvincent merged 1 commit into
mainfrom
autodetect-dims
Jul 5, 2026
Merged

Auto-detect dimension names from DataArray, remove bracket-spec API#17
drbenvincent merged 1 commit into
mainfrom
autodetect-dims

Conversation

@drbenvincent

Copy link
Copy Markdown
Owner

Closes #11. Dimensions are now read from the xarray DataArray and spread automatically — no bracket syntax needed.

# Before
td.parameter_draws(dt, "beta[groups]", "sigma")
td.compare_draws(dt, "beta[groups]")

# After
td.parameter_draws(dt, "beta", "sigma")
td.compare_draws(dt, "beta")

What changed

  • Removed _parse_var_spec() (~35 lines of regex + dimension validation)
  • Removed import re, from typing import Tuple, List
  • parameter_draws: accepts bare *var_names — auto-detects non-sample dims from DataArray.dims
  • compare_draws: follows via delegation, renamed *var_specs*var_names
  • prediction_draws: docstring no longer misleadingly mentions bracket syntax
  • Tests: removed test_error_malformed_spec, test_error_dimension_mismatch (both test files); all specs updated to bare names
  • Docs: all 4 .qmd files + AGENTS.md updated

Verification

  • 49/49 tests pass (93% coverage)
  • Smoke test matches the exact example from the issue

@drbenvincent drbenvincent left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good simplification — auto-detecting dims from the DataArray is cleaner than the bracket-spec, and the implementation is correct. A few issues to address before merging.

Comment thread tidydraws/_extract.py Outdated
Comment thread tests/test_compare_draws.py Outdated
Comment thread tests/test_compare_draws.py
Comment thread tidydraws/_extract.py
@drbenvincent

Copy link
Copy Markdown
Owner Author

Version bump needed — removing the bracket-spec API ("beta[groups]""beta") is a breaking change for any user on v0.2.x who calls parameter_draws or compare_draws with the old syntax. Per SemVer this should be 0.3.0, not 0.2.0. At minimum the PR description should note the version bump and pyproject.toml should be updated before merging.

Also worth adding a one-line migration note to the changelog / release notes so users know what to change.

* Add Altair demo tab to landing page

* Enable vegafusion data transformer for large Altair datasets

* Fix Altair rendering: vegafusion, vl-convert, and faceted chart sizing
@drbenvincent

Copy link
Copy Markdown
Owner Author

Bumped to 0.3.0 in both __init__.py and pyproject.toml. Commit message flags this as a breaking change. A migration note (bare names, no brackets) belongs in the release notes when the tag is cut.

@drbenvincent
drbenvincent merged commit 886d129 into main Jul 5, 2026
7 checks passed
@drbenvincent
drbenvincent deleted the autodetect-dims branch July 5, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Autodetect dimension names?

1 participant