Fix: Bug in writeCompound / parseCompound functions #620
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
The following lines in
io.writeCompoundalways evaluates tofalse, because the value in the field of the data structure is per definition a logical array. It also evaluates to a scalar, so it will not work if the field value is a logical vector.matnwb/+io/writeCompound.m
Lines 96 to 99 in d970ef1
After fixing this, (for some reason which I don't know/understand) the respective part of parseCompound must also be updated:
matnwb/+io/parseCompound.m
Lines 51 to 55 in d970ef1
The expected behavior (in matnwb) when writing logicals via the
int8data type is that it will create an int8 enum type in the h5 file with values equal toTRUEorFALSE. However, when reading values back, the values are of typeint8. The actualtidof the data (h5 type id) indicates that the data should be an "enum boolean", but the values are not.This might have something to do how the compound data type is set up in h5, but I do not know the hdf5 library, so I can't judge if the following should work or not:
matnwb/+io/writeCompound.m
Lines 79 to 83 in d970ef1
The proposed fix does work in the unit test, and will also work if data would be read in as a "boolean enum" (TRUE/FALSE) values.
How to test the behavior?
run unit tests in
tests.unit.io.WriteTestChecklist
fix #XXwhereXXis the issue number?