Skip to content

Improve test suite: ridgeplot._hist#365

Open
tpvasconcelos wants to merge 11 commits into
mainfrom
improve-test-hist
Open

Improve test suite: ridgeplot._hist#365
tpvasconcelos wants to merge 11 commits into
mainfrom
improve-test-hist

Conversation

@tpvasconcelos

@tpvasconcelos tpvasconcelos commented Dec 26, 2025

Copy link
Copy Markdown
Owner

Summary

Rewrites tests/unit/test_hist.py with a more comprehensive, better-organised test suite for ridgeplot._hist:

  • Replace the shared module-level constants (SAMPLES_IN, X_OUT, ...) with parametrised, self-contained test cases: basic binning, single bin, uniform distribution, all-identical samples (zero-width range), and negative values
  • Fix the stale section headers that still referenced estimate_density_trace()/estimate_densities() (copied over from test_kde.py)
  • Add coverage for previously untested behaviour:
    • bin_samples() with sample_weights: flat-vector broadcast to all traces, and per-trace weights in the shallow form (incl. None entries)
    • Shape preservation for ragged rows in bin_samples()
    • Output normalisation to built-in floats (using type(...) is float, since np.float64 is a subclass of float and would pass an isinstance() check)
    • Invariants: counts sum to the sample size (or to the sum of weights, when weighted), and bin centers stay within the data range
  • Error handling: non-finite samples/weights (now incl. -inf) and mismatched weights lengths are parametrised and deduplicated via a shared NON_FINITE_VALUES constant

📚 Documentation preview 📚: https://ridgeplot--365.org.readthedocs.build/en/365/

Signed-off-by: Tomas Pereira de Vasconcelos <tomasvasconcelos1@gmail.com>
@github-actions

This comment has been minimized.

@codecov

codecov Bot commented Dec 26, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (14e872d) to head (83a2262).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #365   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           19        19           
  Lines          674       674           
  Branches        88        88           
=========================================
  Hits           674       674           
Flag Coverage Δ
combined-src 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tpvasconcelos
tpvasconcelos marked this pull request as draft December 26, 2025 13:44
@tpvasconcelos
tpvasconcelos marked this pull request as ready for review July 25, 2026 03:53

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 39a77d3b32

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/unit/test_hist.py
Comment on lines +141 to +144
@pytest.mark.parametrize("non_finite", NON_FINITE_VALUES)
def test_rejects_non_finite_samples(non_finite: float) -> None:
with pytest.raises(ValueError, match="samples array should not contain any infs or NaNs"):
bin_trace_samples([1, 2, non_finite], nbins=2)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove stale tests that reference deleted constants

The new non-finite-value cases duplicate rather than replace the existing tests at lines 71–74 and 172–180, while this patch deletes SAMPLES_IN, NBINS, and WEIGHTS. Consequently, collecting this file runs eight cases that raise NameError before reaching bin_trace_samples; the targeted pytest suite reports 8 failures. Delete those stale tests or make them self-contained so the unit suite passes.

AGENTS.md reference: AGENTS.md:L163-L163

Useful? React with 👍 / 👎.

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