Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Raise error when negative or non-integer ROI values are passed to plot_surf_roi #4131

Merged
merged 12 commits into from Dec 12, 2023

Conversation

michellewang
Copy link
Contributor

Changes proposed in this pull request:

  • Raise ValueError in plot_surf_roi if roi_map has negative or non-integer values
    • For the non-integer case, this is done by casting the roi array to integer, then comparing with the original roi array. Not sure if there's a better way to do this
  • Add tests for both cases above
  • Also test checking that another ValueError is raised if roi is not one-dimensional (there wasn't a test for that)

If we want a deprecation cycle (see #4104 (comment)) I can add that as well.

Copy link
Contributor

github-actions bot commented Dec 5, 2023

👋 @michellewang Thanks for creating a PR!

Until this PR is ready for review, you can include the [WIP] tag in its title, or leave it as a github draft.

Please make sure it is compliant with our contributing guidelines. In particular, be sure it checks the boxes listed below.

  • PR has an interpretable title.
  • PR links to Github issue with mention Closes #XXXX (see our documentation on PR structure)
  • Code is PEP8-compliant (see our documentation on coding style)
  • Changelog or what's new entry in doc/changes/latest.rst (see our documentation on PR structure)

For new features:

  • There is at least one unit test per new function / class (see our documentation on testing)
  • The new feature is demoed in at least one relevant example.

For bug fixes:

  • There is at least one test that would fail under the original bug conditions.

We will review it as quick as possible, feel free to ping us with questions if needed.

Copy link

codecov bot commented Dec 5, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (d95dad9) 91.90% compared to head (40e33c5) 91.83%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4131      +/-   ##
==========================================
- Coverage   91.90%   91.83%   -0.07%     
==========================================
  Files         145      145              
  Lines       16330    16335       +5     
  Branches     3404     3406       +2     
==========================================
- Hits        15008    15002       -6     
- Misses        778      792      +14     
+ Partials      544      541       -3     
Flag Coverage Δ
macos-latest_3.12_test_plotting 91.69% <100.00%> (?)
macos-latest_3.8_test_plotting 91.65% <100.00%> (?)
macos-latest_3.9_test_plotting 91.66% <100.00%> (+0.01%) ⬆️
ubuntu-latest_3.10_test_plotting 91.69% <100.00%> (+0.01%) ⬆️
ubuntu-latest_3.11_test_plotting 91.69% <100.00%> (+0.01%) ⬆️
ubuntu-latest_3.12_test_plotting 91.69% <100.00%> (+0.01%) ⬆️
ubuntu-latest_3.12_test_pre 91.69% <100.00%> (+0.01%) ⬆️
ubuntu-latest_3.8_test_min ?
ubuntu-latest_3.8_test_plot_min 91.42% <100.00%> (+0.01%) ⬆️
ubuntu-latest_3.8_test_plotting 91.65% <100.00%> (+0.01%) ⬆️
ubuntu-latest_3.9_test_plotting 91.66% <100.00%> (+0.01%) ⬆️
windows-latest_3.10_test_plotting ?
windows-latest_3.11_test_plotting 91.67% <100.00%> (+0.01%) ⬆️
windows-latest_3.12_test_plotting ?
windows-latest_3.8_test_plotting 91.63% <100.00%> (+0.01%) ⬆️
windows-latest_3.9_test_plotting 91.64% <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.

@bthirion
Copy link
Member

bthirion commented Dec 5, 2023

LGTM so far, but we probably need to add a deprecation cycle.

@michellewang
Copy link
Contributor Author

Ok I replaced the errors by deprecation warnings. Do we usually specify the future version of Nilearn where deprecated features will be removed? If so, which version would we want to name?

@bthirion
Copy link
Member

bthirion commented Dec 9, 2023

Thx. I guess that removal will be in 0.13.

Copy link
Member

@ymzayek ymzayek left a comment

Choose a reason for hiding this comment

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

Copy link
Member

@bthirion bthirion left a comment

Choose a reason for hiding this comment

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

LGTM, thx !

@ymzayek ymzayek merged commit d3d743f into nilearn:main Dec 12, 2023
32 checks passed
@michellewang michellewang deleted the 4104/plot_surf_roi_error branch February 2, 2024 19:08
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.

plot_surf_roi should raise error when negative or floating-point values are passed
3 participants