mdarray 0.5.5-java → 0.5.5.1-java
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 +7 -0
- data/config.rb +164 -0
- data/lib/env.rb +1 -0
- data/lib/mdarray/access.rb +26 -1
- data/lib/mdarray/counter.rb +37 -2
- data/lib/mdarray/creation.rb +25 -21
- data/lib/mdarray/fast_operators.rb +3 -0
- data/lib/mdarray/printing.rb +10 -0
- data/lib/mdarray/ruby_functions.rb +9 -2
- data/lib/mdarray/ruby_numeric_functions.rb +7 -0
- data/test/colt/test_complete.rb +5 -0
- data/test/colt/~$VALE3_short.xlsx +0 -0
- data/test/complete.rb +5 -7
- data/test/env.rb +8 -97
- data/test/mdarray/test_access.rb +15 -0
- data/test/mdarray/test_complete.rb +4 -2
- data/test/mdarray/test_operator.rb +25 -0
- data/test/netcdf/netcdfwriter.rb +4 -4
- data/test/netcdf/test_complete.rb +5 -0
- data/test/netcdf/test_netcdf.rb +3 -3
- data/vendor/{netcdfAll-4.3.18.jar → netcdfAll-4.5_0.jar} +0 -0
- data/version.rb +1 -1
- metadata +11 -21
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0b09d88dc54e6026fcc58d8fb89f0f4d37e62a37
|
4
|
+
data.tar.gz: a39345c9195c40cf34547af94c6bdd561871e549
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bb22f9ec641ba92ba991a2e3c44356c9cbb2e84b5f1286a977d32055806496886663b8bc07cfd6357509da95c46bc73288d705d72aaa0a7a03f8fb5ede861e0c
|
7
|
+
data.tar.gz: d5948157d07a7b6c042cc33c305e9baeb5b6fb205a1ee08ca3239fa26adaa0afb3e95c34289285da7cc6cacc51c5aba898a14b5a4666b4b9f22007f420db04f4
|
data/config.rb
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
require 'rbconfig'
|
2
|
+
|
3
|
+
##########################################################################################
|
4
|
+
# Configuration. Remove setting before publishing Gem.
|
5
|
+
##########################################################################################
|
6
|
+
|
7
|
+
# set to true if development environment
|
8
|
+
# $DVLP = true
|
9
|
+
|
10
|
+
# Set to 'cygwin' when in cygwin
|
11
|
+
# $ENV = 'cygwin'
|
12
|
+
|
13
|
+
# Dependencies that are not yet installed (still in development)
|
14
|
+
# $DEPEND = Array.new
|
15
|
+
|
16
|
+
##########################################################################################
|
17
|
+
|
18
|
+
# the platform
|
19
|
+
@platform =
|
20
|
+
case RUBY_PLATFORM
|
21
|
+
when /mswin/ then 'windows'
|
22
|
+
when /mingw/ then 'windows'
|
23
|
+
when /bccwin/ then 'windows'
|
24
|
+
when /cygwin/ then 'windows-cygwin'
|
25
|
+
when /java/
|
26
|
+
require 'java' #:nodoc:
|
27
|
+
if java.lang.System.getProperty("os.name") =~ /[Ww]indows/
|
28
|
+
'windows-java'
|
29
|
+
else
|
30
|
+
'default-java'
|
31
|
+
end
|
32
|
+
else 'default'
|
33
|
+
end
|
34
|
+
|
35
|
+
#---------------------------------------------------------------------------------------
|
36
|
+
# Add path to load path
|
37
|
+
#---------------------------------------------------------------------------------------
|
38
|
+
|
39
|
+
def mklib(path, home_path = true)
|
40
|
+
|
41
|
+
if (home_path)
|
42
|
+
lib = path + "/lib"
|
43
|
+
else
|
44
|
+
lib = path
|
45
|
+
end
|
46
|
+
|
47
|
+
$LOAD_PATH << lib
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
##########################################################################################
|
52
|
+
# Prepare environment to work inside Cygwin
|
53
|
+
##########################################################################################
|
54
|
+
|
55
|
+
if $ENV == 'cygwin'
|
56
|
+
|
57
|
+
#---------------------------------------------------------------------------------------
|
58
|
+
# Return the cygpath of a path
|
59
|
+
#---------------------------------------------------------------------------------------
|
60
|
+
|
61
|
+
def set_path(path)
|
62
|
+
`cygpath -a -p -m #{path}`.tr("\n", "")
|
63
|
+
end
|
64
|
+
|
65
|
+
else
|
66
|
+
|
67
|
+
#---------------------------------------------------------------------------------------
|
68
|
+
# Return the path
|
69
|
+
#---------------------------------------------------------------------------------------
|
70
|
+
|
71
|
+
def set_path(path)
|
72
|
+
path
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
#---------------------------------------------------------------------------------------
|
78
|
+
# Set dependencies
|
79
|
+
#---------------------------------------------------------------------------------------
|
80
|
+
|
81
|
+
def depend(name)
|
82
|
+
|
83
|
+
dependency_dir = MDArray.project_dir + "/" + name
|
84
|
+
mklib(dependency_dir)
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
#---------------------------------------------------------------------------------------
|
89
|
+
# Set the project directories
|
90
|
+
#---------------------------------------------------------------------------------------
|
91
|
+
|
92
|
+
class MDArray
|
93
|
+
|
94
|
+
@home_dir = File.expand_path File.dirname(__FILE__)
|
95
|
+
|
96
|
+
class << self
|
97
|
+
attr_reader :home_dir
|
98
|
+
end
|
99
|
+
|
100
|
+
@project_dir = MDArray.home_dir + "/.."
|
101
|
+
@doc_dir = MDArray.home_dir + "/doc"
|
102
|
+
@lib_dir = MDArray.home_dir + "/lib"
|
103
|
+
@src_dir = MDArray.home_dir + "/src"
|
104
|
+
@target_dir = MDArray.home_dir + "/target"
|
105
|
+
@test_dir = MDArray.home_dir + "/test"
|
106
|
+
@vendor_dir = MDArray.home_dir + "/vendor"
|
107
|
+
|
108
|
+
class << self
|
109
|
+
attr_reader :project_dir
|
110
|
+
attr_reader :doc_dir
|
111
|
+
attr_reader :lib_dir
|
112
|
+
attr_reader :src_dir
|
113
|
+
attr_reader :target_dir
|
114
|
+
attr_reader :test_dir
|
115
|
+
attr_reader :vendor_dir
|
116
|
+
end
|
117
|
+
|
118
|
+
@build_dir = MDArray.src_dir + "/build"
|
119
|
+
|
120
|
+
class << self
|
121
|
+
attr_reader :build_dir
|
122
|
+
end
|
123
|
+
|
124
|
+
@classes_dir = MDArray.build_dir + "/classes"
|
125
|
+
|
126
|
+
class << self
|
127
|
+
attr_reader :classes_dir
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
##########################################################################################
|
133
|
+
# Config gem
|
134
|
+
##########################################################################################
|
135
|
+
|
136
|
+
if ($DVLP == true)
|
137
|
+
|
138
|
+
mklib(MDArray.home_dir)
|
139
|
+
|
140
|
+
# Add dependencies here
|
141
|
+
# depend(<other_gems>)
|
142
|
+
$DEPEND.each do |dep|
|
143
|
+
depend(dep)
|
144
|
+
end if $DEPEND
|
145
|
+
|
146
|
+
#----------------------------------------------------------------------------------------
|
147
|
+
# If we need to test for coverage
|
148
|
+
#----------------------------------------------------------------------------------------
|
149
|
+
|
150
|
+
if $COVERAGE == 'true'
|
151
|
+
|
152
|
+
require 'simplecov'
|
153
|
+
|
154
|
+
SimpleCov.start do
|
155
|
+
@filters = []
|
156
|
+
add_group "MDArray", "lib/mdarray"
|
157
|
+
add_group "Colt", "lib/colt"
|
158
|
+
add_group "NetCDF", "lib/netcdf"
|
159
|
+
end
|
160
|
+
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
164
|
+
|
data/lib/env.rb
CHANGED
data/lib/mdarray/access.rb
CHANGED
@@ -63,13 +63,24 @@ class MDArray
|
|
63
63
|
end
|
64
64
|
|
65
65
|
#------------------------------------------------------------------------------------
|
66
|
-
#
|
66
|
+
# When get is used to retrieve an element, it is assumed that the index does not need
|
67
|
+
# correction, for instance, no negative index is allowed. If one wants to use
|
68
|
+
# negative indexes, then method [] should be used. So mat.get([-1, 0, 0]) raises an
|
69
|
+
# exception while mat[-1, 0, 0] gets the last value for the first dimension.
|
67
70
|
#------------------------------------------------------------------------------------
|
68
71
|
|
69
72
|
def get(index = nil)
|
70
73
|
@local_index.get(index)
|
71
74
|
end
|
72
75
|
|
76
|
+
#---------------------------------------------------------------------------------------
|
77
|
+
#
|
78
|
+
#---------------------------------------------------------------------------------------
|
79
|
+
|
80
|
+
def get_as(type, counter = nil)
|
81
|
+
@local_index.get_as(type, counter)
|
82
|
+
end
|
83
|
+
|
73
84
|
#---------------------------------------------------------------------------------------
|
74
85
|
# Sets a value for a scalar D0 array
|
75
86
|
#---------------------------------------------------------------------------------------
|
@@ -212,6 +223,20 @@ class MDArray
|
|
212
223
|
|
213
224
|
end
|
214
225
|
|
226
|
+
#----------------------------------------------------------------------------------------
|
227
|
+
# Given an MDArray, makes it immutable. Renjin data cannot be changed as Renjin assumes
|
228
|
+
# it can delay processing.
|
229
|
+
#----------------------------------------------------------------------------------------
|
230
|
+
|
231
|
+
def immutable
|
232
|
+
|
233
|
+
instance_eval { def set(name, value) raise "Array is immutable" end }
|
234
|
+
instance_eval { def set_scalar(name, value) raise "Array is immutable" end }
|
235
|
+
instance_eval { def set_next(value) raise "Array is immutable" end }
|
236
|
+
instance_eval { def []=(name, value) raise "Array is immutable" end }
|
237
|
+
|
238
|
+
end
|
239
|
+
|
215
240
|
#------------------------------------------------------------------------------------
|
216
241
|
#
|
217
242
|
#------------------------------------------------------------------------------------
|
data/lib/mdarray/counter.rb
CHANGED
@@ -178,6 +178,43 @@ class MDArray
|
|
178
178
|
get_at_counter
|
179
179
|
end
|
180
180
|
|
181
|
+
#------------------------------------------------------------------------------------
|
182
|
+
# Gets the element at the courrent counter with the given type
|
183
|
+
#------------------------------------------------------------------------------------
|
184
|
+
|
185
|
+
def get_as(type, count = nil)
|
186
|
+
|
187
|
+
count ? set_counter_fast(count) : set_counter_fast(self.counter)
|
188
|
+
|
189
|
+
begin
|
190
|
+
case type
|
191
|
+
when :boolean
|
192
|
+
@mdarray.nc_array.getBoolean(@nc_index)
|
193
|
+
when :byte
|
194
|
+
@mdarray.nc_array.getByte(@nc_index)
|
195
|
+
when :char
|
196
|
+
@mdarray.nc_array.getChar(@nc_index)
|
197
|
+
when :short
|
198
|
+
@mdarray.nc_array.getShort(@nc_index)
|
199
|
+
when :int
|
200
|
+
@mdarray.nc_array.getInt(@nc_index)
|
201
|
+
when :long
|
202
|
+
@mdarray.nc_array.getLong(@nc_index)
|
203
|
+
when :float
|
204
|
+
@mdarray.nc_array.getFloat(@nc_index)
|
205
|
+
when :double
|
206
|
+
@mdarray.nc_array.getDouble(@nc_index)
|
207
|
+
when :string
|
208
|
+
@mdarray.nc_array.getObject(@nc_index).to_s
|
209
|
+
else
|
210
|
+
@mdarray.nc_array.getObject(@nc_index)
|
211
|
+
end
|
212
|
+
rescue Java::UcarMa2::ForbiddenConversionException
|
213
|
+
raise "cannot convert to type #{type}"
|
214
|
+
end
|
215
|
+
|
216
|
+
end
|
217
|
+
|
181
218
|
#---------------------------------------------------------------------------------------
|
182
219
|
#
|
183
220
|
#---------------------------------------------------------------------------------------
|
@@ -401,8 +438,6 @@ class MDArray
|
|
401
438
|
@mdarray.nc_array.setChar(@nc_index, value)
|
402
439
|
when "short"
|
403
440
|
@mdarray.nc_array.setShort(@nc_index, value)
|
404
|
-
when "unsigned"
|
405
|
-
@mdarray.nc_array.setUnsigned(@nc_index, value)
|
406
441
|
when "int"
|
407
442
|
@mdarray.nc_array.setInt(@nc_index, value)
|
408
443
|
when "long"
|
data/lib/mdarray/creation.rb
CHANGED
@@ -60,7 +60,7 @@ class MDArray
|
|
60
60
|
# @param storage [Array] a ruby array with the initialization data
|
61
61
|
#------------------------------------------------------------------------------------
|
62
62
|
|
63
|
-
def self.build(type, shape, storage = nil)
|
63
|
+
def self.build(type, shape, storage = nil, layout = :row)
|
64
64
|
|
65
65
|
if (shape.is_a? String)
|
66
66
|
# building from csv
|
@@ -93,6 +93,10 @@ class MDArray
|
|
93
93
|
|
94
94
|
def self.from_jstorage(type, shape, jstorage, section = false)
|
95
95
|
|
96
|
+
if (shape.size == 1 && shape[0] == 0)
|
97
|
+
return nil
|
98
|
+
end
|
99
|
+
|
96
100
|
dtype = DataType.valueOf(type.upcase)
|
97
101
|
jshape = shape.to_java :int
|
98
102
|
nc_array = Java::UcarMa2.Array.factory(dtype, jshape, jstorage)
|
@@ -119,8 +123,8 @@ class MDArray
|
|
119
123
|
# @param storage [Array] a ruby array with the initialization data
|
120
124
|
#------------------------------------------------------------------------------------
|
121
125
|
|
122
|
-
def self.boolean(shape, storage = nil)
|
123
|
-
self.build("boolean", shape, storage)
|
126
|
+
def self.boolean(shape, storage = nil, layout = :row)
|
127
|
+
self.build("boolean", shape, storage, layout)
|
124
128
|
end
|
125
129
|
|
126
130
|
#------------------------------------------------------------------------------------
|
@@ -129,8 +133,8 @@ class MDArray
|
|
129
133
|
# @param storage [Array] a ruby array with the initialization data
|
130
134
|
#------------------------------------------------------------------------------------
|
131
135
|
|
132
|
-
def self.byte(shape, storage = nil)
|
133
|
-
self.build("byte", shape, storage)
|
136
|
+
def self.byte(shape, storage = nil, layout = :row)
|
137
|
+
self.build("byte", shape, storage, layout)
|
134
138
|
end
|
135
139
|
|
136
140
|
#------------------------------------------------------------------------------------
|
@@ -139,8 +143,8 @@ class MDArray
|
|
139
143
|
# @param storage [Array] a ruby array with the initialization data
|
140
144
|
#------------------------------------------------------------------------------------
|
141
145
|
|
142
|
-
def self.char(shape, storage = nil)
|
143
|
-
self.build("char", shape, storage)
|
146
|
+
def self.char(shape, storage = nil, layout = :row)
|
147
|
+
self.build("char", shape, storage, layout)
|
144
148
|
end
|
145
149
|
|
146
150
|
#------------------------------------------------------------------------------------
|
@@ -150,8 +154,8 @@ class MDArray
|
|
150
154
|
#
|
151
155
|
#------------------------------------------------------------------------------------
|
152
156
|
|
153
|
-
def self.short(shape, storage = nil)
|
154
|
-
self.build("short", shape, storage)
|
157
|
+
def self.short(shape, storage = nil, layout = :row)
|
158
|
+
self.build("short", shape, storage, layout)
|
155
159
|
end
|
156
160
|
|
157
161
|
#------------------------------------------------------------------------------------
|
@@ -160,8 +164,8 @@ class MDArray
|
|
160
164
|
# @param storage [Array] a ruby array with the initialization data
|
161
165
|
#------------------------------------------------------------------------------------
|
162
166
|
|
163
|
-
def self.int(shape, storage = nil)
|
164
|
-
self.build("int", shape, storage)
|
167
|
+
def self.int(shape, storage = nil, layout = :row)
|
168
|
+
self.build("int", shape, storage, layout)
|
165
169
|
end
|
166
170
|
|
167
171
|
#------------------------------------------------------------------------------------
|
@@ -171,8 +175,8 @@ class MDArray
|
|
171
175
|
#
|
172
176
|
#------------------------------------------------------------------------------------
|
173
177
|
|
174
|
-
def self.long(shape, storage = nil)
|
175
|
-
self.build("long", shape, storage)
|
178
|
+
def self.long(shape, storage = nil, layout = :row)
|
179
|
+
self.build("long", shape, storage, layout)
|
176
180
|
end
|
177
181
|
|
178
182
|
#------------------------------------------------------------------------------------
|
@@ -181,8 +185,8 @@ class MDArray
|
|
181
185
|
# @param storage [Array] a ruby array with the initialization data
|
182
186
|
#------------------------------------------------------------------------------------
|
183
187
|
|
184
|
-
def self.float(shape, storage = nil)
|
185
|
-
self.build("float", shape, storage)
|
188
|
+
def self.float(shape, storage = nil, layout = :row)
|
189
|
+
self.build("float", shape, storage, layout)
|
186
190
|
end
|
187
191
|
|
188
192
|
#------------------------------------------------------------------------------------
|
@@ -191,8 +195,8 @@ class MDArray
|
|
191
195
|
# @param storage [Array] a ruby array with the initialization data
|
192
196
|
#------------------------------------------------------------------------------------
|
193
197
|
|
194
|
-
def self.double(shape, storage = nil)
|
195
|
-
self.build("double", shape, storage)
|
198
|
+
def self.double(shape, storage = nil, layout = :row)
|
199
|
+
self.build("double", shape, storage, layout)
|
196
200
|
end
|
197
201
|
|
198
202
|
#------------------------------------------------------------------------------------
|
@@ -201,8 +205,8 @@ class MDArray
|
|
201
205
|
# @param storage [Array] a ruby array with the initialization data
|
202
206
|
#------------------------------------------------------------------------------------
|
203
207
|
|
204
|
-
def self.string(shape, storage = nil)
|
205
|
-
self.build("string", shape, storage)
|
208
|
+
def self.string(shape, storage = nil, layout = :row)
|
209
|
+
self.build("string", shape, storage, layout)
|
206
210
|
end
|
207
211
|
|
208
212
|
#------------------------------------------------------------------------------------
|
@@ -211,8 +215,8 @@ class MDArray
|
|
211
215
|
# @param storage [Array] a ruby array with the initialization data
|
212
216
|
#------------------------------------------------------------------------------------
|
213
217
|
|
214
|
-
def self.structure(shape, storage = nil)
|
215
|
-
self.build("structure", shape, storage)
|
218
|
+
def self.structure(shape, storage = nil, layout = :row)
|
219
|
+
self.build("structure", shape, storage, layout)
|
216
220
|
end
|
217
221
|
|
218
222
|
#------------------------------------------------------------------------------------
|
@@ -105,6 +105,7 @@ class FastBinaryOperator < BinaryOperator
|
|
105
105
|
get_args(*args) do |op1, op2, shape, *other_args|
|
106
106
|
helper = @helper::FillBinaryOperator
|
107
107
|
helper.send("apply", op1, op2)
|
108
|
+
|
108
109
|
end
|
109
110
|
|
110
111
|
end
|
@@ -131,6 +132,7 @@ class FastBinaryOperator < BinaryOperator
|
|
131
132
|
calc = nil
|
132
133
|
|
133
134
|
get_args(*args) do |op1, op2, shape, *other_args|
|
135
|
+
# return nil if op2 == nil
|
134
136
|
helper = @helper::ReduceBinaryOperator
|
135
137
|
calc = @pre_condition_result
|
136
138
|
calc = helper.send("apply", calc, op1, op2, @do_func)
|
@@ -149,6 +151,7 @@ class FastBinaryOperator < BinaryOperator
|
|
149
151
|
calc = nil
|
150
152
|
|
151
153
|
get_args(*args) do |op1, op2, shape, *other_args|
|
154
|
+
# return nil if op2 == nil
|
152
155
|
helper = @helper::ComplexReduceBinaryOperator
|
153
156
|
calc = @pre_condition_result
|
154
157
|
calc = helper.send("apply", calc, op1, op2, @do_func)
|
data/lib/mdarray/printing.rb
CHANGED
@@ -66,6 +66,8 @@ class MDArray
|
|
66
66
|
@formatter = method(:float_formatter)
|
67
67
|
when "double"
|
68
68
|
@formatter = method(:float_formatter)
|
69
|
+
when "string"
|
70
|
+
@formatter = method(:string_formatter)
|
69
71
|
else
|
70
72
|
@formatter = method(:default_formatter)
|
71
73
|
end
|
@@ -208,6 +210,14 @@ class MDArray
|
|
208
210
|
#
|
209
211
|
#------------------------------------------------------------------------------------
|
210
212
|
|
213
|
+
def string_formatter(val)
|
214
|
+
val.to_str
|
215
|
+
end
|
216
|
+
|
217
|
+
#------------------------------------------------------------------------------------
|
218
|
+
#
|
219
|
+
#------------------------------------------------------------------------------------
|
220
|
+
|
211
221
|
def default_formatter(val)
|
212
222
|
val.to_s
|
213
223
|
end
|
@@ -84,9 +84,16 @@ module RubyFunctions
|
|
84
84
|
#------------------------------------------------------------------------------------
|
85
85
|
|
86
86
|
def make_comparison_operator(name, func)
|
87
|
-
make_binary_op(name, "default", func, RubyFunctions.binary_helper, "boolean")
|
88
|
-
end
|
89
87
|
|
88
|
+
make_binary_op("_#{name}", "default", func, RubyFunctions.binary_helper, "boolean")
|
89
|
+
|
90
|
+
define_method(name) do |op2, requested_type = nil, *args|
|
91
|
+
return false if op2 == nil
|
92
|
+
self.send("_#{name}", op2, requested_type, *args)
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
90
97
|
#------------------------------------------------------------------------------------
|
91
98
|
#
|
92
99
|
#------------------------------------------------------------------------------------
|
data/test/colt/test_complete.rb
CHANGED
@@ -19,6 +19,11 @@
|
|
19
19
|
# OR MODIFICATIONS.
|
20
20
|
##########################################################################################
|
21
21
|
|
22
|
+
if !(defined? $ENVIR)
|
23
|
+
$ENVIR = true
|
24
|
+
require_relative '../env.rb'
|
25
|
+
end
|
26
|
+
|
22
27
|
require_relative 'test_statistics'
|
23
28
|
require_relative 'test_stat_list'
|
24
29
|
require_relative 'test_math'
|
Binary file
|
data/test/complete.rb
CHANGED
@@ -19,21 +19,19 @@
|
|
19
19
|
# OR MODIFICATIONS.
|
20
20
|
##########################################################################################
|
21
21
|
|
22
|
-
|
22
|
+
$ENVIR = true
|
23
23
|
|
24
|
-
|
25
|
-
require 'colt/test_complete'
|
26
|
-
require 'netcdf/test_complete'
|
24
|
+
require 'env.rb'
|
27
25
|
|
26
|
+
require 'mdarray/test_complete'
|
27
|
+
require 'colt/test_complete'
|
28
|
+
require 'netcdf/test_complete'
|
28
29
|
|
29
30
|
# Temporary tests. Remove before shipping!
|
30
31
|
|
31
32
|
# require 'colt/matrix/test_complete'
|
32
|
-
|
33
33
|
# require 'colt/matrix/test_matrix2d_floatingalgebra'
|
34
34
|
# require 'colt/matrix/test_matrix2d_fixpointalgebra'
|
35
|
-
|
36
35
|
# require 'colt/matrix/test_matrix1d_floatingalgebra'
|
37
36
|
# require 'colt/matrix/test_matrix1d_fixpointalgebra'
|
38
|
-
|
39
37
|
# require 'colt/matrix/test_properties'
|
data/test/env.rb
CHANGED
@@ -1,97 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
# Home directory for MDArray.
|
10
|
-
if $INSTALL_DIR
|
11
|
-
$MDARRAY_HOME_DIR = $INSTALL_DIR
|
12
|
-
else
|
13
|
-
$MDARRAY_HOME_DIR = ".."
|
14
|
-
end
|
15
|
-
|
16
|
-
# MDArray Test directory
|
17
|
-
$MDARRAY_TEST_DIR = "./mdarray"
|
18
|
-
|
19
|
-
# Colt Test directory
|
20
|
-
$COLT_TEST_DIR = "./colt"
|
21
|
-
|
22
|
-
# Tmp directory
|
23
|
-
$TMP_TEST_DIR = "./tmp"
|
24
|
-
|
25
|
-
# Need to change this variable before publication
|
26
|
-
# $MDARRAY_ENV = 'cygwin'
|
27
|
-
|
28
|
-
##########################################################################################
|
29
|
-
# If we need to test for coverage
|
30
|
-
##########################################################################################
|
31
|
-
|
32
|
-
if $COVERAGE == 'true'
|
33
|
-
|
34
|
-
require 'simplecov'
|
35
|
-
|
36
|
-
SimpleCov.start do
|
37
|
-
@filters = []
|
38
|
-
add_group "MDArray", "lib/mdarray"
|
39
|
-
add_group "Colt", "lib/colt"
|
40
|
-
add_group "NetCDF", "lib/netcdf"
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
##########################################################################################
|
46
|
-
# Prepare environment to work inside Cygwin
|
47
|
-
##########################################################################################
|
48
|
-
|
49
|
-
if $MDARRAY_ENV == 'cygwin'
|
50
|
-
|
51
|
-
# RbConfig::CONFIG['host_os'] # returns mswin32 on Windows, for example
|
52
|
-
# p Config::CONFIG
|
53
|
-
|
54
|
-
#---------------------------------------------------------------------------------------
|
55
|
-
# Return the cygpath of a path
|
56
|
-
#---------------------------------------------------------------------------------------
|
57
|
-
|
58
|
-
def cygpath(path)
|
59
|
-
`cygpath -a -p -m #{path}`.tr("\n", "")
|
60
|
-
end
|
61
|
-
|
62
|
-
#---------------------------------------------------------------------------------------
|
63
|
-
# Add path to load path
|
64
|
-
#---------------------------------------------------------------------------------------
|
65
|
-
|
66
|
-
def mklib(path, home_path = true)
|
67
|
-
|
68
|
-
if (home_path)
|
69
|
-
lib = path + "/lib"
|
70
|
-
else
|
71
|
-
lib = path
|
72
|
-
end
|
73
|
-
|
74
|
-
$LOAD_PATH << `cygpath -p -m #{lib}`.tr("\n", "")
|
75
|
-
|
76
|
-
end
|
77
|
-
|
78
|
-
mklib($MDARRAY_HOME_DIR)
|
79
|
-
|
80
|
-
$MDARRAY_TEST_DIR = cygpath($MDARRAY_TEST_DIR)
|
81
|
-
$COLT_TEST_DIR = cygpath($COLT_TEST_DIR)
|
82
|
-
|
83
|
-
else
|
84
|
-
|
85
|
-
def cygpath(path)
|
86
|
-
path
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
|
91
|
-
=begin
|
92
|
-
# Build Jruby classpath from environment classpath
|
93
|
-
ENV['WCLASSPATH'].split(';').each do |path|
|
94
|
-
$CLASSPATH << cygpath(path)
|
95
|
-
end
|
96
|
-
=end
|
97
|
-
|
1
|
+
require_relative '../config.rb'
|
2
|
+
|
3
|
+
# Tmp directory for data storage
|
4
|
+
$TMP_TEST_DIR = MDArray.home_dir + "/test/tmp"
|
5
|
+
#Colt test directory
|
6
|
+
$COLT_TEST_DIR = MDArray.home_dir + "/test/colt"
|
7
|
+
# NetCDF test directory
|
8
|
+
$NETCDF_TEST_DIR = MDArray.home_dir + "/test/netcdf"
|
data/test/mdarray/test_access.rb
CHANGED
@@ -66,6 +66,21 @@ class MDArrayTest < Test::Unit::TestCase
|
|
66
66
|
@b.set([1, 1, 1], 5.25)
|
67
67
|
assert_equal(5.25, @b.get([1, 1, 1]))
|
68
68
|
|
69
|
+
assert_equal(1, @a.get)
|
70
|
+
assert_equal(1, @a.get_as(:int))
|
71
|
+
assert_equal(1, @a.get_as(:int, [0, 0, 0]))
|
72
|
+
assert_equal(1, @a.get_as(:double, [0, 0, 0]))
|
73
|
+
|
74
|
+
assert_equal(5.25, @b[1, 1, 1])
|
75
|
+
assert_raise (RuntimeError) { @b.get_as(:boolean, [1, 1, 1]) }
|
76
|
+
assert_equal(5, @b.get_as(:byte, [1, 1, 1]))
|
77
|
+
assert_equal(5, @b.get_as(:char, [1, 1, 1]))
|
78
|
+
assert_equal(5, @b.get_as(:short, [1, 1, 1]))
|
79
|
+
assert_equal(5, @b.get_as(:int, [1, 1, 1]))
|
80
|
+
assert_equal(5, @b.get_as(:long, [1, 1, 1]))
|
81
|
+
assert_equal(5.25, @b.get_as(:float, [1, 1, 1]))
|
82
|
+
assert_equal(5.25, @b.get_as(:object, [1, 1, 1]))
|
83
|
+
|
69
84
|
end
|
70
85
|
|
71
86
|
#-------------------------------------------------------------------------------------
|
@@ -19,8 +19,10 @@
|
|
19
19
|
# OR MODIFICATIONS.
|
20
20
|
##########################################################################################
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
if !(defined? $ENVIR)
|
23
|
+
$ENVIR = true
|
24
|
+
require_relative '../env.rb'
|
25
|
+
end
|
24
26
|
|
25
27
|
# MDArray main object is the homogeneous multidimensional array. It is a table
|
26
28
|
# of elements (usually numbers), all of the same type, indexed by a tuple of
|
@@ -19,6 +19,11 @@
|
|
19
19
|
# OR MODIFICATIONS.
|
20
20
|
##########################################################################################
|
21
21
|
|
22
|
+
if !(defined? $ENVIR)
|
23
|
+
$ENVIR = true
|
24
|
+
require_relative '../env.rb'
|
25
|
+
end
|
26
|
+
|
22
27
|
require 'rubygems'
|
23
28
|
require "test/unit"
|
24
29
|
require 'shoulda'
|
@@ -60,6 +65,26 @@ class MDArrayTest < Test::Unit::TestCase
|
|
60
65
|
#
|
61
66
|
#-------------------------------------------------------------------------------------
|
62
67
|
|
68
|
+
should "work properly with nil" do
|
69
|
+
|
70
|
+
a = MDArray.int([5, 3, 5])
|
71
|
+
|
72
|
+
assert_raise ( RuntimeError ) { a.fill(nil) }
|
73
|
+
assert_raise ( RuntimeError ) { a + nil }
|
74
|
+
assert_raise ( RuntimeError ) { a.add!(nil) }
|
75
|
+
|
76
|
+
assert_equal(false, a == nil)
|
77
|
+
assert_equal(true, a != nil)
|
78
|
+
assert_equal(false, a.eq(nil))
|
79
|
+
assert_equal(false, a > nil)
|
80
|
+
assert_equal(false, a <= nil)
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
#-------------------------------------------------------------------------------------
|
85
|
+
#
|
86
|
+
#-------------------------------------------------------------------------------------
|
87
|
+
|
63
88
|
should "allow setting values" do
|
64
89
|
|
65
90
|
a = MDArray.int([5, 3, 5])
|
data/test/netcdf/netcdfwriter.rb
CHANGED
@@ -30,7 +30,7 @@ class NetCDF
|
|
30
30
|
# Inside a block we have another scope, so the block cannot access any variables, etc.
|
31
31
|
# from the ouside scope. If we pass the outside scope, in this case we are passing self,
|
32
32
|
# we can access variables in the outside scope by using @outside_scope.<variable>.
|
33
|
-
NetCDF.define(
|
33
|
+
NetCDF.define(@dir, @filename1, "netcdf3", self) do
|
34
34
|
|
35
35
|
# add dimensions
|
36
36
|
dimension "lat", 64
|
@@ -72,7 +72,7 @@ class NetCDF
|
|
72
72
|
|
73
73
|
def write_file
|
74
74
|
|
75
|
-
NetCDF.write(
|
75
|
+
NetCDF.write(@dir, @filename1, self) do
|
76
76
|
|
77
77
|
temperature = find_variable("temperature")
|
78
78
|
shape = temperature.shape
|
@@ -108,7 +108,7 @@ class NetCDF
|
|
108
108
|
|
109
109
|
def define_one_at_time
|
110
110
|
|
111
|
-
NetCDF.define(
|
111
|
+
NetCDF.define(@dir, @filename2, "netcdf3", self) do
|
112
112
|
|
113
113
|
dimension "lat", 3
|
114
114
|
dimension "lon", 4
|
@@ -142,7 +142,7 @@ class NetCDF
|
|
142
142
|
|
143
143
|
def write_one_at_time
|
144
144
|
|
145
|
-
NetCDF.write(
|
145
|
+
NetCDF.write(@dir, @filename2, self) do
|
146
146
|
|
147
147
|
lat = find_variable("lat")
|
148
148
|
lon = find_variable("lon")
|
@@ -19,6 +19,11 @@
|
|
19
19
|
# OR MODIFICATIONS.
|
20
20
|
##########################################################################################
|
21
21
|
|
22
|
+
if !(defined? $ENVIR)
|
23
|
+
$ENVIR = true
|
24
|
+
require_relative '../env.rb'
|
25
|
+
end
|
26
|
+
|
22
27
|
Dir.mkdir($TMP_TEST_DIR) unless File.exists?($TMP_TEST_DIR)
|
23
28
|
|
24
29
|
#=begin
|
data/test/netcdf/test_netcdf.rb
CHANGED
@@ -52,7 +52,7 @@ class MDArrayTest < Test::Unit::TestCase
|
|
52
52
|
# file once and write many times, this is not much of a problem. If one prefers,
|
53
53
|
# one could not use the define block and use the normal APIs.
|
54
54
|
|
55
|
-
NetCDF.define(
|
55
|
+
NetCDF.define(@directory, "nc_output", "netcdf3", self) do
|
56
56
|
|
57
57
|
#=================================================================================
|
58
58
|
# Add global attributes by adding a single valued attribute or an array of
|
@@ -197,7 +197,7 @@ class MDArrayTest < Test::Unit::TestCase
|
|
197
197
|
|
198
198
|
should "open a file for writing data" do
|
199
199
|
|
200
|
-
NetCDF.write(
|
200
|
+
NetCDF.write(@directory, "nc_output", self) do
|
201
201
|
|
202
202
|
# create some data to add to variable
|
203
203
|
array = MDArray.typed_arange("double", 0, 50)
|
@@ -261,7 +261,7 @@ class MDArrayTest < Test::Unit::TestCase
|
|
261
261
|
# ouside scope, that is, "here", we pass self as the third argument to define.
|
262
262
|
# When self is passed as argument, @outside_scope is available inside the block.
|
263
263
|
|
264
|
-
NetCDF.read(
|
264
|
+
NetCDF.read(@directory, "nc_output", self) do
|
265
265
|
|
266
266
|
# print all global attributes
|
267
267
|
global_attributes.each do |att|
|
Binary file
|
data/version.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
$gem_name = "mdarray"
|
2
|
-
$version="0.5.5"
|
2
|
+
$version="0.5.5.1"
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mdarray
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.5.5
|
4
|
+
version: 0.5.5.1
|
6
5
|
platform: java
|
7
6
|
authors:
|
8
7
|
- Rodrigo Botafogo
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-11-16 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: map
|
@@ -18,13 +17,11 @@ dependencies:
|
|
18
17
|
- - '>='
|
19
18
|
- !ruby/object:Gem::Version
|
20
19
|
version: 6.3.0
|
21
|
-
none: false
|
22
20
|
requirement: !ruby/object:Gem::Requirement
|
23
21
|
requirements:
|
24
22
|
- - '>='
|
25
23
|
- !ruby/object:Gem::Version
|
26
24
|
version: 6.3.0
|
27
|
-
none: false
|
28
25
|
prerelease: false
|
29
26
|
type: :runtime
|
30
27
|
- !ruby/object:Gem::Dependency
|
@@ -34,15 +31,13 @@ dependencies:
|
|
34
31
|
- - '>='
|
35
32
|
- !ruby/object:Gem::Version
|
36
33
|
version: '0'
|
37
|
-
none: false
|
38
34
|
requirement: !ruby/object:Gem::Requirement
|
39
35
|
requirements:
|
40
36
|
- - '>='
|
41
37
|
- !ruby/object:Gem::Version
|
42
38
|
version: '0'
|
43
|
-
none: false
|
44
39
|
prerelease: false
|
45
|
-
type: :
|
40
|
+
type: :runtime
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: simplecov
|
48
43
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -50,13 +45,11 @@ dependencies:
|
|
50
45
|
- - '>='
|
51
46
|
- !ruby/object:Gem::Version
|
52
47
|
version: 0.7.1
|
53
|
-
none: false
|
54
48
|
requirement: !ruby/object:Gem::Requirement
|
55
49
|
requirements:
|
56
50
|
- - '>='
|
57
51
|
- !ruby/object:Gem::Version
|
58
52
|
version: 0.7.1
|
59
|
-
none: false
|
60
53
|
prerelease: false
|
61
54
|
type: :development
|
62
55
|
- !ruby/object:Gem::Dependency
|
@@ -66,13 +59,11 @@ dependencies:
|
|
66
59
|
- - '>='
|
67
60
|
- !ruby/object:Gem::Version
|
68
61
|
version: 0.8.5.2
|
69
|
-
none: false
|
70
62
|
requirement: !ruby/object:Gem::Requirement
|
71
63
|
requirements:
|
72
64
|
- - '>='
|
73
65
|
- !ruby/object:Gem::Version
|
74
66
|
version: 0.8.5.2
|
75
|
-
none: false
|
76
67
|
prerelease: false
|
77
68
|
type: :development
|
78
69
|
- !ruby/object:Gem::Dependency
|
@@ -82,13 +73,11 @@ dependencies:
|
|
82
73
|
- - '>='
|
83
74
|
- !ruby/object:Gem::Version
|
84
75
|
version: 1.0.1
|
85
|
-
none: false
|
86
76
|
requirement: !ruby/object:Gem::Requirement
|
87
77
|
requirements:
|
88
78
|
- - '>='
|
89
79
|
- !ruby/object:Gem::Version
|
90
80
|
version: 1.0.1
|
91
|
-
none: false
|
92
81
|
prerelease: false
|
93
82
|
type: :development
|
94
83
|
description: "\"MDArray is a multi dimensional array implemented for JRuby inspired\
|
@@ -112,6 +101,7 @@ extra_rdoc_files: []
|
|
112
101
|
files:
|
113
102
|
- Rakefile
|
114
103
|
- version.rb
|
104
|
+
- config.rb
|
115
105
|
- lib/env.rb
|
116
106
|
- lib/mdarray.rb
|
117
107
|
- lib/colt/cern_double_functions.rb
|
@@ -130,7 +120,6 @@ files:
|
|
130
120
|
- lib/colt/matrix/property.rb
|
131
121
|
- lib/mdarray/access.rb
|
132
122
|
- lib/mdarray/counter.rb
|
133
|
-
- lib/mdarray/creation.rb
|
134
123
|
- lib/mdarray/csv.rb
|
135
124
|
- lib/mdarray/fast_operators.rb
|
136
125
|
- lib/mdarray/function_creation.rb
|
@@ -150,6 +139,7 @@ files:
|
|
150
139
|
- lib/mdarray/ruby_stats.rb
|
151
140
|
- lib/mdarray/section.rb
|
152
141
|
- lib/mdarray/views.rb
|
142
|
+
- lib/mdarray/creation.rb
|
153
143
|
- lib/netcdf/attribute.rb
|
154
144
|
- lib/netcdf/cdm_node.rb
|
155
145
|
- lib/netcdf/dimension.rb
|
@@ -165,12 +155,12 @@ files:
|
|
165
155
|
- test/colt/test_statistics.rb
|
166
156
|
- test/colt/test_stat_list.rb
|
167
157
|
- test/colt/matrix/test_complete.rb
|
158
|
+
- test/colt/matrix/test_creation.rb
|
168
159
|
- test/colt/matrix/test_matrix1d_floatingalgebra.rb
|
169
160
|
- test/colt/matrix/test_matrix2d_fixpointalgebra.rb
|
170
161
|
- test/colt/matrix/test_matrix2d_floatingalgebra.rb
|
171
162
|
- test/colt/matrix/test_operations.rb
|
172
163
|
- test/colt/matrix/test_properties.rb
|
173
|
-
- test/colt/matrix/test_creation.rb
|
174
164
|
- test/mdarray/arithmetic_casting.rb
|
175
165
|
- test/mdarray/test_access.rb
|
176
166
|
- test/mdarray/test_boolean.rb
|
@@ -198,6 +188,7 @@ files:
|
|
198
188
|
- test/colt/ColtMethods.xlsx
|
199
189
|
- test/colt/VALE3.xlsx
|
200
190
|
- test/colt/VALE3_short.xlsx
|
191
|
+
- test/colt/~$VALE3_short.xlsx
|
201
192
|
- doc/20130625 MDArray Internals.docx
|
202
193
|
- doc/BinaryOperator.html
|
203
194
|
- doc/BitwiseOperators.html
|
@@ -262,8 +253,8 @@ files:
|
|
262
253
|
- doc/MDArray/IteratorFastInt.html
|
263
254
|
- doc/MDArray/IteratorFastLong.html
|
264
255
|
- doc/MDArray/IteratorFastShort.html
|
265
|
-
- vendor/netcdfAll-4.3.18.jar
|
266
256
|
- vendor/mdarray.jar
|
257
|
+
- vendor/netcdfAll-4.5_0.jar
|
267
258
|
- target/helper.jar
|
268
259
|
- README.md
|
269
260
|
- LICENSE.txt
|
@@ -271,6 +262,7 @@ files:
|
|
271
262
|
homepage: http://github.com/rbotafogo/mdarray/wiki
|
272
263
|
licenses:
|
273
264
|
- BSD 2-clause
|
265
|
+
metadata: {}
|
274
266
|
post_install_message:
|
275
267
|
rdoc_options: []
|
276
268
|
require_paths:
|
@@ -280,18 +272,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
280
272
|
- - '>='
|
281
273
|
- !ruby/object:Gem::Version
|
282
274
|
version: '0'
|
283
|
-
none: false
|
284
275
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
285
276
|
requirements:
|
286
277
|
- - '>='
|
287
278
|
- !ruby/object:Gem::Version
|
288
279
|
version: '0'
|
289
|
-
none: false
|
290
280
|
requirements: []
|
291
281
|
rubyforge_project:
|
292
|
-
rubygems_version: 1.
|
282
|
+
rubygems_version: 2.1.9
|
293
283
|
signing_key:
|
294
|
-
specification_version:
|
284
|
+
specification_version: 4
|
295
285
|
summary: Multi dimensional array similar to narray and numpy.
|
296
286
|
test_files:
|
297
287
|
- test/complete.rb
|