Skip to content

Commit

Permalink
Incorporated @stephprince suggestions on #1149.
Browse files Browse the repository at this point in the history
  • Loading branch information
cboulay committed Aug 28, 2024
1 parent 0ec4167 commit dc5cf24
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

### Bug fixes
- Fixed issue where scalar datasets with a compound data type were being written as non-scalar datasets @stephprince [#1176](https://github.com/hdmf-dev/hdmf/pull/1176)

### Bug fixes
- Fix H5DataIO not exposing `maxshape` on non-dci dsets. @cboulay [#1149](https://github.com/hdmf-dev/hdmf/pull/1149)
- Fixed H5DataIO not exposing `maxshape` on non-dci dsets. @cboulay [#1149](https://github.com/hdmf-dev/hdmf/pull/1149)

## HDMF 3.14.3 (July 29, 2024)

Expand Down
7 changes: 3 additions & 4 deletions src/hdmf/backends/hdf5/h5_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ...query import HDMFDataset, ReferenceResolver, ContainerResolver, BuilderResolver
from ...region import RegionSlicer
from ...spec import SpecWriter, SpecReader
from ...utils import docval, getargs, popargs, get_docval
from ...utils import docval, getargs, popargs, get_docval, get_data_shape


class HDF5IODataChunkIteratorQueue(deque):
Expand Down Expand Up @@ -681,6 +681,5 @@ def maxshape(self):
return self.data.maxshape
elif hasattr(self, "shape"):
return self.shape
elif 'shape' in self.io_settings:
return self.io_settings['shape']
return None
else:
return get_data_shape(self.data)
14 changes: 11 additions & 3 deletions tests/unit/test_io_hdf5_h5tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,15 +604,15 @@ def test_pass_through_of_chunk_shape_generic_data_chunk_iterator(self):
dset = self.f["test_dataset"]
self.assertEqual(dset.chunks, chunk_shape)

#############################################
# H5DataIO general
#############################################
def test_pass_through_of_maxshape_on_h5dataset(self):
k = 10
self.io.write_dataset(self.f, DatasetBuilder('test_dataset', np.arange(k), attributes={}))
dset = H5DataIO(self.f['test_dataset'])
self.assertEqual(dset.maxshape, (k,))

#############################################
# H5DataIO general
#############################################
def test_warning_on_non_gzip_compression(self):
# Make sure no warning is issued when using gzip
with warnings.catch_warnings(record=True) as w:
Expand Down Expand Up @@ -3769,6 +3769,14 @@ def test_dataio_shape_then_data(self):
with self.assertRaisesRegex(ValueError, "Setting data when dtype and shape are not None is not supported"):
dataio.data = list()

def test_dataio_maxshape(self):
dataio = H5DataIO(data=np.arange(10), maxshape=(None,))
self.assertEqual(dataio.maxshape, (None,))

def test_dataio_maxshape_from_data(self):
dataio = H5DataIO(data=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
self.assertEqual(dataio.maxshape, (10,))


def test_hdf5io_can_read():
assert not HDF5IO.can_read("not_a_file")
Expand Down

0 comments on commit dc5cf24

Please sign in to comment.