Skip to content

Commit

Permalink
all: moves to camel case naming
Browse files Browse the repository at this point in the history
This patch is in regard to issue #37
and features a major renaming of all affected variables.
  • Loading branch information
donkahlero committed Jul 8, 2018
1 parent c257073 commit 2d45916
Show file tree
Hide file tree
Showing 21 changed files with 275 additions and 275 deletions.
10 changes: 5 additions & 5 deletions cmd/test-go-cpxcmpd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
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")
Expand Down
4 changes: 2 additions & 2 deletions cmd/test-go-extend-ds/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ func main() {
//RANK:= 2

//dims := []int{3, 3} // dset dimensions at creation
//maxdims:= []int{hdf5.S_UNLIMITED, hdf5.S_UNLIMITED}
//maxDims:= []int{hdf5.S_UNLIMITED, hdf5.S_UNLIMITED}

//mspace := hdf5.CreateDataspace(dims, maxdims)
//mSpace := hdf5.CreateDataspace(dims, maxDims)

// create a new file
f, err := hdf5.CreateFile(fname, hdf5.F_ACC_TRUNC)
Expand Down
2 changes: 1 addition & 1 deletion cmd/test-go-table-01-readback/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func main() {
if err != nil {
panic(err)
}
fmt.Printf(":: file [%s] opened (id=%d)\n", f.Name(), f.ID())
fmt.Printf(":: file [%s] opened (id=%d)\n", f.Name(), f.Id())

// create a fixed-length packet table within the file
table, err := f.OpenTable(tname)
Expand Down
4 changes: 2 additions & 2 deletions cmd/test-go-table-01/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ func main() {
panic(fmt.Errorf("CreateFile failed: %s", 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 a fixed-length packet table within the file
table, err := f.CreateTableFrom(tname, particle{}, chunkSize, compress)
if err != nil {
panic(fmt.Errorf("CreateTableFrom failed: %s", err))
}
defer table.Close()
fmt.Printf(":: table [%s] created (id=%d)\n", tname, table.ID())
fmt.Printf(":: table [%s] created (id=%d)\n", tname, table.Id())

if !table.IsValid() {
panic("table is invalid")
Expand Down
26 changes: 13 additions & 13 deletions h5a_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
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
Expand Down Expand Up @@ -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)

Expand All @@ -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() {
Expand All @@ -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
}
8 changes: 4 additions & 4 deletions h5a_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ func TestWriteAttribute(t *testing.T) {
}

for name, v := range attrs {
dtype, err := NewDataTypeFromType(v.Type)
dType, err := NewDataTypeFromType(v.Type)
if err != nil {
t.Fatalf("NewDatatypeFromValue failed: %s\n", err)
}
defer dtype.Close()
defer dType.Close()

attr, err := dset.CreateAttribute(name, dtype, scalar)
attr, err := dset.CreateAttribute(name, dType, scalar)
if err != nil {
t.Fatalf("CreateAttribute failed: %s\n", err)
}
defer attr.Close()

if err := attr.Write(v.Value, dtype); err != nil {
if err := attr.Write(v.Value, dType); err != nil {
t.Fatalf("Attribute write failed: %s\n", err)
}
}
Expand Down
64 changes: 32 additions & 32 deletions h5d_dataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 {
dType, err := s.Datatype()
defer dType.Close()
if err != nil {
return err
}
Expand Down Expand Up @@ -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
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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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
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
}
Expand All @@ -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
Expand All @@ -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 {
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
Expand Down
32 changes: 16 additions & 16 deletions h5d_dataset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ func createDataset1(t *testing.T) error {
}

dims := []uint{20, 5}
dspace, err := CreateSimpleDataspace(dims, dims)
dSpace, err := CreateSimpleDataspace(dims, dims)
if err != nil {
t.Fatal(err)
return err
}

dset, err := f.CreateDataset("dset", T_NATIVE_USHORT, dspace)
dset, err := f.CreateDataset("dset", T_NATIVE_USHORT, dSpace)
if err != nil {
t.Fatal(err)
return err
Expand Down Expand Up @@ -78,20 +78,20 @@ func TestReadSubset(t *testing.T) {
t.Fatal(err)
}

// get the filespace and select the subset
filespace := dset.Space()
// get the fileSpace and select the subset
fileSpace := dset.Space()
offset, stride, count, block := [2]uint{5, 1}, [2]uint{1, 1}, [2]uint{5, 2}, [2]uint{1, 1}
err = filespace.SelectHyperslab(offset[:], stride[:], count[:], block[:])
err = fileSpace.SelectHyperslab(offset[:], stride[:], count[:], block[:])
if err != nil {
t.Fatal(err)
}

// create the memory space for the subset
dims, maxdims := [2]uint{2, 5}, [2]uint{2, 5}
dims, maxDims := [2]uint{2, 5}, [2]uint{2, 5}
if err != nil {
t.Fatal(err)
}
memspace, err := CreateSimpleDataspace(dims[:], maxdims[:])
memSpace, err := CreateSimpleDataspace(dims[:], maxDims[:])
if err != nil {
t.Fatal(err)
}
Expand All @@ -104,7 +104,7 @@ func TestReadSubset(t *testing.T) {
data := [10]uint16{}

// read the subset
err = dset.ReadSubset(&data, memspace, filespace)
err = dset.ReadSubset(&data, memSpace, fileSpace)
if err != nil {
t.Fatal(err)
}
Expand All @@ -120,7 +120,7 @@ func TestReadSubset(t *testing.T) {
data := make([]uint16, 10)

// read the subset
err = dset.ReadSubset(&data, memspace, filespace)
err = dset.ReadSubset(&data, memSpace, fileSpace)
if err != nil {
t.Fatal(err)
}
Expand All @@ -142,7 +142,7 @@ func TestWriteSubset(t *testing.T) {
t.Fatal(err)
}
mdims := []uint{2, 6}
mspace, err := CreateSimpleDataspace(mdims, nil)
mSpace, err := CreateSimpleDataspace(mdims, nil)
if err != nil {
t.Fatal(err)
}
Expand All @@ -167,7 +167,7 @@ func TestWriteSubset(t *testing.T) {

data := make([]uint16, mdims[0]*mdims[1])

if err = dset.WriteSubset(&data, mspace, fspace); err != nil {
if err = dset.WriteSubset(&data, mSpace, fspace); err != nil {
t.Fatal(err)
}
}
Expand All @@ -177,21 +177,21 @@ func TestSelectHyperslab(t *testing.T) {
defer DisplayErrors(false)

dims := []uint{12, 4}
dspace, err := CreateSimpleDataspace(dims, nil)
dSpace, err := CreateSimpleDataspace(dims, nil)
if err != nil {
t.Fatal(err)
}
offset, stride, count, block := []uint{1, 2}, []uint{2, 1}, []uint{4, 2}, []uint{1, 1}
if err = dspace.SelectHyperslab(offset, stride, count, block); err != nil {
if err = dSpace.SelectHyperslab(offset, stride, count, block); err != nil {
t.Fatal(err)
}
if err = dspace.SelectHyperslab(offset, nil, count, block); err != nil {
if err = dSpace.SelectHyperslab(offset, nil, count, block); err != nil {
t.Fatal(err)
}
if err = dspace.SelectHyperslab(offset, stride, count, nil); err != nil {
if err = dSpace.SelectHyperslab(offset, stride, count, nil); err != nil {
t.Fatal(err)
}
if err = dspace.SelectHyperslab(offset, nil, count, nil); err != nil {
if err = dSpace.SelectHyperslab(offset, nil, count, nil); err != nil {
t.Fatal(err)
}
}
Loading

0 comments on commit 2d45916

Please sign in to comment.