Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide hooks for user-defined types #1

Open
sbinet opened this issue Mar 4, 2016 · 0 comments
Open

provide hooks for user-defined types #1

sbinet opened this issue Mar 4, 2016 · 0 comments
Assignees

Comments

@sbinet
Copy link
Owner

sbinet commented Mar 4, 2016

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 (where T is one of the scalar types that npyio 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
}
@sbinet sbinet self-assigned this Mar 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant