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
Default values for ROIs #2341
Default values for ROIs #2341
Conversation
@thomasaarholt, what is the status of this PR? The relative slicing that you added in #2386 could be used here to set the default value? |
Yes! The lack of any comments here made me think that this PR perhaps wasn't desirable, but then again the post is a block of text where I never asked for feedback. I'm currently deeply involved with a different programming project, but this change should be small enough so I'll try to get it done soon. |
Indeed... actually, I commented on this PR in #2343 (comment). |
Codecov Report
@@ Coverage Diff @@
## RELEASE_next_minor #2341 +/- ##
======================================================
+ Coverage 76.67% 76.71% +0.04%
======================================================
Files 203 203
Lines 30133 30123 -10
Branches 6566 6565 -1
======================================================
+ Hits 23103 23108 +5
+ Misses 5210 5199 -11
+ Partials 1820 1816 -4
Continue to review full report at Codecov.
|
There is one "breaking" change in this: >>> rect = hs.roi.RectangularROI(2, 2, 5, 5)
>>> rect
RectangularROI(left=2, top=2, right=5, bottom=5)
>>> rect[2]
2.0 Now it is indexed in the same order. |
Agreed and I think we need to make sure that we get it right... because it can be quite disruptive for users... Definitely better figuring this out in a separate PR. |
I've manually checked that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments to make it more simple.
Co-authored-by: Eric Prestat <eric.prestat@gmail.com>
Thanks for the comments. I ended up keeping We now use I also refactored some code (like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have provided more details on why we shouldn't add more method which doesn't add any functionality. The code for the ROIs is already quite long and we shall not make unnecessarily longer.
As mentioned in the review, I am not convinced that adding these method is a good approach. |
@ericpre I think everything is now taken into account. Those were good suggestions, it's a lot cleaner now. It's been a while since I've thought about taking The failing tests are due to numpy 1.20, see #2635. The change to setting CircleROI's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I find this version much better! My reviews may have sound a bit picky and annoying but I really think, we should keep the ROI classes as tidy as possible.
I think the structure is good now and the suggestions I have added, are mainly about tests and other improvements.
Would it be possible to finish this PR while it is getting closed to be finished? |
Ok, please take a look |
Great, thanks! |
TLDR:
This lets one call
hs.roi.Line2DROI()
without specifying coordinates, defaulting to sensible values when calledinteractive
ly on a signal.Description of the change
It is cumbersome to have to manually specify the coordinates of a ROI - especially when you just quickly want a ROI on an image to extract a certain part of it with
roi.interactive()
.This PR is an attempt to allow
None
(or really, theUndefined
traits
type) to be an allowed value for ROIs so that they can be properly instantiated at a later time.I have:
get_central_half_limits_of_axis(ax)
inhyperspy.utils.axes
(new file) that returns indices of the central half of an axes using Support for relative slicing #2386.roi.parameters
: property that returns the parameter names and values as a dictroi._set_default_values()
: sets the appropriate values when using it interactively with un-set values.is_valid
,__getitem__
and__repr__
)__repr__
of ROIs to use f-strings and the:G
formatter where possible.Progress of the PR
Minimal example of the bug fix or the new feature