Reading custom opaque types
See original GitHub issueTo assist reproducing bugs, please include the following:
- Operating System: Ubuntu 18.04
- Python version: 3.6.9
- Where Python was acquired: System python
- h5py version: 3.1.0
- HDF5 version: 1.12.0
I have a h5-file which contains an array of a custom opaque 2-byte datatype (bfloat16
). The data is written by a non-python application and should now be read with h5py.
I try to read the data as 2-byte-blobs and then to convert them to a float32 numpy-array. Unfortunately, I could not find a way to just read the blobs (the conversion should then be trivial).
I always get this error:
h5py/_objects.pyx in h5py._objects.with_phil.wrapper()
h5py/_objects.pyx in h5py._objects.with_phil.wrapper()
/mnt/c/git/test/.venv/lib/python3.6/site-packages/h5py/_hl/dataset.py in __getitem__(self, args)
571 mspace = h5s.create_simple(mshape)
572 fspace = selection.id
--> 573 self.id.read(mspace, fspace, arr, mtype, dxpl=self._dxpl)
574
575 # Patch up the output for NumPy
h5py/_objects.pyx in h5py._objects.with_phil.wrapper()
h5py/_objects.pyx in h5py._objects.with_phil.wrapper()
h5py/h5d.pyx in h5py.h5d.DatasetID.read()
h5py/_proxy.pyx in h5py._proxy.dset_rw()
h5py/_proxy.pyx in h5py._proxy.H5PY_H5Dread()
OSError: Can't read data (no appropriate function for conversion path)
Is there a possibility to register a custom function for reading opaque data? Alternatively it would also be okay to read the data as (u)int16 if this is possible.
Thanks
Issue Analytics
- State:
- Created 3 years ago
- Comments:23 (11 by maintainers)
Top Results From Across the Web
Some keyword in Swift: Opaque types explained with code ...
The some keyword in Swift allows you to define opaque parameter and return types. Expose only minimum APIs without losing performance.
Read more >Opaque Types - Apple Developer
The individual fields of an object based on an opaque type are hidden from clients, but the type's functions offer access to most...
Read more >6 Objects, Collections, and OPAQUE Types - Oracle Help Center
Custom Java classes are first-class types that you can use to read from and write to user-defined SQL types transparently. To be used...
Read more >Understanding opaque types in Swift - tanaschita.com
Swift 5.1 introduced a new language feature called opaque types. Opaque types give us the capability to return a concrete type without ...
Read more >What defines an opaque type in C, and when are they ...
Opaque types are, in part, a way to make C more object-oriented. They allow encapsulation, so that the internal details of a type...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thank for this very quick response. In general: All responses were always quick. Thanks a lot for this 😃!
If I could, I would provide a PR which fixes this, but I don’t know the code base (so my solution would be hacky). Until this is fixed, I’ll go for the not-so-nice
uint16
-solution.Thanks:-)!
@kutoga The exponential bias (set by
H5Tset_ebias
) you have for the bfloat16 looks wrong, it should be 127 not 15 (which is from half/IEEE-16 bit float), which would explain the large values.