-
Notifications
You must be signed in to change notification settings - Fork 41
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
Slicer extension 1344 #1919
Slicer extension 1344 #1919
Conversation
ready for testing on Win |
It now mostly works!! Remaining things to address that I found through testing on a (slow) Windows 10 machine.
|
I get the following two errors when testing the functionality:
|
Thanks @rozyczko I just noticed the second error on exiting the application but failed to see the first. Looking more closely I too get that error. This could easily solve a couple of the GUI problems I'm guessing? |
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.
Code looks very good, there are some very minor stylistic issues left.
If the errors seen in my local build test are reproducible, then those will have to be addressed.
I've tested this locally on Linux. The errors that occurred previously are fixed, sometimes I get the error "ValueError: Average Error: No points inside ROI to average...", but not 100% reproducible, and only happens at -Qx. I'm not really sure where this error comes from or how to fix it... I've also fixed so that the box is placed in the middle of the plot not just at Qx = Qy = 0. However, if the plot only contains data at negative Qx (and negative Qy) then I get the same error as above. I've added a x_center and y_center to the parameter list. The parameters can be edited through the Edit slicer parameter window. Question: |
LOL .. I see that it looks like these commits break all the unit tests .. which makes sense since the behavior has been altered. Those will need to be adjust clearly to reflect the new correct behavior. Regarding the question about how to present the width variables that is a question of what might be easier/more intuitive for a user. My thinking was that for the purpose at hand my guess is that the user will more likely be thinking in terms of delta Q around the center rather than qmax? Another usability question that has come to mind is whether for the boxslicer as opposed to boxsum, it would not make much more sense (and be less confusing to a new user) if the default box was not drawn as a square from -.5 imagedQ to +.5 imagedQ in both directions. I would think something like -3/4 imagedQ to + 3/4 imagedQ (or even -1 to 1) in the direction of the q being scanned and maybe -.2 to +.2 in the direction of q being integrated. Note that by imagedQ I mean qmax-qcenter of the displayed data (image) |
@butlerpd To your other questions I can change and add the new functionality. Changing the parameter list and see if I can change the initial size of the box! |
@butlerpd will look at it |
See if @butlerpd can address at June hackathon otherwise remove PR and wait till someone has time |
There is a difference between very limited resources on a complex project and a stale project :-) |
This branch is 9 commits ahead, 1374 commits behind main. |
Unlike issues, branches get behind main and merging them gets harder and harder. If you don't want a stale label, please keep it up to date with main, preferably with log10(commit_difference) < 2. |
Changes were made to release 5.0.5 branch and attempted to be reverted 2 years ago. For reasons lost in the mists of time, 3 months later branch 5.0.5 was merged into this branch even though it was based on main and not being released? This led to 4 files from @dehoni work in a completely different branch becoming part of the changes in this branch compared to main. By usind checkout main --file, I've now updated the offending files with what is currently in main (the base) so that they should no longer be part of the pull request.
ce1e792
to
6e237d1
Compare
… comment in review)
* Fixed numerous typos in comments * Deleted unused (commented out) code * Fixed issue regarding question of default for fold param * Fixed issue of if statement not capturing incorrect value being passed for self.direction (added elif) * Fixed an unreported problem in numbper of parameters in a remove function (def restore(self, ev) instead of def restore(self)
The _post_data method calculates the bin widths to pass to manipulations.py. This probably should not be how it is done but is currently. This was still using the simple calculation based on a fixed center at 0,0 and thus caused havoc when moving the center around.
* The validate function was done twice. It has been moved from BoxInteractorX(Y) to BoxInteractor. * The validate function was expanded to minimize the chance of creating an ROI with no data in it (which would throw an error) * Added/simplified code in the move(ev) method of both horizontal and vertical lines interactor to prevent negative widths (which leads to no points in the ROI and thus throws an error)
As suggested by reviewer. The values should never be negative but it is unclear whether if they end up negative (should not be possible at this point) that absoluting them will yield the correct answer. Thus better for it to fail. Also fixed a couple more typos
The review comments asked for the dictionary set params for x and y widths be standardized. In fact it turned out that a) the widths were actually half widths and b) there was a variety of words used. The entire BoxSlicer.py code now uses half_width and half_height (and half_width_min etc). Also as per review, the abs(half_width/height) from set params was removed. It turns out the values should never be negative but it is unclear whether absoluting them if they end up negative (which should not be possible at this point) will yield the correct answer. Thus better for it to fail. also corrected the nbins calculation in _post_data for direction="Y" (the plus should have been a minus)
These files are part of main. It must have been part of an update of the branch. Anyway, the files are unrelated to this PR feature and only work on the general scattering calculator. |
ROI has no data error is impossible to catch without checking to see if any of the data are in the ROI. This is effectively done in manipulations.py as part of deciding what to average. Rather than check twice, use a try except to capture the ValueError that manipulations.py raises and report it in the log then negate the move.
Apply same checks to the Parameter editor data entry as is applied when entering slicer parameters graphically. * Make the validate function fully robust * As for the graphical interface, let manipulations.py check for no data in ROI and negate the entry if the error is flagged. * Note, we have added that the full ROI must remain on the plot not just the center point as was done originally and still is the case graphically. This might be something to fix graphically as well.
* Removed "restore" from onDrag in baseinteractor. It should never be needed since the illegal move is never recorded. Replaced it with a log message that attempt was made to go out of bounds. * Removed unused qmax variables from BoxInteractor where they do not seem to ever have been used. * In BoxInteractor, changed default self.half_height to 1.0 instead of 0.9 when direction = Y to match default self.half_width when direction = X (was leftover from old testing). * Removed super()._post_data from the inialization of the BoxInteractorX/Y. It was duplicating what was done in BaseInteractor (and didn't fail only because BaseInteractor had already run it properly). * Fixed bug in BoxInteractor._post_data that reversed the limits (ymin is from horizontal_lines not vertical_lines). Mostly OK due to redundancy but not totally robust.
One of the super()._post_data from the inialization of the BoxInteractorX/Y was accidentally ommitted in the previous commit.
Added code in the mov(ev) methods for all three objects (vertical and horizontal lines and the center point) to check that the move does not cause any part of the ROI to exit the data window.
All comments and concerns should now have been addressed. Also in testing a few new bugs were discovered and fixed and all user inputs now checked to avoid failures as documented in each of the commit messages. One question: The tests now log warning when the user tries to provide an invalid ROI. However, Warnings do not trigger opening the GUI console. Only Error level logging does. However the warning is meant as an aid to the user. Can we have warnings bring up the console? or should these messages be labelled as error even though I would argue they technically do not rise to the error level at this point? |
connect the top and right lines (those with the markers) so they can be moved without "catching" the marker. Particularly useful if the box becomes very narrow so that the center marker and line marker are on top of each other. This also matches the behavior of the sector slicer so also part of making slicers consistent.
Testing if latest PyInstaller fixes startup problem
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.
This is looking much better. I think almost there.
# Conflicts: # .github/workflows/ci.yml
Implemented a self.move_valid flag in order to only throw 1 logging.warning message until a valid move occurs to reset the flag. Unfortuantely this cannot be implemented yet in the onDrag of BaseInteractor as that would change the interface for all other classes deriving from BaseInteractor. Instead have removed the logging for now. In fact this check is no longer necessary for box interactor and not sure any other interactor except boxsum perhaps? So probably eventually remove that check from BaseInteractor.py altogether. Also changed the logging.error to logging.warning on the try except catch. TODO: either change all to loggin.error, lower the leve at which it starts the console log ... or decide not telling the user is OK.
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.
Minor nitpick at this point: The graphical box interactors won't allow me to extend/move to the edge of the data anymore, but that is mostly a visual issue.
Instead of ignoring moves that move an edge of the ROI box outside the data, reset the edge to the datamin or datamax as appropriate. This makes it easier to move a box to the edge of the data box and also makes it possible to vertically move a horizontal strip going from xmin to xmax etc.
I just tested the latest changes (from code, not the installer) and the user experience is much better. The box sides are coerced to the data limits and no warnings. Assuming the installers work, I think this can be merged. |
It still needs to have the ci.yml reverted. before merging. Will do after my meeting. We probably should also say something in the docs. The coercion to the edge worked a bit better for me the old way but the big advantage here that I think trumps all minor differences in usage is the fact that now you can slide the initial box up and down (or sideways depending on which slicer it is) without shrinking the box. Note I plan to update the docs in another PR. A lot of the changes will need documentation updates as well. |
This PR attempts to allow the box slicers to take slices whose center is not 0,0. if using the full q range of the long dimension this would be the same as giving slices at constant qx yielding I(qy|qx=constant) for example.