[h5py] 37/455: h5t additions

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:15 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 42e56cccc10c55418c81ceca4b6dd6124ba62768
Author: andrewcollette <andrew.collette at gmail.com>
Date:   Wed Jun 4 05:13:10 2008 +0000

    h5t additions
---
 h5py/h5t.pxd | 47 ++++++++++++++++++++++++++++++++++++++++-------
 h5py/h5t.pyx | 53 +++++++++++++++++++++++++++++++++++++++++++----------
 2 files changed, 83 insertions(+), 17 deletions(-)

diff --git a/h5py/h5t.pxd b/h5py/h5t.pxd
index 6a7ea1b..4010402 100644
--- a/h5py/h5t.pxd
+++ b/h5py/h5t.pxd
@@ -38,7 +38,7 @@ cdef extern from "hdf5.h":
     H5T_NATIVE_LDOUBLE
 
   # Byte orders
-  cdef enum H5T_order_t:
+  ctypedef enum H5T_order_t:
     H5T_ORDER_ERROR      = -1,  # error
     H5T_ORDER_LE         = 0,   # little endian
     H5T_ORDER_BE         = 1,   # bit endian
@@ -46,14 +46,30 @@ cdef extern from "hdf5.h":
     H5T_ORDER_NONE       = 3    # no particular order (strings, bits,..)
 
   # HDF5 signed enums
-  cdef enum H5T_sign_t:
+  ctypedef enum H5T_sign_t:
     H5T_SGN_ERROR        = -1,  # error
     H5T_SGN_NONE         = 0,   # this is an unsigned type
     H5T_SGN_2            = 1,   # two's complement
     H5T_NSGN             = 2    # this must be last!
 
+  ctypedef enum H5T_norm_t:
+    H5T_NORM_ERROR       = -1,
+    H5T_NORM_IMPLIED     = 0,
+    H5T_NORM_MSBSET      = 1,
+    H5T_NORM_NONE        = 2
+
+  ctypedef enum H5T_cset_t:
+    H5T_CSET_ERROR       = -1,
+    H5T_CSET_ASCII       = 0
+
+  ctypedef enum H5T_str_t:
+    H5T_STR_ERROR        = -1,
+    H5T_STR_NULLTERM     = 0,
+    H5T_STR_NULLPAD      = 1,
+    H5T_STR_SPACEPAD     = 2
+
   # Atomic datatype padding
-  cdef enum H5T_pad_t:
+  ctypedef enum H5T_pad_t:
     H5T_PAD_ZERO        = 0,
     H5T_PAD_ONE         = 1,
     H5T_PAD_BACKGROUND  = 2
@@ -122,6 +138,11 @@ cdef extern from "hdf5.h":
     H5T_UNIX_D32BE
     H5T_UNIX_D64BE
 
+  cdef enum H5T_direction_t:
+    H5T_DIR_DEFAULT,
+    H5T_DIR_ASCEND,
+    H5T_DIR_DESCEND
+
  # --- Datatype operations ---------------------------------------------------
   # General operations
   hid_t         H5Tcreate(H5T_class_t type, size_t size)
@@ -137,8 +158,8 @@ cdef extern from "hdf5.h":
   htri_t        H5Tdetect_class(hid_t type_id, H5T_class_t dtype_class)
   herr_t        H5Tclose(hid_t type_id)
 
+  hid_t         H5Tget_native_type(hid_t type_id, H5T_direction_t direction)
   # 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
@@ -159,8 +180,21 @@ cdef extern from "hdf5.h":
   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
+  herr_t        H5Tget_fields(hid_t type_id, size_t *spos, size_t *epos, 
+                                size_t *esize, size_t *mpos, size_t *msize  )
+  herr_t        H5Tset_fields(hid_t type_id, size_t spos, size_t epos, 
+                                size_t esize, size_t mpos, size_t msize  )
+
+  size_t        H5Tget_ebias(hid_t type_id)
+  herr_t        H5Tset_ebias(hid_t type_id, size_t ebias)
+  H5T_norm_t    H5Tget_norm(hid_t type_id)
+  herr_t        H5Tset_norm(hid_t type_id, H5T_norm_t norm)
+  H5T_pad_t     H5Tget_inpad(hid_t type_id)
+  herr_t        H5Tset_inpad(hid_t type_id, H5T_pad_t inpad)
+  H5T_cset_t    H5Tget_cset(hid_t type_id)
+  herr_t        H5Tset_cset(hid_t type_id, H5T_cset_t cset)
+  H5T_str_t     H5Tget_strpad(hid_t type_id)
+  herr_t        H5Tset_strpad(hid_t type_id, H5T_str_t strpad)
 
   # VLENs
   hid_t     H5Tvlen_create(hid_t base_type_id)
@@ -171,7 +205,6 @@ cdef extern from "hdf5.h":
   H5T_class_t   H5Tget_member_class(hid_t type_id, int member_no)
   char*         H5Tget_member_name(hid_t type_id, unsigned membno)
   hid_t         H5Tget_member_type(hid_t type_id, unsigned membno)
