-
Notifications
You must be signed in to change notification settings - Fork 6
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
Use more explicit errors and warnings in data cleaning #79
Conversation
for more information, see https://pre-commit.ci
Codecov Report
@@ Coverage Diff @@
## master #79 +/- ##
==========================================
+ Coverage 48.24% 50.46% +2.22%
==========================================
Files 19 21 +2
Lines 3646 3725 +79
==========================================
+ Hits 1759 1880 +121
+ Misses 1887 1845 -42
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
I also added x and y limits to the |
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.
Mostly nits. In general I'm totally on board with this and I strongly believe clear warnings and errors are the bread and butter to build a satisfying UX.
amical/tests/test_tools.py
Outdated
img_size = 80 # Same size as NIRISS images | ||
img = np.ones((img_size, img_size)) | ||
xmax, ymax = 17, 57 | ||
img[ymax, xmax] = img.max() * 5 # Add off-centered max pixel |
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 looks like a very particular case, maybe it'd make a more robust test if the image was random. You can then manually set the center to the lowest value since it's important for this test that the max be off-centered
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.
Do you mean making the whole image random instead of ones and one value > 1 ? Or do you mean making the max position random? I'm not sure what you by "manually set the center to the lowest value". Also, after looking into it a bit more, it should not matter that the location is off-centered, as long as the cropped size is bigger than the distance to the edges.
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 made the test random in the last commit. Should I use pytest-repeat
to repeat the test a few times to make it more robust ?
Co-authored-by: Clément Robert <cr52@protonmail.com>
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
While reviewing this, I added a test for the default behaviour of
I decided to add these changes here directly because they are close to the other changes, which aim to make the cleaning step more transparent for users. Also, I felt like having a clearly defined (and tested) default behaviour will make future changes easier to develop and test, so I wanted to add the changes upstream as quickly as possible. |
When playing with simulated NIRISS data, I encountered a few corner cases during the cleaning due to the small size (80x80) of the images. The problems were not caught and resulted in error later when the image was re-used:
isz
that went out of bounds gave a non-square array and did not warn the user. After discussing with @DrSoulain, we chose to simply raise and error and suggest maximum possible value to the user.NaN
value for the whole background. Now, there is a warning and the background subraction is skipped (same behaviour as the previous one if anIndexError
was caught.r1
is used.I also added tests for these changes in two new files
test_processing.py
andtest_tools.py
.