Skip to content

Commit

Permalink
mereged in old patches for issue h5py#225
Browse files Browse the repository at this point in the history
  • Loading branch information
tacaswell committed Feb 20, 2013
1 parent da4893a commit e39e80e
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 4 deletions.
3 changes: 3 additions & 0 deletions h5py/api_functions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ hdf5:
herr_t H5Pset_char_encoding(hid_t plist_id, H5T_cset_t encoding)
herr_t H5Pget_char_encoding(hid_t plist_id, H5T_cset_t *encoding)

herr_t H5Pset_obj_track_times( hid_t ocpl_id, hbool_t track_times )
herr_t H5Pget_obj_track_times( hid_t ocpl_id, hbool_t *track_times )

herr_t H5Pset_local_heap_size_hint(hid_t plist_id, size_t size_hint)
herr_t H5Pget_local_heap_size_hint(hid_t plist_id, size_t *size_hint)
herr_t H5Pset_link_phase_change(hid_t plist_id, unsigned max_compact, unsigned min_dense)
Expand Down
60 changes: 56 additions & 4 deletions h5py/h5p.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ cdef object propwrap(hid_t id_in):
pcls = PropLAID
elif H5Pequal(clsid, H5P_GROUP_CREATE):
pcls = PropGCID
elif H5Pequal(clsid, H5P_OBJECT_CREATE):
pcls = PropOCID

else:
raise ValueError("No class found for ID %d" % id_in)

Expand All @@ -72,16 +75,20 @@ cdef object lockcls(hid_t id_in):

# Property list classes
# These need to be locked, as the library won't let you close them.


NO_CLASS = lockcls(H5P_NO_CLASS)
FILE_CREATE = lockcls(H5P_FILE_CREATE)
FILE_ACCESS = lockcls(H5P_FILE_ACCESS)
DATASET_CREATE = lockcls(H5P_DATASET_CREATE)
DATASET_XFER = lockcls(H5P_DATASET_XFER)

OBJECT_COPY = lockcls(H5P_OBJECT_COPY)

LINK_CREATE = lockcls(H5P_LINK_CREATE)
LINK_ACCESS = lockcls(H5P_LINK_ACCESS)
GROUP_CREATE = lockcls(H5P_GROUP_CREATE)
OBJECT_CREATE = lockcls(H5P_OBJECT_CREATE)

DEFAULT = None # In the HDF5 header files this is actually 0, which is an
# invalid identifier. The new strategy for default options
Expand All @@ -104,6 +111,7 @@ def create(PropClassID cls not None):
- LINK_ACCESS
- GROUP_CREATE
- OBJECT_COPY
- OBJECT_CREATE
"""
cdef hid_t newid
newid = H5Pcreate(cls.id)
Expand Down Expand Up @@ -671,18 +679,36 @@ cdef class PropDCID(PropCreateID):
and general restrictions on use of the SZIP format.
"""
H5Pset_szip(self.id, options, pixels_per_block)

def set_scaleoffset(self, H5Z_SO_scale_type_t scale_type, int scale_factor):
'''(H5Z_SO_scale_type_t scale_type, INT scale_factor)
Enable scale/offset (usually lossy) compression; lossless (e.g. gzip)
compression and other filters may be applied on top of this.
Note that error detection (i.e. fletcher32) cannot precede this in
the filter chain, or else all reads on lossily-compressed data will
fail.'''
H5Pset_scaleoffset(self.id, scale_type, scale_factor)

def set_obj_track_times(self,track_times):
"""Sets the recording of times associated with an object."""
H5Pset_obj_track_times(self.id,track_times)

def get_obj_track_times(self):
"""
Determines whether times associated with an object are being recorded.
"""

cdef hbool_t track_times

H5Pget_obj_track_times(self.id,&track_times)

return track_times




# File access
cdef class PropFAID(PropInstanceID):

Expand Down Expand Up @@ -1037,14 +1063,40 @@ cdef class PropGCID(PropCreateID):
""" Group creation property list """
pass

def set_obj_track_times(self,track_times):
"""Sets the recording of times associated with an object."""
H5Pset_obj_track_times(self.id,track_times)
def get_obj_track_times(self):
"""
Determines whether times associated with an object are being recorded.
"""

cdef hbool_t track_times

H5Pget_obj_track_times(self.id,&track_times)

return track_times


# Object creation property list
cdef class PropOCID(PropCreateID):
""" Object creation property list
This seems to be a super class for dataset creation property list
and group creation property list.
The documentation is somewhat hazy
"""
def set_obj_track_times(self,track_times):
"""Sets the recording of times associated with an object."""
H5Pset_obj_track_times(self.id,track_times)
def get_obj_track_times(self):
"""
Determines whether times associated with an object are being recorded.
"""

cdef hbool_t track_times

H5Pget_obj_track_times(self.id,&track_times)


return track_times
27 changes: 27 additions & 0 deletions h5py/lowtest/test_h5p.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,30 @@ def test_libver(self):
self.assertEqual((h5f.LIBVER_EARLIEST, h5f.LIBVER_LATEST),
plist.get_libver_bounds())

class TestPL(ut.TestCase):
def test_obj_track_times(self):
"""
tests if the object track times set/get
"""
# test for groups
gcid = h5p.create(h5p.GROUP_CREATE)
gcid.set_obj_track_times(False)
self.assertEqual(False,gcid.get_obj_track_times())

gcid.set_obj_track_times(True)
self.assertEqual(True,gcid.get_obj_track_times())
# test for datasets
dcid = h5p.create(h5p.DATASET_CREATE)
dcid.set_obj_track_times(False)
self.assertEqual(False,dcid.get_obj_track_times())

dcid.set_obj_track_times(True)
self.assertEqual(True,dcid.get_obj_track_times())

# test for generic objects
ocid = h5p.create(h5p.OBJECT_CREATE)
ocid.set_obj_track_times(False)
self.assertEqual(False,ocid.get_obj_track_times())

ocid.set_obj_track_times(True)
self.assertEqual(True,ocid.get_obj_track_times())

0 comments on commit e39e80e

Please sign in to comment.