Open
Description
it should be possible for npyio.Write
and npyio.Read
to properly handle user-defined types, e.g. type MyMatrix struct {...}
probably by having said user-defined type implement an interface that allows to describe the internal data:
- a way to expose equivalent data to
npyio.Header.Descr
- a way to expose the underlying data slice
[]T
(whereT
is one of the scalar types thatnpyio
supports)
Alternatively, have npyio
expose npyio.Marshaler
and npyio.Unmarshaler
interfaces (which would then be tested for and used in npyio.Write
and npyio.Read
, respectively)
Tentatively:
type Type struct {
Name string // e.g. '<f8'
Shape []int
Fortran bool
}
type Marshaler interface {
MarshalNPy() (dtype Type, data []byte, err error)
}
type Unmarshaler interface {
UnmarshalNPy(dtype Type, data []byte) error
}
Activity