-  #hid_t         H5Tget_native_type(hid_t type_id, H5T_direction_t direction)
   int           H5Tget_member_offset(hid_t type_id, int membno)
   int           H5Tget_member_index(hid_t type_id, char* name)
   herr_t        H5Tinsert(hid_t parent_id, char *name, size_t offset,
diff --git a/h5py/h5t.pyx b/h5py/h5t.pyx
index 5911cc4..8f6fba4 100644
--- a/h5py/h5t.pyx
+++ b/h5py/h5t.pyx
@@ -97,6 +97,15 @@ ORDER_BE    = H5T_ORDER_BE
 ORDER_VAX   = H5T_ORDER_VAX
 ORDER_NONE  = H5T_ORDER_NONE
 
+DIR_DEFAULT = H5T_DIR_DEFAULT
+DIR_ASCEND  = H5T_DIR_ASCEND
+DIR_DESCEND = H5T_DIR_DESCEND
+
+STR_NULLTERM = H5T_STR_NULLTERM
+STR_NULLPAD  = H5T_STR_NULLPAD
+STR_SPACEPAD = H5T_STR_SPACEPAD
+
+
 if sys.byteorder == "little":    # Custom python addition
     ORDER_NATIVE = H5T_ORDER_LE
 else:
@@ -261,6 +270,23 @@ def get_super(hid_t type_id):
         raise DatatypeError("Can't determine base datatype of %d" % type_id)
     return stype
 
+def get_native_type(hid_t type_id, int direction):
+    """ (INT type_id, INT direction) => INT new_type_id
+
+        Determine the native C equivalent for the given datatype.  Legal values
+        for "direction" are:
+          DIR_DEFAULT
+          DIR_ASCEND
+          DIR_DESCEND
+        These determine which direction the list of native datatypes is
+        searched; see the HDF5 docs for a definitive list.
+    """
+    cdef hid_t retval
+    retval = H5Tget_native_type(type_id, <H5T_direction_t>direction)
+    if retval < 0:
+        raise DatatypeError("Can't determine native equivalent of %d" % type_id)
+    return retval
+
 def detect_class(hid_t type_id, int classtype):
     """ (INT type_id, INT class) => BOOL class_is_present
 
@@ -305,8 +331,10 @@ def set_size(hid_t type_id, size_t size):
 def get_order(hid_t type_id):
     """ (INT type_id) => INT order
 
-        Obtain the byte order of the datatype; one of h5t.ORDER_* or
-        h5t.pyORDER_NATIVE
+        Obtain the byte order of the datatype; one of:
+         ORDER_LE
+         ORDER_BE
+         ORDER_NATIVE
     """
     cdef int order
     order = <int>H5Tget_order(type_id)
@@ -317,8 +345,10 @@ def get_order(hid_t type_id):
 def set_order(hid_t type_id, int order):
     """ (INT type_id, INT order)
 
-        Set the byte order of the datatype. <order> must be one of 
-        h5t.ORDER_* or h5t.pyORDER_NATIVE
+        Set the byte order of the datatype. "order" must be one of
+         ORDER_LE
+         ORDER_BE
+         ORDER_NATIVE
     """
     cdef herr_t retval
     retval = H5Tset_order(type_id, <H5T_order_t>order)
@@ -328,7 +358,9 @@ def set_order(hid_t type_id, int order):
 def get_sign(hid_t type_id):
     """ (INT type_id) => INT sign
 
-        Obtain the "signedness" of the datatype; one of h5t.SIGN_*
+        Obtain the "signedness" of the datatype; one of:
+          SGN_NONE:  Unsigned
+          SGN_2:     Signed 2's complement
     """
     cdef int retval
     retval = <int>H5Tget_sign(type_id)
@@ -339,13 +371,16 @@ def get_sign(hid_t type_id):
 def set_sign(hid_t type_id, int sign):
     """ (INT type_id, INT sign)
 
-        Set the "signedness" of the datatype; one of h5t.SIGN_*
+        Set the "signedness" of the datatype; one of:
+          SGN_NONE:  Unsigned
+          SGN_2:     Signed 2's complement
     """
     cdef herr_t retval
     retval = H5Tset_sign(type_id, <H5T_sign_t>sign)
     if retval < 0:
         raise DatatypeError("Failed to set sign of datatype %d" % type_id)
 
+
 def is_variable_str(hid_t type_id):
     """ (INT type_id) => BOOL is_variable
 
@@ -429,9 +464,8 @@ def get_member_offset(hid_t type_id, int member):
         library, this function will never raise an exception.  It returns
         0 on failure; be careful as this is also a legal offset value.
     """
-    cdef size_t offset
-    offset = H5Tget_member_offset(type_id, member)
-    return offset
+    return H5Tget_member_offset(type_id, member)
+
 
 def get_member_type(hid_t type_id, int member):
     """ (INT type_id, INT member_index) => INT type_id
@@ -477,7 +511,6 @@ def pack(hid_t type_id):
 # get_array_dims
 
 
-
 def array_create(hid_t base, object dims_tpl):
     """ (INT base_type_id, TUPLE dimensions)
 

-- 
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