/usr/lib/python2.7/dist-packages/h5py/tests/old/test_h5d_direct_chunk_write.py is in python-h5py 2.7.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | from __future__ import absolute_import
import h5py
import numpy
from ..common import ut, TestCase
@ut.skipUnless(h5py.version.hdf5_version_tuple >= (1, 8, 11), 'Direct Chunk Writing requires HDF5 >= 1.8.11')
class TestWriteDirectChunk(TestCase):
def test_write_direct_chunk(self):
filename = self.mktemp().encode()
filehandle = h5py.File(filename, "w")
dataset = filehandle.create_dataset("data", (100, 100, 100),
maxshape=(None, 100, 100),
chunks=(1, 100, 100),
dtype='float32')
# writing
array = numpy.zeros((10, 100, 100))
for index in range(10):
a = numpy.random.rand(100, 100).astype('float32')
dataset.id.write_direct_chunk((index, 0, 0), a.tostring(), filter_mask=1)
array[index] = a
filehandle.close()
# checking
filehandle = h5py.File(filename, "r")
for i in range(10):
read_data = filehandle["data"][i]
self.assertTrue((array[i] == read_data).all())
|