-
Notifications
You must be signed in to change notification settings - Fork 86
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
Avoid raising data timestamps length mismatch warning with external file #1486
Avoid raising data timestamps length mismatch warning with external file #1486
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #1486 +/- ##
==========================================
+ Coverage 78.30% 78.42% +0.12%
==========================================
Files 37 37
Lines 2761 2777 +16
Branches 488 493 +5
==========================================
+ Hits 2162 2178 +16
Misses 518 518
Partials 81 81
Continue to review full report at Codecov.
|
from @oruebel: better would be to implement the check as a protected method in |
src/pynwb/image.py
Outdated
@staticmethod | ||
def _check_data_timestamps_mismatch(data, timestamps): | ||
return not np.array_equal(data, ImageSeries.DEFAULT_DATA) and timestamps is not None | ||
|
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.
@rly I have an issue with this, since this check is in the TimeSeries init, I'm not sure how
to pass the external_file or format as kwargs. I noticed this TODO,
Line 76 in a62c4e9
# TODO catch warning when default data is used and timestamps are provided |
which is connected to this warning I believe. So instead of overwriting that method with an additional check, I could ignore the warning when external file is provided within the ImageSeries init?
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.
does this method need to be static?
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.
No, but currently that would not help I think, because the check method gets called here
Line 77 in a62c4e9
super().__init__(**kwargs) |
before setting
self.external_file
with whatever value is in args_to_set
Lines 78 to 82 in a62c4e9
if args_to_set["external_file"] is None: | |
args_to_set["starting_frame"] = None # overwrite starting_frame | |
for key, val in args_to_set.items(): | |
setattr(self, key, val) |
Thank you @rly! |
@weiglszonja add to changelog please :-) |
starting_frame=[0], | ||
timestamps=[1, 2, 3, 4] | ||
) | ||
self.assertEqual(w, []) |
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.
Can we also add a test to ensure that using an external file and a rate
instead of timestamps
does not raise a warning?
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.
Sure, I added a new unittest.
Motivation
Minor issue, but storing images (e.g.
ImageSeries
) with external mode raises aUserWarning
that the length of data does not match the length of timestamps. However whenexternal_file
is specified (not None), data is not used and therefore this kind of warning should not be raised.pynwb/src/pynwb/base.py
Lines 184 to 185 in d38cc78
How to test the behavior?
New unittest is added at
test_image.ImageSeriesConstructor.test_external_file_no_warning
to test new behavior.Checklist
flake8
from the source directory.