-
Notifications
You must be signed in to change notification settings - Fork 84
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
Fix bad validation check for postion in ElectrodeGroup.__init__ #1770
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #1770 +/- ##
==========================================
+ Coverage 91.85% 91.87% +0.01%
==========================================
Files 27 27
Lines 2689 2695 +6
Branches 701 703 +2
==========================================
+ Hits 2470 2476 +6
Misses 145 145
Partials 74 74
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Just some detective work for background:
Given that it has take 3 years for this issue to surface, it seems that |
@@ -25,7 +25,8 @@ def setUpContainer(self): | |||
eg = ElectrodeGroup(name='elec1', | |||
description='a test ElectrodeGroup', | |||
location='a nonexistent place', | |||
device=self.dev1) | |||
device=self.dev1, | |||
position=[(1., 2., 3.), ]) |
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.
One question - why is this a list at all? Is there a case where we would have multiple tuples in this list? What would that represent?
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 also wasn't sure what the use case of the list would be - I added a test case with multiple tuples for now but not sure if that is necessary?
src/pynwb/ecephys.py
Outdated
position_dtype_valid = False | ||
if position_dtype_valid: # If we have list of element, then check that the elements are of length 3 | ||
try: | ||
if len(args_to_set['position'][0]) != 3: |
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.
Checking only the first element here seems to imply that this value should only be a single tuple of length 2 or 3 and that we would not expect more than one to be passed in the list input
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.
We could iterate through all elements. I believe I just wanted to avoid checking all elements to keep runtime short in case there are a lot of values .
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 updated this to iterate and check the length of all the position elements
@oruebel Any updates on this PR? |
@stephprince could you take a look at this PR. I think this is essentially complete but needs some final attention to get over the finish line. |
@stephprince do you have a chance to take a look at this? thanks! |
Yes sorry for the delay I'll take a look! |
@rly this is ready to review |
The schema here says:
I.e., position is a compound dataset but the shape is not specified. Looking at the schema language docs here, I believe this means that Question, how does the input for scalar compound datasets need to look like? Looking at the source issue #1768 setting:
Specifying as |
After some further investigation, it turned out that scalar datasets with a compound datatype were being written incorrectly so that the dataset was not scalar. These changes should be addressed in the upcoming hdmf release (3.14.4), but the tests will fail until that is released. With the hdmf update, I believe |
This looks good to me but I will let @stephprince review and approve to merge. |
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 for the updates @rly. All looks good to me.
I will fix the broken links in a separate PR.
Motivation
Fix #1768
ElectrodeGroup.position
is a compound dataset ofx,y,z
positions, butElectrodeGroup.__init__
validates it wrongly by enforcing that the array has 3 elements instead of checking that the elements have 3 elements. This PR updatesElectrodeGroup.__init__
to validateElectrodeGroup.position
correctlyHow to test the behavior?
See the linked issue for details
Checklist
flake8
from the source directory.