Code Monkey home page Code Monkey logo

hdf5's Introduction

hdf5

Build Status codecov Go Report Card GoDoc

hdf5 is a pure Go implementation of the HDF5 file format.

License

hdf5 is released under the BSD-3 license.

Documentation

Documentation for hdf5 is served by GoDoc.

hdf5's People

Contributors

sbinet avatar

Stargazers

 avatar ginuerzh avatar Ezekiel Enns avatar Ivan Markin avatar Blazej Gruszka avatar James Pirruccello avatar LogC11111000110 avatar  avatar Mark Wolfe avatar  avatar Song Liu avatar Florian Rohrweck avatar ik5 avatar István Bozsó avatar  avatar Zero avatar Giacomo Tartari avatar Rajeeva Lochan Musunuri avatar robin avatar Amir Irani avatar Theofanis Despoudis avatar Botond Sipos avatar

Watchers

James Cloos avatar  avatar LogC11111000110 avatar

Forkers

sbinet-gonum

hdf5's Issues

panic: runtime error: cgo argument has Go pointer to Go pointer

Running what I believe is the test code:


import (
	"fmt"

	"gonum.org/v1/hdf5"
)

const (
	fname  string = "SDScompound.h5"
	dsname string = "ArrayOfStructures"
	mbr1   string = "A_name"
	mbr2   string = "B_name"
	mbr3   string = "C_name"
	length uint   = 10
	rank   int    = 1
)

type s1Type struct {
	a int
	b float32
	c float64
	d [3]int
	e string
}

type s2Type struct {
	c float64
	a int
}

func main() {

	// initialize data
	// s1 := make([]s1_t, LENGTH)
	// for i:=0; i<LENGTH; i++ {
	// 	s1[i] = s1_t{a:i, b:float32(i*i), c:1./(float64(i)+1)}
	// }
	// fmt.Printf(":: data: %v\n", s1)
	s1 := [length]s1Type{}
	for i := 0; i < int(length); i++ {
		s1[i] = s1Type{
			a: i,
			b: float32(i * i),
			c: 1. / (float64(i) + 1),
			d: [...]int{i, i * 2, i * 3},
			e: fmt.Sprintf("--%d--", i),
		}
		//s1[i].d = []float64{float64(i), float64(2*i), 3.*i}}
	}
	fmt.Printf(":: data: %v\n", s1)

	// create data space
	dims := []uint{length}
	space, err := hdf5.CreateSimpleDataspace(dims, nil)
	if err != nil {
		panic(err)
	}

	// create the file
	f, err := hdf5.CreateFile(fname, hdf5.F_ACC_TRUNC)
	if err != nil {
		panic(err)
	}
	defer f.Close()

	// create the memory data type
	dtype, err := hdf5.NewDatatypeFromValue(s1[0])
	if err != nil {
		panic("could not create a dtype")
	}

	// create the dataset
	dset, err := f.CreateDataset(dsname, dtype, space)
	if err != nil {
		panic(err)
	}

	// write data to the dataset
	fmt.Printf(":: dset.Write...\n")
	err = dset.Write(&s1)
	if err != nil {
		panic(err)
	}
	fmt.Printf(":: dset.Write... [ok]\n")

	// release resources
	dset.Close()
	f.Close()

	// open the file and the dataset
	f, err = hdf5.OpenFile(fname, hdf5.F_ACC_RDONLY)
	if err != nil {
		panic(err)
	}
	dset, err = f.OpenDataset(dsname)
	if err != nil {
		panic(err)
	}

	// read it back into a new slice
	s2 := make([]s1Type, length)
	err = dset.Read(&s2)
	if err != nil {
		panic(err)
	}

	// display the fields
	fmt.Printf(":: data: %v\n", s2)

	// release resources
	dset.Close()
	f.Close()
}

I experience this crash:

% go run test.go
:: data: [{0 0 1 [0 0 0] --0--} {1 1 0.5 [1 2 3] --1--} {2 4 0.3333333333333333 [2 4 6] --2--} {3 9 0.25 [3 6 9] --3--} {4 16 0.2 [4 8 12] --4--} {5 25 0.16666666666666666 [5 10 15] --5--} {6 36 0.14285714285714285 [6 12 18] --6--} {7 49 0.125 [7 14 21] --7--} {8 64 0.1111111111111111 [8 16 24] --8--} {9 81 0.1 [9 18 27] --9--}]
:: dset.Write...
panic: runtime error: cgo argument has Go pointer to Go pointer

goroutine 1 [running]:
gonum.org/v1/hdf5.(*Dataset).WriteSubset.func1(0x500000000000000, 0x300000000000143, 0x0, 0x0, 0x0, 0xc000090000, 0x11)
	/Users/nick/atsu/atsui/src/gonum.org/v1/hdf5/h5d_dataset.go:147 +0x4c
gonum.org/v1/hdf5.(*Dataset).WriteSubset(0xc0000101f0, 0x40b02a0, 0xc000090000, 0x0, 0x0, 0x0, 0x0)
	/Users/nick/atsu/atsui/src/gonum.org/v1/hdf5/h5d_dataset.go:147 +0x1b2
gonum.org/v1/hdf5.(*Dataset).Write(0xc0000101f0, 0x40b02a0, 0xc000090000, 0x0, 0x0)
	/Users/nick/atsu/atsui/src/gonum.org/v1/hdf5/h5d_dataset.go:154 +0x47
main.main()
	/Users/nick/.tmp/hdf/test.go:81 +0x481
exit status 2
% go version
go version go1.11.1 darwin/amd64

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.