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

Don't allow negative contour values #5830

Merged
merged 2 commits into from
May 21, 2023
Merged

Conversation

dstansby
Copy link
Contributor

Fixes/Closes

Fixes #5829

Description

This limits the contour spin box limits to exclude negative numbers. Negative values do not have any affect on the contouring and act the same as 0, so I think it makes sense to prevent users from setting negative values to avoid confusion.

I couldn't obviously think of a test to add for this, but happy to dig further if required.

References

Type of change

  • Bug-fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this been tested?

  • example: the test suite for my feature covers cases x, y, and z
  • example: all tests pass with my change
  • example: I check if my changes works with both PySide and PyQt backends
    as there are small differences between the two Qt bindings.

Final checklist:

  • My PR is the minimum possible work for the desired functionality
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • If I included new strings, I have used trans. to make them localizable.
    For more information see our translations guide.

@github-actions github-actions bot added the qt Relates to qt label May 12, 2023
@brisvag brisvag added the bugfix PR with bugfix label May 12, 2023
Copy link
Contributor

@brisvag brisvag left a comment

Choose a reason for hiding this comment

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

Makes sense to me!

@Czaki
Copy link
Collaborator

Czaki commented May 12, 2023

It should also be fixed here:

@contour.setter
def contour(self, contour):
self._contour = contour
self.events.contour()
self.refresh()

Im not sure if silent fixing should be applied or raise an exception.

@dstansby
Copy link
Contributor Author

It looks like in other places (e.g. color_mode, contrast_limits) errors are raised on invalid values, so I'll raise an error.

@github-actions github-actions bot added the tests Something related to our tests label May 13, 2023
@codecov
Copy link

codecov bot commented May 13, 2023

Codecov Report

Merging #5830 (67999b8) into main (3868f5c) will increase coverage by 0.05%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #5830      +/-   ##
==========================================
+ Coverage   89.86%   89.92%   +0.05%     
==========================================
  Files         615      615              
  Lines       52474    52478       +4     
==========================================
+ Hits        47158    47189      +31     
+ Misses       5316     5289      -27     
Impacted Files Coverage Δ
napari/_qt/layer_controls/qt_labels_controls.py 92.07% <100.00%> (ø)
napari/layers/labels/_tests/test_labels.py 99.51% <100.00%> (+<0.01%) ⬆️
napari/layers/labels/labels.py 95.87% <100.00%> (+0.01%) ⬆️

... and 7 files with indirect coverage changes

@brisvag brisvag added the ready to merge Last chance for comments! Will be merged in ~24h label May 15, 2023
@Czaki Czaki merged commit fba26dc into napari:main May 21, 2023
34 checks passed
@Czaki Czaki removed the ready to merge Last chance for comments! Will be merged in ~24h label May 21, 2023
@psobolewskiPhD psobolewskiPhD modified the milestones: 0.4.18, 0.5.0 May 21, 2023
@Czaki Czaki mentioned this pull request Jun 7, 2023
@Czaki Czaki modified the milestones: 0.5.0, 0.4.18 Jun 16, 2023
@Czaki Czaki added the triaged-0.4.18 To mark PR that is triaged in 0.4.18 release process label Jun 16, 2023
Czaki pushed a commit that referenced this pull request Jun 19, 2023
# Fixes/Closes

Fixes #5829

# Description
This limits the contour spin box limits to exclude negative numbers.
Negative values do not have any affect on the contouring and act the
same as 0, so I think it makes sense to prevent users from setting
negative values to avoid confusion.

I couldn't obviously think of a test to add for this, but happy to dig
further if required.

# References
<!-- What resources, documentation, and guides were used in the creation
of this PR? -->

## Type of change
<!-- Please delete options that are not relevant. -->
- [ ] Bug-fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

