How to use the h5pyd._hl.datatype.Datatype function in h5pyd

To help you get started, we’ve selected a few h5pyd examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HDFGroup / h5pyd / h5pyd / _hl / View on Github external
                    raise IOError("Unexpected uuid: {}".format(uuid))
            objdb =
            if objdb and uuid in objdb:
                # we should be able to construct an object from objdb json
                obj_json = objdb[uuid]
                # will need to get JSON from server
                req = "/" + collection_type + "/" + uuid
                # make server request
                obj_json = self.GET(req)

            if collection_type == 'groups':
                tgt = Group(GroupID(self, obj_json))
            elif collection_type == 'datatypes':
                tgt = Datatype(TypeID(self, obj_json))
            elif collection_type == 'datasets':
                # create a Table if the daset is one dimensional and compound
                shape_json = obj_json["shape"]
                dtype_json = obj_json["type"]
                if "dims" in shape_json and len(shape_json["dims"]) == 1 and dtype_json["class"] == 'H5T_COMPOUND':
                    tgt = Table(DatasetID(self, obj_json))
                    tgt = Dataset(DatasetID(self, obj_json))
                raise IOError("Unexpecrted collection_type: {}".format(collection_type))

            return tgt
github HDFGroup / h5pyd / h5pyd / _hl / View on Github external
raise ValueError("chunk is of wrong dimension")
         for i in range(len(shape)):
             if maxshape is not None:
                 if maxshape[i] is not None and maxshape[i] < chunks[i]:
                     raise ValueError(errmsg)
                 if shape[i] < chunks[i]:
                     raise ValueError(errmsg)

    layout = None
    if chunks is not None and isinstance(chunks, dict):
        # use the given chunk layout
        layout = chunks
        chunks = None

    if isinstance(dtype, Datatype):
        # Named types are used as-is
        type_json =

        # Validate dtype
        if dtype is None:
            dtype = numpy.dtype("=f4")
            dtype = numpy.dtype(dtype)

        if dtype.kind == 'O' and 'ref' in dtype.metadata:
            type_json = {}
            type_json["class"] = "H5T_REFERENCE"
            meta_type = dtype.metadata['ref']
            if meta_type is Reference:
                type_json["base"] = "H5T_STD_REF_OBJ"
github HDFGroup / h5pyd / h5pyd / _hl / View on Github external

        # First, make sure we have a NumPy array.  We leave the data
        # type conversion for HDF5 to perform.
        if isinstance(data, Reference):
            dtype = special_dtype(ref=Reference)
        data = numpy.asarray(data, dtype=dtype, order='C')

        if shape is None:
            shape = data.shape

        use_htype = None    # If a committed type is given, we must use it
                            # in the call to h5a.create.

        if isinstance(dtype, Datatype):
            use_htype =
            dtype = dtype.dtype

            # Special case if data are complex numbers
            if (data.dtype.kind == 'c' and
                (dtype.names is None or
                    dtype.names != ('r', 'i') or
                    any(dt.kind != 'f' for dt, off in dtype.fields.values()) or
                    dtype.fields['r'][0] == dtype.fields['i'][0])):
                raise TypeError(
                    'Wrong committed datatype for complex numbers: %s' %
        elif dtype is None:
            if data.dtype.kind == 'U':
                # use vlen for unicode strings
                dtype = special_dtype(vlen=str)
github HDFGroup / h5pyd / h5pyd / _hl / View on Github external
except KeyError:
                return default

        if not name in self:
            return default

        elif getclass and not getlink:
            obj = self.__getitem__(name)
            if obj is None:
                return None
            if is GroupID:
                return Group
            elif is DatasetID:
                return Dataset
            elif is TypeID:
                return Datatype
                raise TypeError("Unknown object type")

        elif getlink:
            parent_uuid, link_json = self._get_link_json(name)
            typecode = link_json['class']

            if typecode == 'H5L_TYPE_SOFT':
                if getclass:
                    return SoftLink

                return SoftLink(link_json['h5path'])
            elif typecode == 'H5L_TYPE_EXTERNAL':
                if getclass:
                    return ExternalLink