Skip to content

[BUG] fix test_discrete_pmf_plotting assertion, resolves #918#981

Open
rupeshca007 wants to merge 1 commit intosktime:mainfrom
rupeshca007:main
Open

[BUG] fix test_discrete_pmf_plotting assertion, resolves #918#981
rupeshca007 wants to merge 1 commit intosktime:mainfrom
rupeshca007:main

Conversation

@rupeshca007
Copy link

Summary

Fixes #918.

The test_discrete_pmf_plotting test was failing because the assertion
incorrectly checked len(ax.containers[0].get_children()) > 5.

A matplotlib StemContainer always has exactly 3 children
(markerline, stemlines, baseline), regardless of how many data points
are plotted. So the check was always 3 > 5 = False.

Fix

  • Removed the @pytest.mark.skip decorator added as a workaround in [BUG] test_discrete_pmf_plotting is failing #918.
  • Replaced the broken assertion with
    len(stem_container.stemlines.get_segments()) > 5, which correctly
    counts the number of plotted support points. For Binomial(n=10),
    this is 11 (support is {0, 1, ..., 10}).

PR checklist

For all contributions
  • I've added myself to the list of contributors with any new badges I've earned :-)
    • Badge: bug (diagnosed and fixed a bug) + code
  • The PR title starts with [BUG]

The test was checking len(StemContainer.get_children()) > 5, but a
StemContainer always has exactly 3 children (markerline, stemlines,
baseline). The correct way to count plotted support points is via
stem_container.stemlines.get_segments(), which returns one segment per data
point. For Binomial(n=10) there are 11 support points, so the > 5 threshold
remains valid.

Also removes the @pytest.mark.skip decorator since the root cause is fixed.
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.

[BUG] test_discrete_pmf_plotting is failing

1 participant