Class: Hdf5::H5Dataspace
- Inherits:
-
Object
- Object
- Hdf5::H5Dataspace
- Extended by:
- FFI::Library
- Defined in:
- lib/hdf5.rb
Overview
Object for wrapping an HD5 dataspace, which contains information about the dimensions and size of the dataset
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
-
.create_simple(current_dims, maximum_dims = nil) ⇒ Object
Create a new HDF5 dataspace with the given current and maximum dimensions.
Instance Method Summary collapse
-
#dims ⇒ Object
Get the size of the dataspace.
-
#initialize(id) ⇒ H5Dataspace
constructor
Create a new H5Dataspace object.
-
#maxdims ⇒ Object
Get the maximum size of the dataspace.
-
#ndims ⇒ Object
Number of dimensions in the dataspace.
-
#offset_simple(offsets) ⇒ Object
Set the offset of the dataspace.
Constructor Details
#initialize(id) ⇒ H5Dataspace
Create a new H5Dataspace object. id must be the id of a pre-existing HDF5 dataspace.
269 270 271 272 |
# File 'lib/hdf5.rb', line 269 def initialize(id) ObjectSpace.define_finalizer(self){H5Dataspace.basic_close(id)} @id = id end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
245 246 247 |
# File 'lib/hdf5.rb', line 245 def id @id end |
Class Method Details
.create_simple(current_dims, maximum_dims = nil) ⇒ Object
Create a new HDF5 dataspace with the given current and maximum dimensions. If maximum_dims is omitted it is set to current_dims. Returns an H5Dataspace object wrapping the dataspace
256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/hdf5.rb', line 256 def self.create_simple(current_dims, maximum_dims=nil) maximum_dims ||= current_dims raise ArgumentError.new("current_dims and maximum_dims must be the same size") unless current_dims.size == maximum_dims.size n = current_dims.size #basic_dims = FFI::MemoryPointer.new(H5Types.hsize_t, n) #basic_maxdims = FFI::MemoryPointer.new(H5Types.hsize_t, n) #basic_dims.write_array_of_type(:size_t, :put_size_t, current_dims) #basic_maxdims.write_array_of_type(:size_t, :put_size_t, maximum_dims) # Th new(basic_create_simple(n, current_dims.ffi_mem_pointer_hsize_t, maximum_dims.ffi_mem_pointer_hsize_t)) end |
Instance Method Details
#dims ⇒ Object
Get the size of the dataspace
285 286 287 |
# File 'lib/hdf5.rb', line 285 def dims basic_dims_maxdims[0].get_array_of_int64(0, ndims) end |
#maxdims ⇒ Object
Get the maximum size of the dataspace
289 290 291 |
# File 'lib/hdf5.rb', line 289 def maxdims basic_dims_maxdims[1].get_array_of_int64(0, ndims) end |
#ndims ⇒ Object
Number of dimensions in the dataspace
274 275 276 |
# File 'lib/hdf5.rb', line 274 def ndims basic_get_simple_extent_ndims(@id) end |
#offset_simple(offsets) ⇒ Object
Set the offset of the dataspace. offsets should be an ndims-sized array of zero-based integer offsets.
294 295 296 297 |
# File 'lib/hdf5.rb', line 294 def offset_simple(offsets) raise ArgumentError.new("offsets should have ndims elements") unless offsets.size == ndims basic_offset_simple(@id, offsets.ffi_mem_pointer_hsize_t) end |