tpvasconcelos / ridgeplot

Beautiful ridgeline plots in Python
https://ridgeplot.readthedocs.io/
MIT License
67 stars 6 forks source link

[BUG] Fix single trace zero division error #268

Open sstephanyy opened 3 weeks ago

sstephanyy commented 3 weeks ago

Description

To prevent the ZeroDivisionError from occurring when using index-based colormodes with a single trace or a single row of data, the code has been modified to check the number of rows before performing any calculations. If only one row is present, a default color value (like 0.0) is returned instead of attempting to divide by zero.

Related issues

Closes #252

PR check list


šŸ“š Documentation preview šŸ“š: https://ridgeplot--268.org.readthedocs.build/en/268/

codecov[bot] commented 3 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (abdb617) to head (7b7c968).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #268 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 13 13 Lines 537 543 +6 Branches 70 73 +3 ========================================= + Hits 537 543 +6 ``` | [Flag](https://app.codecov.io/gh/tpvasconcelos/ridgeplot/pull/268/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tomas+Pereira+de+Vasconcelos) | Coverage Ī” | | |---|---|---| | [combined-src](https://app.codecov.io/gh/tpvasconcelos/ridgeplot/pull/268/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tomas+Pereira+de+Vasconcelos) | `99.26% <100.00%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tomas+Pereira+de+Vasconcelos#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

tpvasconcelos commented 3 weeks ago

Hey @sstephanyy thanks a lot for your pull request!

I see that some CI checks are still failing. Let me know if you need me to look into it šŸ‘

sstephanyy commented 3 weeks ago

I see that some CI checks are still failing. Let me know if you need me to look into it šŸ‘

@tpvasconcelos, I solved a mypy CI failing check, but 1 CI failure remains :/

tpvasconcelos commented 2 weeks ago

@sstephanyy just noticed that you added your changes to the wrong section of the changelog. No worries of course but this would mean that your changes would not be listed in the next release notes šŸ˜Ø

Fixed in bba6be22c124d47c11f95fcdb1c602a01325369d āœ…

tpvasconcelos commented 2 weeks ago

@sstephanyy I simplified your test cases a bit by using pytest.mark.parametrize (take a look).

sstephanyy commented 2 weeks ago

@sstephanyy just noticed that you added your changes to the wrong section of the changelog. No worries of course but this would mean that your changes would not be listed in the next release notes šŸ˜Ø

Fixed in bba6be2 āœ…

Thanks so much for the fix :)

sstephanyy commented 2 weeks ago

@sstephanyy I simplified your test cases a bit by using pytest.mark.parametrize (take a look).

wow, well-done. I do know about the existence of pytest.mark.parametrize to run the same test over and over again with different values, but didn't come to my mind using it. Great job :open_mouth: :confetti_ball:

tpvasconcelos commented 1 week ago

@sstephanyy let me know if the new test cases I pushed were helpful or whether you want more help here šŸ‘

See this as well