-
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
all: moves to camel case naming #38
base: master
Are you sure you want to change the base?
Changes from 1 commit
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 |
---|---|---|
|
@@ -67,20 +67,20 @@ func main() { | |
panic(err) | ||
} | ||
defer f.Close() | ||
fmt.Printf(":: file [%s] created (id=%d)\n", fname, f.ID()) | ||
fmt.Printf(":: file [%s] created (id=%d)\n", fname, f.Id()) | ||
|
||
// create the memory data type | ||
dtype, err := hdf5.NewDatatypeFromValue(s1[0]) | ||
dType, err := hdf5.NewDatatypeFromValue(s1[0]) | ||
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. I'd be really happy if these all just became |
||
if err != nil { | ||
panic("could not create a dtype") | ||
panic("could not create a dType") | ||
} | ||
|
||
// create the dataset | ||
dset, err := f.CreateDataset(dsname, dtype, space) | ||
dset, err := f.CreateDataset(dsname, dType, space) | ||
if err != nil { | ||
panic(err) | ||
} | ||
fmt.Printf(":: dset (id=%d)\n", dset.ID()) | ||
fmt.Printf(":: dset (id=%d)\n", dset.Id()) | ||
|
||
// write data to the dataset | ||
fmt.Printf(":: dset.Write...\n") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,22 +22,22 @@ func newAttribute(id C.hid_t) *Attribute { | |
return &Attribute{Identifier{id}} | ||
} | ||
|
||
func createAttribute(id C.hid_t, name string, dtype *Datatype, dspace *Dataspace, acpl *PropList) (*Attribute, error) { | ||
c_name := C.CString(name) | ||
defer C.free(unsafe.Pointer(c_name)) | ||
hid := C.H5Acreate2(id, c_name, dtype.id, dspace.id, acpl.id, P_DEFAULT.id) | ||
if err := checkID(hid); err != nil { | ||
func createAttribute(id C.hid_t, name string, dType *Datatype, dSpace *Dataspace, acpl *PropList) (*Attribute, 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. And, for the |
||
cName := C.CString(name) | ||
defer C.free(unsafe.Pointer(cName)) | ||
hid := C.H5Acreate2(id, cName, dType.id, dSpace.id, acpl.id, P_DEFAULT.id) | ||
if err := checkId(hid); err != nil { | ||
return nil, err | ||
} | ||
return newAttribute(hid), nil | ||
} | ||
|
||
func openAttribute(id C.hid_t, name string) (*Attribute, error) { | ||
c_name := C.CString(name) | ||
defer C.free(unsafe.Pointer(c_name)) | ||
cName := C.CString(name) | ||
defer C.free(unsafe.Pointer(cName)) | ||
|
||
hid := C.H5Aopen(id, c_name, P_DEFAULT.id) | ||
if err := checkID(hid); err != nil { | ||
hid := C.H5Aopen(id, cName, P_DEFAULT.id) | ||
if err := checkId(hid); err != nil { | ||
return nil, err | ||
} | ||
return newAttribute(hid), nil | ||
|
@@ -68,7 +68,7 @@ func (s *Attribute) Space() *Dataspace { | |
} | ||
|
||
// Read reads raw data from a attribute into a buffer. | ||
func (s *Attribute) Read(data interface{}, dtype *Datatype) error { | ||
func (s *Attribute) Read(data interface{}, dType *Datatype) error { | ||
var addr unsafe.Pointer | ||
v := reflect.ValueOf(data) | ||
|
||
|
@@ -88,13 +88,13 @@ func (s *Attribute) Read(data interface{}, dtype *Datatype) error { | |
addr = unsafe.Pointer(v.UnsafeAddr()) | ||
} | ||
|
||
rc := C.H5Aread(s.id, dtype.id, addr) | ||
rc := C.H5Aread(s.id, dType.id, addr) | ||
err := h5err(rc) | ||
return err | ||
} | ||
|
||
// Write writes raw data from a buffer to an attribute. | ||
func (s *Attribute) Write(data interface{}, dtype *Datatype) error { | ||
func (s *Attribute) Write(data interface{}, dType *Datatype) error { | ||
var addr unsafe.Pointer | ||
v := reflect.Indirect(reflect.ValueOf(data)) | ||
switch v.Kind() { | ||
|
@@ -114,7 +114,7 @@ func (s *Attribute) Write(data interface{}, dtype *Datatype) error { | |
addr = unsafe.Pointer(v.UnsafeAddr()) | ||
} | ||
|
||
rc := C.H5Awrite(s.id, dtype.id, addr) | ||
rc := C.H5Awrite(s.id, dType.id, addr) | ||
err := h5err(rc) | ||
return err | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,18 +26,18 @@ func newDataset(id C.hid_t, typ *Datatype) *Dataset { | |
return &Dataset{Identifier: Identifier{id}, typ: typ} | ||
} | ||
|
||
func createDataset(id C.hid_t, name string, dtype *Datatype, dspace *Dataspace, dcpl *PropList) (*Dataset, error) { | ||
dtype, err := dtype.Copy() // For safety | ||
func createDataset(id C.hid_t, name string, dType *Datatype, dSpace *Dataspace, dcpl *PropList) (*Dataset, error) { | ||
dType, err := dType.Copy() // For safety | ||
if err != nil { | ||
return nil, err | ||
} | ||
c_name := C.CString(name) | ||
defer C.free(unsafe.Pointer(c_name)) | ||
hid := C.H5Dcreate2(id, c_name, dtype.id, dspace.id, P_DEFAULT.id, dcpl.id, P_DEFAULT.id) | ||
if err := checkID(hid); err != nil { | ||
cName := C.CString(name) | ||
defer C.free(unsafe.Pointer(cName)) | ||
hid := C.H5Dcreate2(id, cName, dType.id, dSpace.id, P_DEFAULT.id, dcpl.id, P_DEFAULT.id) | ||
if err := checkId(hid); err != nil { | ||
return nil, err | ||
} | ||
return newDataset(hid, dtype), nil | ||
return newDataset(hid, dType), nil | ||
} | ||
|
||
// Close releases and terminates access to a dataset. | ||
|
@@ -59,9 +59,9 @@ func (s *Dataset) Space() *Dataspace { | |
} | ||
|
||
// ReadSubset reads a subset of raw data from a dataset into a buffer. | ||
func (s *Dataset) ReadSubset(data interface{}, memspace, filespace *Dataspace) error { | ||
dtype, err := s.Datatype() | ||
defer dtype.Close() | ||
func (s *Dataset) ReadSubset(data interface{}, memSpace, fileSpace *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. These are good though. |
||
dType, err := s.Datatype() | ||
defer dType.Close() | ||
if err != nil { | ||
return err | ||
} | ||
|
@@ -89,14 +89,14 @@ func (s *Dataset) ReadSubset(data interface{}, memspace, filespace *Dataspace) e | |
addr = unsafe.Pointer(v.UnsafeAddr()) | ||
} | ||
|
||
var filespace_id, memspace_id C.hid_t = 0, 0 | ||
if memspace != nil { | ||
memspace_id = memspace.id | ||
var fileSpaceId, memSpaceId C.hid_t = 0, 0 | ||
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. Remove the redundant assignment and change to |
||
if memSpace != nil { | ||
memSpaceId = memSpace.id | ||
} | ||
if filespace != nil { | ||
filespace_id = filespace.id | ||
if fileSpace != nil { | ||
fileSpaceId = fileSpace.id | ||
} | ||
rc := C.H5Dread(s.id, dtype.id, memspace_id, filespace_id, 0, addr) | ||
rc := C.H5Dread(s.id, dType.id, memSpaceId, fileSpaceId, 0, addr) | ||
err = h5err(rc) | ||
return err | ||
} | ||
|
@@ -107,9 +107,9 @@ func (s *Dataset) Read(data interface{}) error { | |
} | ||
|
||
// WriteSubset writes a subset of raw data from a buffer to a dataset. | ||
func (s *Dataset) WriteSubset(data interface{}, memspace, filespace *Dataspace) error { | ||
dtype, err := s.Datatype() | ||
defer dtype.Close() | ||
func (s *Dataset) WriteSubset(data interface{}, memSpace, fileSpace *Dataspace) error { | ||
dType, err := s.Datatype() | ||
defer dType.Close() | ||
if err != nil { | ||
return err | ||
} | ||
|
@@ -137,14 +137,14 @@ func (s *Dataset) WriteSubset(data interface{}, memspace, filespace *Dataspace) | |
addr = unsafe.Pointer(v.UnsafeAddr()) | ||
} | ||
|
||
var filespace_id, memspace_id C.hid_t = 0, 0 | ||
if memspace != nil { | ||
memspace_id = memspace.id | ||
var fileSpaceId, memSpaceId C.hid_t = 0, 0 | ||
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. Same here. |
||
if memSpace != nil { | ||
memSpaceId = memSpace.id | ||
} | ||
if filespace != nil { | ||
filespace_id = filespace.id | ||
if fileSpace != nil { | ||
fileSpaceId = fileSpace.id | ||
} | ||
rc := C.H5Dwrite(s.id, dtype.id, memspace_id, filespace_id, 0, addr) | ||
rc := C.H5Dwrite(s.id, dType.id, memSpaceId, fileSpaceId, 0, addr) | ||
err = h5err(rc) | ||
return err | ||
} | ||
|
@@ -156,14 +156,14 @@ func (s *Dataset) Write(data interface{}) error { | |
|
||
// Creates a new attribute at this location. The returned attribute | ||
// must be closed by the user when it is no longer needed. | ||
func (s *Dataset) CreateAttribute(name string, dtype *Datatype, dspace *Dataspace) (*Attribute, error) { | ||
return createAttribute(s.id, name, dtype, dspace, P_DEFAULT) | ||
func (s *Dataset) CreateAttribute(name string, dType *Datatype, dSpace *Dataspace) (*Attribute, error) { | ||
return createAttribute(s.id, name, dType, dSpace, P_DEFAULT) | ||
} | ||
|
||
// Creates a new attribute at this location. The returned | ||
// attribute must be closed by the user when it is no longer needed. | ||
func (s *Dataset) CreateAttributeWith(name string, dtype *Datatype, dspace *Dataspace, acpl *PropList) (*Attribute, error) { | ||
return createAttribute(s.id, name, dtype, dspace, acpl) | ||
func (s *Dataset) CreateAttributeWith(name string, dType *Datatype, dSpace *Dataspace, acpl *PropList) (*Attribute, error) { | ||
return createAttribute(s.id, name, dType, dSpace, acpl) | ||
} | ||
|
||
// Opens an existing attribute. The returned attribute must be closed | ||
|
@@ -176,11 +176,11 @@ func (s *Dataset) OpenAttribute(name string) (*Attribute, error) { | |
// Datatype returns the HDF5 Datatype of the Dataset. The returned | ||
// datatype must be closed by the user when it is no longer needed. | ||
func (s *Dataset) Datatype() (*Datatype, error) { | ||
dtype_id := C.H5Dget_type(s.id) | ||
if dtype_id < 0 { | ||
dTypeId := C.H5Dget_type(s.id) | ||
if dTypeId < 0 { | ||
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.
|
||
return nil, fmt.Errorf("couldn't open Datatype from Dataset %q", s.Name()) | ||
} | ||
return NewDatatype(dtype_id), nil | ||
return NewDatatype(dTypeId), nil | ||
} | ||
|
||
// hasIllegalGoPointer returns whether the Dataset is known to have | ||
|
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.
Please revert the ID changes.