[h5py] 22/455: h5p, h5t additions
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:13 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to annotated tag 1.3.0
in repository h5py.
commit cb6f235ea85af7c947afe75ec92801cea60e58eb
Author: andrewcollette <andrew.collette at gmail.com>
Date: Fri May 16 23:48:55 2008 +0000
h5p, h5t additions
---
h5py/h5p.pxd | 26 ++++++++--
h5py/h5p.pyx | 126 +++++++++++++++++++++++++++++++++++++++++++++++--
h5py/h5t.pxd | 25 ++++++++--
h5py/h5t.pyx | 97 ++++++++++++++++++++++++-------------
h5py/tests/__init__.py | 3 +-
5 files changed, 230 insertions(+), 47 deletions(-)
diff --git a/h5py/h5p.pxd b/h5py/h5p.pxd
index bfafc59..247c3c7 100644
--- a/h5py/h5p.pxd
+++ b/h5py/h5p.pxd
@@ -39,6 +39,29 @@ cdef extern from "hdf5.h":
herr_t H5Pclose(hid_t plist_id)
htri_t H5Pequal( hid_t id1, hid_t id2 )
+ # File creation properties
+ herr_t H5Pget_version(hid_t plist, unsigned int *super_, unsigned int* freelist,
+ unsigned int *stab, unsigned int *shhdr)
+ herr_t H5Pset_userblock(hid_t plist, hsize_t size)
+ herr_t H5Pget_userblock(hid_t plist, hsize_t * size)
+ herr_t H5Pset_sizes(hid_t plist, size_t sizeof_addr, size_t sizeof_size)
+ herr_t H5Pget_sizes(hid_t plist, size_t *sizeof_addr, size_t *sizeof_size)
+ herr_t H5Pset_sym_k(hid_t plist, unsigned int ik, unsigned int lk)
+ herr_t H5Pget_sym_k(hid_t plist, unsigned int *ik, unsigned int *lk)
+ herr_t H5Pset_istore_k(hid_t plist, unsigned int ik)
+ herr_t H5Pget_istore_k(hid_t plist, unsigned int *ik )
+
+ # File access
+ herr_t H5Pset_fclose_degree(hid_t fapl_id, H5F_close_degree_t fc_degree)
+ herr_t H5Pget_fclose_degree(hid_t fapl_id, H5F_close_degree_t *fc_degree)
+ herr_t H5Pset_fapl_core( hid_t fapl_id, size_t increment, hbool_t backing_store)
+ herr_t H5Pget_fapl_core( hid_t fapl_id, size_t *increment, hbool_t *backing_store)
+ herr_t H5Pset_fapl_family ( hid_t fapl_id, hsize_t memb_size, hid_t memb_fapl_id )
+ herr_t H5Pget_fapl_family ( hid_t fapl_id, hsize_t *memb_size, hid_t *memb_fapl_id )
+ herr_t H5Pset_family_offset ( hid_t fapl_id, hsize_t offset)
+ herr_t H5Pget_family_offset ( hid_t fapl_id, hsize_t *offset)
+ herr_t H5Pset_fapl_log(hid_t fapl_id, char *logfile, unsigned int flags, size_t buf_size)
+
# Dataset creation properties
herr_t H5Pset_layout(hid_t plist, H5D_layout_t layout )
H5D_layout_t H5Pget_layout(hid_t plist)
@@ -68,10 +91,7 @@ cdef extern from "hdf5.h":
herr_t H5Pset_fletcher32(hid_t plist)
herr_t H5Pset_shuffle(hid_t plist_id)
herr_t H5Pset_szip(hid_t plist, unsigned int options_mask, unsigned int pixels_per_block)
- # external files not implemented
- # File access
- herr_t H5Pset_fclose_degree(hid_t fapl_id, H5F_close_degree_t fc_degree)
# Transfer properties
herr_t H5Pset_edc_check(hid_t plist, H5Z_EDC_t check)
diff --git a/h5py/h5p.pyx b/h5py/h5p.pyx
index 8dd5ba2..448bdf9 100644
--- a/h5py/h5p.pyx
+++ b/h5py/h5p.pyx
@@ -13,9 +13,6 @@
"""
HDF5 property list interface.
-
- This module is currently incomplete; functions exist for generic operations
- and dataset creation property lists, but not much else.
"""
# Pyrex compile-time imports
@@ -24,7 +21,6 @@ from h5 cimport herr_t, hid_t, htri_t, herr_t, hsize_t
from h5d cimport H5D_layout_t
from h5z cimport H5Z_filter_t
from utils cimport tuple_to_dims, dims_to_tuple
-from numpy cimport PyArray_CheckScalar, PyArray_ScalarAsCtype
# Runtime imports
import h5
@@ -104,6 +100,128 @@ def equal(hid_t plist1, hid_t plist2):
raise PropertyError("Could not compare for equality: %d vs %d" % (plist1, plist2))
return bool(retval)
+# === File creation ===========================================================
+def get_version(hid_t plist):
+ """ (INT plist) => TUPLE version_info [File creation]
+
+ Determine version information of various file attributes. Elements are:
+
+ 0: UINT Super block version number
+ 1: UINT Freelist version number
+ 2: UINT Symbol table version number
+ 3: UINT Shared object header version number
+ """
+ cdef herr_t retval
+ cdef unsigned int super_
+ cdef unsigned int freelist
+ cdef unsigned int stab
+ cdef unsigned int shhdr
+
+ retval = H5Pget_version(plist, &super_, &freelist, &stab, &shhdr)
+ if retval < 0:
+ raise PropertyError("Failed to determine version info for list %d" % plist)
+ return (super_, freelist, stab, shhdr)
+
+def set_userblock(hid_t plist, long size):
+ """ (INT plist, LONG size) [File creation]
+
+ Set the file user block size, in bytes. Must be a power of 2, and at
+ least 512.
+ """
+ cdef herr_t retval
+ retval = H5Pset_userblock(plist, <hsize_t>size)
+ if retval < 0:
+ raise PropertyError("Failed to set userblock size to %d on list %d" % (size, plist))
+
+def get_userblock(hid_t plist):
+ """ (INT plist) => LONG size [File creation]
+
+ Determine the user block size, in bytes.
+ """
+ cdef herr_t retval
+ cdef hsize_t size
+
+ retval = H5Pget_userblock(plist, &size)
+ if retval < 0:
+ raise PropertyError("Failed to determine user block size on list %d" % plist)
+ return size
+
+def set_sizes(hid_t plist, size_t addr, size_t size):
+ """ (INT plist, INT addr, INT size) [File creation]
+
+ Set the addressing offsets and lengths for objects in an HDF5 file, in
+ bytes.
+ """
+ cdef herr_t retval
+ retval = H5Pset_sizes(plist, addr, size)
+ if retval < 0:
+ raise PropertyError("Failed to set sizes on list %d (addr %d, length %d)" % (plist, addr, size))
+
+def get_sizes(hid_t plist):
+ """ (INT plist) => TUPLE sizes [File creation]
+
+ Determine addressing offsets and lengths for objects in an HDF5 file, in
+ bytes. Return value is a 2-tuple with values:
+
+ 0: UINT Address offsets
+ 1: UINT Lengths
+ """
+ cdef herr_t retval
+ cdef size_t addr
+ cdef size_t size
+ retval = H5Pget_sizes(plist, &addr, &size)
+ if retval < 0:
+ raise PropertyError("Failed to get sizes for plist %d" % plist)
+ return (addr, size)
+
+def set_sym_k(hid_t plist, unsigned int ik, unsigned int lk):
+ """ (INT plist, INT ik, INT lk) [File creation]
+
+ Symbol table node settings. See the HDF5 docs for H5Pset_sym_k.
+ """
+ cdef herr_t retval
+ retval = H5Pset_sym_k(plist, ik, lk)
+ if retval < 0:
+ raise PropertyError("Failed to set symbol table params on list %d" % plist)
+
+def get_sym_k(hid_t plist):
+ """ (INT plist) => TUPLE settings [File creation]
+
+ Determine symbol table node settings. See the HDF5 docs for
+ H5Pget_sym_k. Return is a 2-tuple (ik, lk).
+ """
+ cdef herr_t retval
+ cdef unsigned int ik
+ cdef unsigned int lk
+
+ retval = H5Pget_sym_k(plist, &ik, &lk)
+ if retval < 0:
+ raise PropertyError("Failed to get symbol table params on list %d" % plist)
+ return (ik, lk)
+
+def set_istore_k(hid_t plist, unsigned int ik):
+ """ (INT plist, UINT ik) [File creation]
+
+ See hdf5 docs for H5Pset_istore_k.
+ """
+ cdef herr_t retval
+ retval = H5Pset_istore_k(plist, ik)
+ if retval < 0:
+ raise PropertyError("Failed to set istore params on list %d (value %d)" % (plist,ik))
+
+def get_istore_k(hid_t plist):
+ """ (INT plist) => UINT ik [File creation]
+
+ See HDF5 docs for H5Pget_istore_k
+ """
+ cdef herr_t retval
+ cdef unsigned int ik
+
+ retval = H5Pget_istore_k(plist, &ik)
+ if retval < 0:
+ raise PropertyError("Failed to get istore params on list %d" % plist)
+ return ik
+
# === Dataset creation properties =============================================
def set_layout(hid_t plist, int layout_code):
diff --git a/h5py/h5t.pxd b/h5py/h5t.pxd
index 6a5dcd7..6a7ea1b 100644
--- a/h5py/h5t.pxd
+++ b/h5py/h5t.pxd
@@ -52,6 +52,12 @@ cdef extern from "hdf5.h":
H5T_SGN_2 = 1, # two's complement
H5T_NSGN = 2 # this must be last!
+ # Atomic datatype padding
+ cdef enum H5T_pad_t:
+ H5T_PAD_ZERO = 0,
+ H5T_PAD_ONE = 1,
+ H5T_PAD_BACKGROUND = 2
+
# HDF5 type classes
cdef enum H5T_class_t:
H5T_NO_CLASS = -1, # error
@@ -123,25 +129,36 @@ cdef extern from "hdf5.h":
herr_t H5Tcommit(hid_t loc_id, char* name, hid_t type)
htri_t H5Tcommitted(hid_t type)
hid_t H5Tcopy(hid_t type_id)
+ htri_t H5Tequal(hid_t type_id1, hid_t type_id2 )
+ herr_t H5Tlock(hid_t type_id )
H5T_class_t H5Tget_class(hid_t type_id)
+ size_t H5Tget_size(hid_t type_id )
hid_t H5Tget_super(hid_t type)
htri_t H5Tdetect_class(hid_t type_id, H5T_class_t dtype_class)
herr_t H5Tclose(hid_t type_id)
- herr_t H5Tconvert(hid_t src_id, hid_t dst_id, size_t nelmts, void *buf, void *background, hid_t plist_id )
+
+ # Not for public API
+ #hid_t H5Tget_native_type(hid_t type_id, H5T_direction_t direction)
+ herr_t H5Tconvert(hid_t src_id, hid_t dst_id, size_t nelmts, void *buf, void *background, hid_t plist_id)
# Atomic datatypes
- size_t H5Tget_size(hid_t type_id)
herr_t H5Tset_size(hid_t type_id, size_t size)
+
H5T_order_t H5Tget_order(hid_t type_id)
herr_t H5Tset_order(hid_t type_id, H5T_order_t order)
+
hsize_t H5Tget_precision(hid_t type_id)
herr_t H5Tset_precision(hid_t type_id, size_t prec)
+
int H5Tget_offset(hid_t type_id)
herr_t H5Tset_offset(hid_t type_id, size_t offset)
- # missing: get_pad
- # missing: set_pad
+
+ herr_t H5Tget_pad(hid_t type_id, H5T_pad_t * lsb, H5T_pad_t * msb )
+ herr_t H5Tset_pad(hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb )
+
H5T_sign_t H5Tget_sign(hid_t type_id)
herr_t H5Tset_sign(hid_t type_id, H5T_sign_t sign)
+
# missing: bunch of floating-point crap nobody uses
# missing: g/s strpad
diff --git a/h5py/h5t.pyx b/h5py/h5t.pyx
index 24494cc..99bbc67 100644
--- a/h5py/h5t.pyx
+++ b/h5py/h5t.pyx
@@ -67,6 +67,7 @@ from utils cimport create_ieee_complex64, create_ieee_complex128,\
# Runtime imports
import h5
+from h5 import DDict
from errors import DatatypeError, ConversionError
import sys
@@ -91,11 +92,13 @@ CLASS_MAPPER = {H5T_NO_CLASS: "ERROR", H5T_INTEGER: "INTEGER", H5T_FLOAT: "FLOAT
H5T_TIME: "TIME", H5T_STRING: "STRING", H5T_BITFIELD: "BITFIELD",
H5T_OPAQUE: "OPAQUE", H5T_COMPOUND: "COMPOUND", H5T_REFERENCE: "REFERENCE",
H5T_ENUM: "ENUM", H5T_VLEN: "VLEN", H5T_ARRAY: "ARRAY"}
+CLASS_MAPPER = DDict(CLASS_MAPPER)
# Enumeration H5T_sign_t
SIGN_NONE = H5T_SGN_NONE
SIGN_2 = H5T_SGN_2
SIGN_MAPPER = {H5T_SGN_NONE: "UNSIGNED", H5T_SGN_2: "SIGNED"}
+SIGN_MAPPER = DDict(SIGN_MAPPER)
# Enumeration H5T_order_t
ORDER_LE = H5T_ORDER_LE
@@ -103,7 +106,9 @@ ORDER_BE = H5T_ORDER_BE
ORDER_VAX = H5T_ORDER_VAX
ORDER_NONE = H5T_ORDER_NONE
ORDER_MAPPER = {H5T_ORDER_LE: "LITTLE-ENDIAN", H5T_ORDER_BE: "BIG-ENDIAN",
- H5T_ORDER_VAX: "VAX MIXED-ENDIAN" }
+ H5T_ORDER_VAX: "VAX MIXED-ENDIAN", H5T_ORDER_NONE: "NONE" }
+ORDER_MAPPER = DDict(ORDER_MAPPER)
+
if sys.byteorder == "little": # Custom python addition
pyORDER_NATIVE = H5T_ORDER_LE
else:
@@ -177,6 +182,27 @@ def open(hid_t group_id, char* name):
raise DatatypeError('Failed to open datatype "%s" on group %d' % (name, group_id))
return retval
+def commit(hid_t loc_id, char* name, hid_t type_id):
+ """ (INT group_id, STRING name, INT type_id)
+
+ Commit a transient datatype to a named datatype in a file.
+ """
+ cdef herr_t retval
+ retval = H5Tcommit(loc_id, name, type_id)
+ if retval < 0:
+ raise DatatypeError("Failed to commit datatype %d under group %d with name '%s'" % (type_id, loc_id, name))
+
+def committed(hid_t type_id):
+ """ (INT type_id) => BOOL is_comitted
+
+ Determine if a given type object is named (T) or transient (F).
+ """
+ cdef htri_t retval
+ retval = H5Tcommitted(type_id)
+ if retval < 0:
+ raise DatatypeError("Failed to determine status of datatype %d" % type_id)
+ return bool(retval)
+
def copy(hid_t type_id):
""" (INT type_id) => INT new_type_id
@@ -189,13 +215,28 @@ def copy(hid_t type_id):
raise DatatypeError("Failed to copy datatype %d" % type_id)
return retval
-def close(hid_t type_id):
- " (INT type_id) "
-
+def equal(hid_t typeid_1, hid_t typeid_2):
+ """ (INT typeid_1, INT typeid_2) => BOOL types_are_equal
+
+ Test whether two identifiers point to the same datatype object. Note
+ this does NOT perform any kind of logical comparison.
+ """
+ cdef htri_t retval
+ retval = H5Tequal(typeid_1, typeid_2)
+ if retval < 0:
+ raise DatatypeError("Failed to test datatypes for equality: %d and %d" % (typeid_1, typeid_2))
+ return bool(retval)
+
+def lock(hid_t type_id):
+ """ (INT type_id)
+
+ Lock a datatype, which makes it immutable and indestructible. Once
+ locked, it can't be unlocked.
+ """
cdef herr_t retval
- retval = H5Tclose(type_id)
+ retval = H5Tlock(type_id)
if retval < 0:
- raise DatatypeError("Failed to close datatype %d" % type_id)
+ raise DatatypeError("Failed to lock datatype %d" % type_id)
def get_class(hid_t type_id):
""" (INT type_id) => INT class
@@ -209,6 +250,17 @@ def get_class(hid_t type_id):
raise DatatypeError("Failed to determine class of datatype %d" % type_id)
return classtype
+def get_size(hid_t type_id):
+ """ (INT type_id) => INT size
+
+ Determine the total size of a datatype, in bytes.
+ """
+ cdef size_t retval
+ retval = H5Tget_size(type_id)
+ if retval == 0:
+ raise DatatypeError("Can't determine size of datatype %d (got 0)" % type_id)
+ return retval
+
def get_super(hid_t type_id):
""" (INT type_id) => INT super_type_id
@@ -233,42 +285,19 @@ def detect_class(hid_t type_id, int classtype):
raise DatatypeError("Couldn't inspect datatype %d for class %s" % (type_id, str(classtype)))
return bool(retval)
-def commit(hid_t loc_id, char* name, hid_t type_id):
- """ (INT group_id, STRING name, INT type_id)
- Commit a transient datatype to a named datatype in a file.
- """
+def close(hid_t type_id):
+ " (INT type_id) "
+
cdef herr_t retval
- retval = H5Tcommit(loc_id, name, type_id)
- if retval < 0:
- raise DatatypeError("Failed to commit datatype %d under group %d with name '%s'" % (type_id, loc_id, name))
-
-def committed(hid_t type_id):
- """ (INT type_id) => BOOL is_comitted
-
- Determine if a given type object is named (T) or transient (F).
- """
- cdef htri_t retval
- retval = H5Tcommitted(type_id)
+ retval = H5Tclose(type_id)
if retval < 0:
- raise DatatypeError("Failed to determine status of datatype %d" % type_id)
- return bool(retval)
+ raise DatatypeError("Failed to close datatype %d" % type_id)
# === Atomic datatype operations ==============================================
# H5Tget_size, H5Tset_size, H5Tget_order, H5Tset_order, H5Tget_precision, \
# H5Tset_precision, H5Tget_offset, H5Tset_offset, H5Tget_sign, H5Tset_sign
-def get_size(hid_t type_id):
- """ (INT type_id) => INT size_in_bytes
-
- Obtain the total size of the datatype in bytes.
- """
- cdef size_t retval
- retval = H5Tget_size(type_id)
- if retval == 0:
- raise DatatypeError("Failed to get size of datatype %d" % type_id)
- return retval
-
def set_size(hid_t type_id, size_t size):
""" (INT type_id, INT size)
diff --git a/h5py/tests/__init__.py b/h5py/tests/__init__.py
index 8385af8..27f75bf 100644
--- a/h5py/tests/__init__.py
+++ b/h5py/tests/__init__.py
@@ -18,7 +18,7 @@ import test_h5g
import test_h5i
import test_h5d
-from h5py import h5a, h5f, h5g, h5d, h5s, h5i, h5z, h5p
+from h5py import h5a, h5f, h5g, h5d, h5s, h5i, h5z, h5p, highlevel
TEST_CASES = (test_h5a.TestH5A, test_h5f.TestH5F, test_h5g.TestH5G,
test_h5i.TestH5I, test_h5d.TestH5D)
@@ -40,6 +40,5 @@ def autotest():
if not runtests():
sys.exit(1)
-__all__ = ['test_h5a','runtests']
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/h5py.git
More information about the debian-science-commits
mailing list