Make conversion and offset required on TimeSeries children with required units - #2258
Open
h-mayorquin wants to merge 3 commits into
Open
h-mayorquin wants to merge 3 commits into
h-mayorquin wants to merge 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #2258 +/- ##
==========================================
+ Coverage 96.17% 96.19% +0.02%
==========================================
Files 30 30
Lines 3003 3021 +18
Branches 437 442 +5
==========================================
+ Hits 2888 2906 +18
Misses 65 65
Partials 50 50
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
ElectricalSeries,CurrentClampSeries,CurrentClampStimulusSeries,VoltageClampSeriesandVoltageClampStimulusSeriesfix the unit of their data, but until now a user could create one without saying anything about calibration and PyNWB would quietly writeconversion=1.0andoffset=0.0. AnElectricalSeriesbuilt from raw int16 samples then states that the integer 17 is 17 volts.These five types now warn when they are created without a
conversionor anoffset, and that will raise an error in PyNWB 4.4.0. Passingchannel_conversioncounts as passing aconversion, since a per-channel scaling already carries the calibration, and that exemption is why the check belongs here rather than in the schema, which cannot express a dependency between the two fields. I am unsure on whether we should raise and when the warning should become a raise, I am open for suggestions. I picked this as a compromise between producing wrong data (which pushes for urgency and raise now) but give some air to people that already have scripts running (which would push for version 5.0).TimeSeriesnow declaresconversionandoffsetwith a default ofNoneand resolves them to the old1.0and0.0at the top of its__init__, which is what lets the five subtypes tell an explicit1.0apart from an unspecified one. Because that resolution happens inside the constructor, the container never carries aNone, so a file produced by unchanged user code is identical to before and the only other visible effect is thatconversion=Noneis now accepted on anyTimeSeriesinstead of raising a type error. This was just for an easy implementation of the behavior above on the first paragraph. Maybe there is a better one.How to test the behavior?
Fix #2257, and see NeurodataWithoutBorders/nwb-schema#671 and NeurodataWithoutBorders/nwb-schema#670 for the schema side of this.
Checklist
ruff check . && codespellfrom the source directory.