Skip to content

Modernize packaging, drop strict pins, add tests and CI#2

Merged
mjuez merged 2 commits into
mainfrom
feat/mjg/improvements
May 2, 2026
Merged

Modernize packaging, drop strict pins, add tests and CI#2
mjuez merged 2 commits into
mainfrom
feat/mjg/improvements

Conversation

@mjuez
Copy link
Copy Markdown
Owner

@mjuez mjuez commented May 2, 2026

Summary

Fixes the dependency-resolver failure reported by users (The conflict is caused by: baycomp-plotting 1.1.1 depends on numpy==1.19.1 / 1.1 depends on scipy==1.5.3 / ...) and modernizes the project for long-term maintenance. No public API changesimport baycomp_plotting, Color, dens, tern all keep the same signatures and behaviour, so existing users are unaffected on pip install -U baycomp_plotting.

What changed

Packaging

  • setup.py / setup.cfg → PEP 621 pyproject.toml (hatchling backend).
  • Dependencies declared with lower bounds only (matplotlib>=3.5, numpy>=1.21, scipy>=1.7). Upper bounds deliberately omitted; CI catches future breakage instead of declaring it preemptively.
  • iteround dropped as a runtime dep — small _safe_round (largest-remainder) helper inlined.
  • src/ layout (src/baycomp_plotting/) so tests run against the installed wheel, not the source tree.
  • Bumped to 1.2.0. New __version__ attribute.

Tests (tests/)

  • pytest suite with 19 tests covering:
    • Pure helpers (_safe_round, _project, _process_names, Color palette).
    • Structural tests for dens / tern (number of axes, lines, labels).
    • Image regression tests for dens / tern via pytest-mpl against baselines in tests/baseline_images/.
  • Tests pass with -W error::DeprecationWarning -W error::FutureWarning against the latest numpy 2.4, scipy 1.17 and matplotlib 3.10.

CI (.github/workflows/)

  • test.yml: matrix python 3.9 / 3.10 / 3.11 / 3.12 / 3.13 on Ubuntu, plus one job each on macOS and Windows. Runs on push, PR, and weekly cron (Mondays 06:00) so we get notified when a new transitive dep breaks the lib.
  • release.yml: triggered by tag pushes. Builds sdist + wheel and publishes via PyPI trusted publishing.
    • Pre-release tags (vX.Y.Z-rc1, -a1, -b1) → TestPyPI.
    • Stable tags (vX.Y.Z) → PyPI, gated by the pypi environment for manual approval.

Code cleanup

  • setup.py == Noneis None, type hints, modern f-string-style formatting.
  • Extracted _add_posterior to module level (was a triple-nested closure inside dens).
  • ax.set_yticks(ticks); ax.set_yticklabels(labels)ax.set_yticks(ticks, labels=...) (matplotlib 3.5+ recommended single call).
  • Removed redundant section-labelling comments.

Forward-compat notes

I audited plotting.py for deprecated APIs across numpy 2.x, scipy 1.17 and matplotlib 3.10. None used:

API Status
np.amax, np.float_, np.int_ not used
scipy.interpolate.interp2d (removed in scipy 1.14) not used; we use interpn
plt.cm.register_cmap (deprecated mpl 3.7) not used; we use ListedColormap directly

Test plan

  • pytest --mpl — 19/19 passing locally.
  • pytest --mpl -W error::DeprecationWarning -W error::FutureWarning — clean.
  • python -m build — produces wheel + sdist.
  • twine check dist/* — PASSED.
  • Fresh-venv install of the built wheel imports correctly with __version__ == "1.2.0".
  • CI matrix passes (will run on this PR).
  • After merge: tag v1.2.0-rc1 → verify TestPyPI publish path.
  • Then tag v1.2.0 → publish to PyPI.

🤖 Generated with Claude Code

mjuez and others added 2 commits May 2, 2026 18:54
Resolves the dependency-resolver failure reported by users on Python 3.10+.
The 1.1.1 release pinned numpy==1.19.1, scipy==1.5.3, matplotlib==3.3.2 and
iteround==1.0.2; those have no wheels for modern CPython and conflict with
any environment that already requires numpy>=2.

Changes
-------

* Replace setup.py / setup.cfg with PEP 621 pyproject.toml using the
  hatchling backend. Dependencies are declared with lower bounds only
  (matplotlib>=3.5, numpy>=1.21, scipy>=1.7); upper bounds are deliberately
  omitted to avoid the same trap going forward — CI catches breakage.

* Move the package to src/ layout (src/baycomp_plotting/) so tests run
  against the installed wheel instead of the source tree.

* Drop iteround as a runtime dependency by inlining a small
  largest-remainder _safe_round helper.

* Bump to 1.2.0. No public API changes:
  - Color, dens, tern keep the same signatures and behaviour.
  - dens() figure still exposes add_posterior(); it now defaults ls and
    color (was already the documented behaviour in README).
  - __version__ added.

* Add a pytest suite (tests/) covering the pure helpers and image-
  regression tests for dens / tern with pytest-mpl baselines.

* Add GitHub Actions workflows:
  - test.yml: matrix on python 3.9-3.13 + ubuntu / macOS / windows,
    run on push, PR and weekly cron.
  - release.yml: builds sdist and wheel on tag push, publishes via PyPI
    trusted publishing. Pre-release tags (-rc, -a, -b) go to TestPyPI;
    stable tags go to PyPI with a manual approval gate.

* Forward-compat checks: tests pass with -W error::DeprecationWarning
  -W error::FutureWarning under numpy 2.4, scipy 1.17, matplotlib 3.10.
  Switched the two-step set_yticks + set_yticklabels to the single-call
  ax.set_yticks(ticks, labels=...) form (matplotlib 3.5+).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CI failed on Python 3.9 because matplotlib 3.9.x (the last line that supports
3.9 since matplotlib 3.10 dropped it) emits PyparsingDeprecationWarning during
its own initialisation. With -W error::DeprecationWarning that aborted pytest
before any test ran.

Move the strict-warning filters from the workflow command to filterwarnings
in pyproject.toml — that's the canonical place and benefits local runs too —
and silence the pyparsing category so the noise from matplotlib's internals
doesn't gate our suite.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mjuez mjuez merged commit 2576297 into main May 2, 2026
7 checks passed
@mjuez mjuez deleted the feat/mjg/improvements branch May 2, 2026 17:21
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.

1 participant