gonum / hdf5

hdf5 is a wrapper for the HDF5 library
BSD 3-Clause "New" or "Revised" License
131 stars 33 forks source link

Getting dtype in terms of int32 or int64 #52

Open jeffhu1 opened 5 years ago

jeffhu1 commented 5 years ago

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

kortschak commented 5 years ago

Please provide a reproducer and more detailed expectations.

jeffhu1 commented 5 years ago
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.