-
Notifications
You must be signed in to change notification settings - Fork 27
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
Allow DataViews to become invalid fixes #502 #516
Conversation
This pull request introduces 1 alert when merging 9a245a2 into f2c0cd6 - view on LGTM.com new alerts:
|
Codecov Report
@@ Coverage Diff @@
## master #516 +/- ##
==========================================
+ Coverage 81.25% 81.30% +0.04%
==========================================
Files 81 81
Lines 10538 10730 +192
==========================================
+ Hits 8563 8724 +161
- Misses 1975 2006 +31
Continue to review full report at Codecov.
|
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.
Looks good to me
nixio/data_view.py
Outdated
"does not contain data.".format(slices) | ||
) | ||
else: | ||
self._error_message = "" |
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.
Îf I read this line correctly this is the initialization of the self._error_message
attribute. Why not move this line to before the if ...
and remove the else
clause. The first time I read it, I found it a bit confusing.
nixio/tag.py
Outdated
else: | ||
if dimunit is None and unit is not None: | ||
raise IncompatibleDimensions( | ||
"Units of position and SampledDimension " |
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.
Should "RangeDimension" also be considered at this point?
no exceptions are thrown upon creation, DataView is invalid though and reading the data will return an empty array Adds a "debug_message" to troubleshoot why the DV might be empty Adapts the tests
and returns the new position as well as the scaling factor, this is done to separate scaling and getting the index for ranges/slices where we need more control
the respective dimension
the returned DataView will be invalid, though
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.
Looks good to me now.
This PR changes the way ranges along a dimension are calculated.
allows DataView to be invalid and reading access will return an empty array
range calculation is delegated to the dimensions respecting the SliceMode.
allows for some simplification of the BaseTag._calc_data_slice method
We do not necessarily return at minimum a single value along a given dimension. If there are no data points between start and end position the range is invalid and the DataView will become invalid and return an empty array. Just like slicing a numpy array that does not return a result.
Invalid DataViews return no data extent, write access will raise an exception. They offer a "debug message" containing the reason of their invalidity.
I might be that I went a little far with removing the OOB and IncompatibleDimensions exceptions from DataView, happy to have your opinions..