hdf5 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/hdf5.gemspec +2 -2
- data/lib/hdf5.rb +43 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f87349d9ad32fe5bf91ee2b354e422a33d58c6dd
|
4
|
+
data.tar.gz: 123edc76244a070d15879c517833db299541840a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54ecfe442aff612125759e3011bbfb5c30aeec7efc644de3254d4fcdf21079cead05966a2db3500740f471cd69d075b9bb60bb671b01192b7d66c16e2408a203
|
7
|
+
data.tar.gz: 352c2115bd2e5e6383a050a12ab6bca2db9a4a1c9b9fa70aeb54f057f6ecbcbe1dbb599a53297a2d027079fd64f1e4ab5845528d43869a597a43bcfb6936f64e
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/hdf5.gemspec
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: hdf5 0.2.
|
5
|
+
# stub: hdf5 0.2.2 ruby lib
|
6
6
|
# stub: ext/hdf5/extconf.rb
|
7
7
|
|
8
8
|
Gem::Specification.new do |s|
|
9
9
|
s.name = "hdf5"
|
10
|
-
s.version = "0.2.
|
10
|
+
s.version = "0.2.2"
|
11
11
|
|
12
12
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
13
13
|
s.require_paths = ["lib"]
|
data/lib/hdf5.rb
CHANGED
@@ -7,6 +7,26 @@ class NArray
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
+
class Array
|
11
|
+
# Allocate an integer64 chunk of memory, copy the contents of
|
12
|
+
# the array into it and return an FFI::MemoryPointer to the memory.
|
13
|
+
# The memory will be garbage collected when the pointer goes out of
|
14
|
+
# scope. Obviously the array should contain only integers. This method
|
15
|
+
# is not fast and shouldn't be used for giant arrays.
|
16
|
+
def ffi_mem_pointer_int64
|
17
|
+
raise TypeError.new("Array must contain only integers.") if self.find{|el| not el.kind_of? Integer}
|
18
|
+
ptr = FFI::MemoryPointer.new(:int64, size)
|
19
|
+
ptr.write_array_of_int64(self)
|
20
|
+
ptr
|
21
|
+
end
|
22
|
+
|
23
|
+
# This method currently assumes that hsize_t is an int64... this needs
|
24
|
+
# to be generalised ASAP.
|
25
|
+
def ffi_mem_pointer_hsize_t
|
26
|
+
ffi_mem_pointer_int64
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
10
30
|
# This is a module for reading and manipulating HDF5 (Hierarchical Data Format)
|
11
31
|
# files. At the current time (July 2014) it is capable of basic reading operations.
|
12
32
|
# However, its use of the FFI library means that extending its capabilities is easy
|
@@ -62,8 +82,20 @@ module Hdf5
|
|
62
82
|
end
|
63
83
|
end
|
64
84
|
|
85
|
+
# A module for dynamically interrogating the environment and the library
|
86
|
+
# and providing the correct library path etc. Currently very dumb!
|
87
|
+
module H5Library
|
88
|
+
class << self
|
89
|
+
# The location of the hdf5 library. Currently it is assumed to be in
|
90
|
+
# the default linker path.
|
91
|
+
def library_path
|
92
|
+
'hdf5'
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
65
97
|
extend FFI::Library
|
66
|
-
ffi_lib
|
98
|
+
ffi_lib H5Library.library_path
|
67
99
|
attach_function :group_open, :H5Gopen2, [H5Types.hid_t, :string, H5Types.hid_t], H5Types.hid_t
|
68
100
|
attach_function :get_type, :H5Iget_type, [H5Types.hid_t], H5Types.hid_t
|
69
101
|
#
|
@@ -75,7 +107,7 @@ module Hdf5
|
|
75
107
|
#
|
76
108
|
class H5File
|
77
109
|
extend FFI::Library
|
78
|
-
ffi_lib
|
110
|
+
ffi_lib H5Library.library_path
|
79
111
|
attach_function :basic_is_hdf5, :H5Fis_hdf5, [:string], H5Types.htri_t
|
80
112
|
attach_function :basic_open, :H5Fopen, [:string, :uint, H5Types.hid_t], H5Types.hid_t
|
81
113
|
attach_function :basic_close, :H5Fclose, [H5Types.hid_t], H5Types.herr_t
|
@@ -110,7 +142,7 @@ module Hdf5
|
|
110
142
|
# data array.
|
111
143
|
class H5Dataset
|
112
144
|
extend FFI::Library
|
113
|
-
ffi_lib
|
145
|
+
ffi_lib H5Library.library_path
|
114
146
|
attach_function :basic_open, :H5Dopen2, [H5Types.hid_t, :string, H5Types.hid_t], H5Types.hid_t
|
115
147
|
attach_function :basic_get_type, :H5Dget_type, [H5Types.hid_t], H5Types.hid_t
|
116
148
|
attach_function :basic_get_space, :H5Dget_space, [H5Types.hid_t], H5Types.hid_t
|
@@ -174,7 +206,7 @@ module Hdf5
|
|
174
206
|
# information about the dimensions and size of the dataset
|
175
207
|
class H5Dataspace
|
176
208
|
extend FFI::Library
|
177
|
-
ffi_lib
|
209
|
+
ffi_lib H5Library.library_path
|
178
210
|
attach_function :basic_get_simple_extent_ndims, :H5Sget_simple_extent_ndims, [H5Types.hid_t], :int
|
179
211
|
attach_function :basic_get_simple_extent_dims, :H5Sget_simple_extent_dims, [H5Types.hid_t, :pointer, :pointer], :int
|
180
212
|
attach_function :basic_create_simple, :H5Screate_simple, [:int, :pointer, :pointer], H5Types.hid_t
|
@@ -185,11 +217,12 @@ module Hdf5
|
|
185
217
|
maximum_dims ||= current_dims
|
186
218
|
raise ArgumentError.new("current_dims and maximum_dims must be the same size") unless current_dims.size == maximum_dims.size
|
187
219
|
n = current_dims.size
|
188
|
-
basic_dims = FFI::MemoryPointer.new(H5Types.hsize_t, n)
|
189
|
-
basic_maxdims = FFI::MemoryPointer.new(H5Types.hsize_t, n)
|
190
|
-
basic_dims.
|
191
|
-
basic_maxdims.
|
192
|
-
|
220
|
+
#basic_dims = FFI::MemoryPointer.new(H5Types.hsize_t, n)
|
221
|
+
#basic_maxdims = FFI::MemoryPointer.new(H5Types.hsize_t, n)
|
222
|
+
#basic_dims.write_array_of_type(:size_t, :put_size_t, current_dims)
|
223
|
+
#basic_maxdims.write_array_of_type(:size_t, :put_size_t, maximum_dims)
|
224
|
+
# Th
|
225
|
+
new(basic_create_simple(n, current_dims.ffi_mem_pointer_hsize_t, maximum_dims.ffi_mem_pointer_hsize_t))
|
193
226
|
end
|
194
227
|
# Create a new H5Dataspace object. id must be the id
|
195
228
|
# of a pre-existing HDF5 dataspace.
|
@@ -220,7 +253,7 @@ module Hdf5
|
|
220
253
|
# a vast compound type
|
221
254
|
class H5Datatype
|
222
255
|
extend FFI::Library
|
223
|
-
ffi_lib
|
256
|
+
ffi_lib H5Library.library_path
|
224
257
|
attach_function :basic_get_class, :H5Tget_class, [H5Types.hid_t], H5Types.h5t_class_t
|
225
258
|
attach_function :basic_get_nmembers, :H5Tget_nmembers, [H5Types.hid_t], :int
|
226
259
|
attach_function :basic_get_member_type, :H5Tget_member_type, [H5Types.hid_t, :uint], H5Types.hid_t
|