-
Notifications
You must be signed in to change notification settings - Fork 33
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
add deflate, add other function calls from the api, fix tag naming #2
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,11 +177,69 @@ func (s *Dataset) OpenAttribute(name string) (*Attribute, error) { | |
return openAttribute(s.id, name) | ||
} | ||
|
||
//H5_DLL hid_t H5Dget_space(hid_t dset_id); | ||
func (s *Dataset) H5Dget_space() (*Dataspace, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need to namespace with |
||
dspace_id := C.H5Dget_space(s.id) | ||
ds := newDataspace(dspace_id) | ||
if ds.id < 0 { | ||
return (ds), fmt.Errorf("couldn't open dataspace from Dataset %q", s.Name()) | ||
} | ||
return (ds), nil | ||
} | ||
|
||
// Datatype returns the HDF5 Datatype of the Dataset | ||
//H5_DLL hid_t H5Dget_type(hid_t dset_id); | ||
func (s *Dataset) Datatype() (*Datatype, error) { | ||
dtype_id := C.H5Dget_type(s.id) | ||
if dtype_id < 0 { | ||
return nil, fmt.Errorf("couldn't open Datatype from Dataset %q", s.Name()) | ||
} | ||
return NewDatatype(dtype_id), nil | ||
} | ||
|
||
//H5_DLL hid_t H5Dget_create_plist(hid_t dset_id); | ||
func (s *Dataset) H5Dget_create_plist() (C.hid_t, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto: no need to namespace with |
||
plist_id := (C.H5Dget_create_plist(s.id)) | ||
if plist_id < 0 { | ||
return (plist_id), fmt.Errorf("couldn't open access_plist from Dataset %q", s.Name()) | ||
} | ||
return (plist_id), nil | ||
} | ||
|
||
//H5_DLL hid_t H5Dget_access_plist(hid_t dset_id); | ||
func (s *Dataset) H5Dget_access_plist() (C.hid_t, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto: no need to namespace with |
||
plist_id := C.H5Dget_access_plist(s.id) | ||
if plist_id < 0 { | ||
return (plist_id), fmt.Errorf("couldn't open access_plist from Dataset %q", s.Name()) | ||
} | ||
return (plist_id), nil | ||
} | ||
|
||
//H5_DLL hsize_t H5Dget_storage_size(hid_t dset_id); | ||
func (s *Dataset) H5Dget_storage_size() (C.hsize_t, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto: no need to namespace with |
||
ds_size := C.H5Dget_storage_size(s.id) | ||
if ds_size < 0 { | ||
return (ds_size), fmt.Errorf("couldn't get size from Dataset %q", s.Name()) | ||
} | ||
return (ds_size), nil | ||
} | ||
|
||
//H5_DLL herr_t H5Dset_extent(hid_t dset_id, const hsize_t size[]); | ||
func (s *Dataset) H5Dset_extent(dims []uint) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto: no need to namespace with |
||
return h5err(C.H5Dset_extent(s.id, (*C.hsize_t)(unsafe.Pointer(&dims[0])))) | ||
} | ||
|
||
//H5_DLL herr_t H5Dflush(hid_t dset_id); | ||
func (s *Dataset) H5Dflush() error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto: no need to namespace with |
||
return h5err(C.H5Dflush(s.id)) | ||
} | ||
|
||
//H5_DLL herr_t H5Drefresh(hid_t dset_id); | ||
func (s *Dataset) H5Drefresh() error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto: no need to namespace with |
||
return h5err(C.H5Drefresh(s.id)) | ||
} | ||
|
||
//H5_DLL herr_t H5Ddebug(hid_t dset_id); | ||
func (s *Dataset) H5Ddebug() error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto: no need to namespace with |
||
return h5err(C.H5Ddebug(s.id)) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import "C" | |
import ( | ||
"fmt" | ||
"runtime" | ||
"unsafe" | ||
) | ||
|
||
type PropType C.hid_t | ||
|
@@ -38,6 +39,12 @@ func (p *PropList) finalizer() { | |
} | ||
} | ||
|
||
func AttachPropList(id C.hid_t) *PropList { | ||
p := &PropList{Identifier{id}} | ||
runtime.SetFinalizer(p, (*PropList).finalizer) | ||
return p | ||
} | ||
|
||
// NewPropList creates a new PropList as an instance of a property list class. | ||
func NewPropList(cls_id PropType) (*PropList, error) { | ||
hid := C.H5Pcreate(C.hid_t(cls_id)) | ||
|
@@ -47,6 +54,15 @@ func NewPropList(cls_id PropType) (*PropList, error) { | |
return newPropList(hid), nil | ||
} | ||
|
||
// NewPropList creates a new PropList as an instance of a property list class. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please fix the doc comment (function name doesn't match.) |
||
func NewDefaultDatasetPropList() (*PropList, error) { | ||
hid := C.H5Pcreate(C.H5P_CLS_DATASET_CREATE_ID_g) | ||
if err := checkID(hid); err != nil { | ||
return nil, err | ||
} | ||
return newPropList(hid), nil | ||
} | ||
|
||
// Close terminates access to a PropList. | ||
func (p *PropList) Close() error { | ||
if p.id == 0 { | ||
|
@@ -65,3 +81,42 @@ func (p *PropList) Copy() (*PropList, error) { | |
} | ||
return newPropList(hid), nil | ||
} | ||
|
||
/* Object creation property list (OCPL) routines */ | ||
|
||
//H5_DLL int H5Pget_nfilters(hid_t plist_id); | ||
func (p *PropList) H5Pget_nfilters() int { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto: no need to namespace with |
||
return int(C.H5Pget_nfilters(p.id)) | ||
} | ||
|
||
//H5_DLL herr_t H5Pset_deflate(hid_t plist_id, unsigned aggression); | ||
func (p *PropList) H5Pset_deflate(aggression uint) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto: no need to namespace with |
||
return h5err(C.H5Pset_deflate(p.id, C.uint(aggression))) | ||
} | ||
|
||
/* Dataset creation property list (DCPL) routines */ | ||
|
||
//H5_DLL herr_t H5Pset_layout(hid_t plist_id, H5D_layout_t layout); | ||
func (p *PropList) H5Pset_layout(layout_code uint) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto: no need to namespace with |
||
return h5err(C.H5Pset_layout(p.id, C.H5D_layout_t(layout_code))) | ||
} | ||
|
||
//H5_DLL H5D_layout_t H5Pget_layout(hid_t plist_id); | ||
func (p *PropList) H5Pget_layout() uint { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto: no need to namespace with |
||
return uint(C.H5Pget_layout(p.id)) | ||
} | ||
|
||
//H5_DLL herr_t H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]); | ||
func (p *PropList) H5Pset_chunk(ndims uint, dims []uint) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto: no need to namespace with |
||
return h5err(C.H5Pset_chunk(p.id, C.int(ndims), (*C.hsize_t)(unsafe.Pointer(&dims[0])))) | ||
} | ||
|
||
//H5_DLL int H5Pget_chunk(hid_t plist_id, int max_ndims, hsize_t dim[]/*out*/); | ||
func (p *PropList) H5Pget_chunk() uint { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto: no need to namespace with |
||
ndims := uint(0xffff) | ||
dims := []uint{ndims} | ||
c_dims := (*C.hsize_t)(unsafe.Pointer(&dims[0])) | ||
res := C.H5Pget_chunk(p.id, C.int(ndims), c_dims) | ||
|
||
return uint(res) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -261,6 +261,7 @@ var ( | |
|
||
// | ||
var h5t_VARIABLE int64 = C.H5T_VARIABLE | ||
var H5S_UNLIMITED int64 = C.H5S_UNLIMITED | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lead with lower case please. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It needs to be exported. For instance, is passed to hdf5.CreateSimpleDataspace() to create an unlimited dataspace. |
||
|
||
func makeGoStringDatatype() *Datatype { | ||
dt, err := T_C_S1.Copy() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,14 @@ func init() { | |
} | ||
} | ||
|
||
func H5open() { | ||
err := h5err(C.H5open()) | ||
if err != nil { | ||
err_str := fmt.Sprintf("pb calling H5open(): %s", err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just lump the lines together: panic(fmt.Errorf("error calling H5open: %v", err)) why is it required? |
||
panic(err_str) | ||
} | ||
} | ||
|
||
// hdferror wraps hdf5 int-based error codes | ||
type h5error struct { | ||
code int | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are these comments for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the prototype of the function being mapped, from the c header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, that's what it is, but why is it here? There should be user-facing documentation (possibly, but by no means guaranteed including such a line) - think about how godoc renders this.