-
Notifications
You must be signed in to change notification settings - Fork 524
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
Add H5Pget_meta_block_size and H5Pset_meta_block_size support #2106
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2106 +/- ##
==========================================
+ Coverage 90.00% 90.02% +0.02%
==========================================
Files 17 17
Lines 2350 2357 +7
==========================================
+ Hits 2115 2122 +7
Misses 235 235
Continue to review full report at Codecov.
|
Thanks, this looks good. I spotted that in the docs you seem to use a mixture of 'metadata' and 'meta data' - let's make this consistent. 'Metadata' is the more familiar form for me, and this is also how it's spelled in the HDF5 docs we link to. |
I'm not sure what to make of the Travis error. |
@takluyver Thanks for the previous review. The docs have been fixed. Is there anything else to do here? |
h5py/tests/test_file2.py
Outdated
self.mktemp(), 'w', | ||
meta_block_size=meta_block_size | ||
) as f: | ||
self.assertTrue(f) |
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 is probably superfluous.
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.
Removed in ae9b8d4
h5py/tests/test_file2.py
Outdated
) as f: | ||
self.assertTrue(f) | ||
f["test"] = 5 | ||
self.assertTrue(f.meta_block_size) == meta_block_size |
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.
self.assertTrue(f.meta_block_size) == meta_block_size | |
self.assertEqual(f.meta_block_size, meta_block_size) |
And likewise for the other assertions, otherwise they're not really asserting what they look like.
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.
Good point. I fixed this in ae9b8d4
I'm not sure what happened on Travis either, but I re-ran the job and it succeeded this time. |
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 assertGreaterEqual is better for the test for HDF5 1.8 compat
h5py/tests/test_file2.py
Outdated
@pytest.mark.skipif(h5py.version.hdf5_version_tuple < (1, 10, 2), | ||
reason="HDF5 header became smaller in version v1.8") | ||
def test_file_create_with_meta_block_size_libver(self): | ||
meta_block_size = 512 | ||
libver = "v108" |
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 might get rid of this test entirely - h5py tests shouldn't depend on the precise details of how HDF5 allocates space in its files from version to version. I think the test above with assertGreaterEqual
is sufficient.
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 option exists to manipulate how HDF5 allocates space in the file. That's the point.
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.
The default meta_block_size
is 2048 bytes
Thus we need two tests here:
- One greater than the default
meta_block_size
: 4096 bytes - One less than the default
meta_block_size
: 512 bytes
I have removed version restrictions on both tests. They both now use assertGreaterEqual
so that both tests will pass on HDF5 1.8. I added an upper bound on the 512 byte test to differentiate it from the situation when the default meta_block_size
is used.
for both 512 and 4096 byte meta_block_size tests
I modified the test so that both tests now apply to HDF5 1.8. They both now use I added comments detailing that we can expect equality for these tests for HDF5 1.10 and greater. I have kept both tests in because they test values that are greater than and less than the default I added comments detailing the default size in the tests. |
Thanks @mkitti ! |
Here we add support for
H5Pget_meta_block_size
andH5Pset_meta_block_size
.h5py.File
gets a newmeta_block_size
keyword argument that defaults toNone
.h5py.File
also gets a new propertymeta_block_size
.This feature sets the minimum meta block size that the HDF5 will allocate. This can be used to regularize the size of the header and the space between datasets. Setting a large meta block size can consolidate the meta data into a single large header. Setting a small meta block size can minimize the space needed for the HDF5 header.
Note that this influences a file access property. The value is not stored in the file.