Skip to content

Conversation

@sstephanyy
Copy link
Contributor

@sstephanyy sstephanyy commented Nov 1, 2024

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

  • Read the contributing guidelines.
    • You don't have to read the whole thing, but it's a good idea to skim it. And definitely take a look at it if you're experiencing any issues getting your local environment up and running.
  • Provided the relevant details in the PR's description.
  • Referenced relevant issues in the PR's description.
  • Added tests for all my changes.
    • The CI will fail unless 100% of all new code is covered by the tests.
  • Updated the docs for relevant changes.
    • New modules (or renamed ones) are included in docs/api/internal/.
    • New public functions/classes/variables are documented in docs/api/index.rst.
    • Added the appropriate versionadded, versionchanged, or deprecated directives to docstrings.
      • The version should be the next release version, which you can infer by bumping the minor version in MAJOR.MINOR.PATCH (e.g., if the current version is 0.2.3, the next release will be 0.3.0).
  • Changes are documented in docs/reference/changelog.md.
    • Please try to follow the conventions laid out in the file. In doubt, just ask!
  • Consider granting push permissions to your PR's branch, so maintainers can help you out if needed.
  • The CI check are all passing, or I'm working on fixing them!
  • I have reviewed my own code! 🤠

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

@codecov
Copy link

codecov bot commented Nov 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (8196584) to head (7c6ebdb).
Report is 139 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #268   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           13        13           
  Lines          537       541    +4     
  Branches        70        72    +2     
=========================================
+ Hits           537       541    +4     
Flag Coverage Δ
combined-src 99.26% <100.00%> (+<0.01%) ⬆️

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

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

@tpvasconcelos tpvasconcelos added the BUG Something isn't working label Nov 1, 2024
@tpvasconcelos

This comment was marked as outdated.

@sstephanyy

This comment was marked as outdated.

@tpvasconcelos
Copy link
Owner

@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

@tpvasconcelos tpvasconcelos changed the base branch from main to refactor-interpol November 4, 2024 00:59
@tpvasconcelos tpvasconcelos deleted the branch tpvasconcelos:main November 4, 2024 01:03
@tpvasconcelos tpvasconcelos reopened this Nov 4, 2024
@tpvasconcelos tpvasconcelos changed the base branch from refactor-interpol to main November 4, 2024 01:08
@tpvasconcelos
Copy link
Owner

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

tpvasconcelos

This comment was marked as resolved.

@sstephanyy
Copy link
Contributor Author

@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
Copy link
Contributor Author

@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 😮 🎊

@tpvasconcelos
Copy link
Owner

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

See this as well

Copy link
Owner

@tpvasconcelos tpvasconcelos left a comment

Choose a reason for hiding this comment

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

Thank you @sstephanyy for your work here!

@tpvasconcelos tpvasconcelos merged commit c150a1d into tpvasconcelos:main Nov 24, 2024
17 checks passed
@sstephanyy sstephanyy deleted the fix/single-trace-zero-division-error branch November 25, 2024 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BUG Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Index-based colormodes raise ZeroDivisionError for single-trace plots

2 participants