-
Notifications
You must be signed in to change notification settings - Fork 4
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
HDF5Base
can identify empty objects
#330
Conversation
e12e1f0
to
681554f
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #330 +/- ##
===================================
Coverage 26% 26%
===================================
Files 69 69
Lines 3674 3699 +25
===================================
+ Hits 952 976 +24
- Misses 2722 2723 +1
☔ View full report in Codecov by Sentry. |
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 substantial comments. You can take or leave these...
// the object. | ||
return file_->isHdf5(filename_); | ||
// return file_->isAccessible(filename_) && file_->isHdf5(filename_); | ||
} | ||
|
||
bool HDF5Base::flagged_MATLAB_empty(const std::string &object_path) const { |
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.
Maybe is_flagged_as_MATLAB_empty(object_path)
?
I don't insist though.
# Create test data to read in | ||
consecutive_numbers = np.arange(0, 12, dtype=float) | ||
|
||
# Create a group under root | ||
read_in_test = file.require_group("read_in_test") |
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, however, does need a comment because it's weird to me that require_group
creates a group.
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.
#libhdf5-world-problems
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.
That's h5py
for you 😅
Co-authored-by: Sam Cunliffe <[email protected]>
Context
Naturally, MATLAB does not save empty arrays or structs as objects with no elements or zero-size, instead it saves them as 2-by-1 arrays with 0's populating the data. This means that a simple comparison against the number of elements or members does not provide the correct information when attempting to determine whether an empty input has been passed.
MATLAB does however attach an attribute to any object that it marks as empty:
MATLAB_empty
. Thisuint8
is set to 1 if the object is indeed an empty array, so that is what we will use to distinguish.mxIsEmpty
function).Details
Adds the
HDF5Base::flagged_MATLAB_empty
method to replace themxIsEmpty
function, which a number of our classes depend on when reading from the input file.Going forward, if the input generation is ever moved away from MATLAB too, a workaround will need to be decided to replace/handle
.hdf5
files that are not created with MATLAB, as the analogue of this flag will not exist.Testing
tdms/tests/unit/hdf5_io/test_hdf5_base.cpp
added with extensive tests for the newflagged_MATLAB_empty
method..mat
and.hdf5
unit test data has been updated with the necessary additions