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 / group.py View on Github external
else:
                    raise IOError("Unexpected uuid: {}".format(uuid))
            objdb = self.id.http_conn.getObjDb()
            if objdb and uuid in objdb:
                # we should be able to construct an object from objdb json
                obj_json = objdb[uuid]
            else:
                # 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))
                else:
                    tgt = Dataset(DatasetID(self, obj_json))
            else:
                raise IOError("Unexpecrted collection_type: {}".format(collection_type))

            return tgt
github HDFGroup / h5pyd / h5pyd / _hl / dataset.py 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)
             else:
                 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 = dtype.id.type_json

    else:
        # Validate dtype
        if dtype is None:
            dtype = numpy.dtype("=f4")
        else:
            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 / attrs.py View on Github external
"""
        self._parent.log.info("attrs.create({})".format(name))

        # 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.id
            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' %
                    dtype.name)
        elif dtype is None:
            if data.dtype.kind == 'U':
                # use vlen for unicode strings
                dtype = special_dtype(vlen=str)
github HDFGroup / h5pyd / h5pyd / _hl / group.py 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 obj.id.__class__ is GroupID:
                return Group
            elif obj.id.__class__ is DatasetID:
                return Dataset
            elif obj.id.__class__ is TypeID:
                return Datatype
            else:
                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