# How has this been tested?
<!-- Please describe the tests that you ran to verify your changes. -->
- [ ] example: the test suite for my feature covers cases x, y, and z
- [ ] example: all tests pass with my change
- [ ] example: I check if my changes works with both PySide and PyQt
backends
      as there are small differences between the two Qt bindings.  

## Final checklist:
- [ ] My PR is the minimum possible work for the desired functionality
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] If I included new strings, I have used `trans.` to make them
localizable.
For more information see our [translations
guide](https://napari.org/developers/translations.html).
Czaki pushed a commit that referenced this pull request Jun 21, 2023
# Fixes/Closes

Fixes #5829

# Description
This limits the contour spin box limits to exclude negative numbers.
Negative values do not have any affect on the contouring and act the
same as 0, so I think it makes sense to prevent users from setting
negative values to avoid confusion.

I couldn't obviously think of a test to add for this, but happy to dig
further if required.

# References
<!-- What resources, documentation, and guides were used in the creation
of this PR? -->

## Type of change
<!-- Please delete options that are not relevant. -->
- [ ] Bug-fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

# How has this been tested?
<!-- Please describe the tests that you ran to verify your changes. -->
- [ ] example: the test suite for my feature covers cases x, y, and z
- [ ] example: all tests pass with my change
- [ ] example: I check if my changes works with both PySide and PyQt
backends
      as there are small differences between the two Qt bindings.  

## Final checklist:
- [ ] My PR is the minimum possible work for the desired functionality
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] If I included new strings, I have used `trans.` to make them
localizable.
For more information see our [translations
guide](https://napari.org/developers/translations.html).
Czaki pushed a commit that referenced this pull request Jun 21, 2023
# Fixes/Closes

Fixes #5829

# Description
This limits the contour spin box limits to exclude negative numbers.
Negative values do not have any affect on the contouring and act the
same as 0, so I think it makes sense to prevent users from setting
negative values to avoid confusion.

I couldn't obviously think of a test to add for this, but happy to dig
further if required.

# References
<!-- What resources, documentation, and guides were used in the creation
of this PR? -->

## Type of change
<!-- Please delete options that are not relevant. -->
- [ ] Bug-fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

# How has this been tested?
<!-- Please describe the tests that you ran to verify your changes. -->
- [ ] example: the test suite for my feature covers cases x, y, and z
- [ ] example: all tests pass with my change
- [ ] example: I check if my changes works with both PySide and PyQt
backends
      as there are small differences between the two Qt bindings.  

## Final checklist:
- [ ] My PR is the minimum possible work for the desired functionality
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] If I included new strings, I have used `trans.` to make them
localizable.
For more information see our [translations
guide](https://napari.org/developers/translations.html).
Czaki pushed a commit that referenced this pull request Jun 21, 2023
# Fixes/Closes

Fixes #5829

# Description
This limits the contour spin box limits to exclude negative numbers.
Negative values do not have any affect on the contouring and act the
same as 0, so I think it makes sense to prevent users from setting
negative values to avoid confusion.

I couldn't obviously think of a test to add for this, but happy to dig
further if required.

# References
<!-- What resources, documentation, and guides were used in the creation
of this PR? -->

## Type of change
<!-- Please delete options that are not relevant. -->
- [ ] Bug-fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

# How has this been tested?
<!-- Please describe the tests that you ran to verify your changes. -->
- [ ] example: the test suite for my feature covers cases x, y, and z
- [ ] example: all tests pass with my change
- [ ] example: I check if my changes works with both PySide and PyQt
backends
      as there are small differences between the two Qt bindings.  

## Final checklist:
- [ ] My PR is the minimum possible work for the desired functionality
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] If I included new strings, I have used `trans.` to make them
localizable.
For more information see our [translations
guide](https://napari.org/developers/translations.html).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix PR with bugfix qt Relates to qt tests Something related to our tests triaged-0.4.18 To mark PR that is triaged in 0.4.18 release process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Label contour values < 0 act the same as 0
4 participants