hdf5 icon indicating copy to clipboard operation
hdf5 copied to clipboard

Getting dtype in terms of int32 or int64

Open jeffhu1 opened this issue 5 years ago • 2 comments

What are you trying to do?

I am trying to get the exact size of a datatype

What did you do?

Tried using Datatype.GoType(), but this aliases everything to golang int

What did you expect to happen?

Expected to get an exact datatype

What actually happened?

Didn't get an exact datatype

jeffhu1 avatar Jul 01 '19 17:07 jeffhu1

Please provide a reproducer and more detailed expectations.

kortschak avatar Jul 01 '19 22:07 kortschak

package main
import (
	"fmt"
	"gonum.org/v1/hdf5"
)

func main() {
	f, _ := hdf5.OpenFile("myFile.h5", hdf5.F_ACC_RDONLY)
	myDataset, _ := f.OpenDataset("mydataset")
	dtype, _ := myDataset.Datatype()

	// this aliases to the general "int" format, which doesn't get to the specificity of int32 vs 64
	fmt.Println(dtype.Class())
	// this just returns int, which is int64 on my machine
	fmt.Println(dtype.GoType())
}

Reading the file with h5py, I know that the type is stored as int32, however gonum/hdf5 just returns it as a general int type. I'd like to know what exact type it is. It seems like these lines could be related. Any advice would be appreciated.

jeffhu1 avatar Jul 02 '19 17:07 jeffhu1