mdarray 0.4.0-java → 0.4.2-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.
- data/README.md +1 -0
- data/Rakefile +1 -1
- data/lib/mdarray.rb +3 -33
- data/lib/mdarray/access.rb +0 -24
- data/lib/mdarray/hierarchy.rb +0 -56
- data/lib/mdarray/operators.rb +62 -17
- data/lib/mdarray/ruby_boolean_functions.rb +43 -0
- data/lib/mdarray/ruby_functions.rb +1 -0
- data/lib/mdarray/ruby_operators.rb +1 -0
- data/lib/mdarray/ruby_stats.rb +32 -19
- data/lib/mdarray/{slices.rb → views.rb} +76 -9
- data/test/test_boolean.rb +4 -3
- data/test/test_complete.rb +19 -13
- data/test/test_counter.rb +2 -19
- data/test/test_creation.rb +0 -1
- data/test/test_operator.rb +22 -9
- data/test/test_printing.rb +8 -9
- data/test/test_statistics.rb +1 -8
- data/test/test_views.rb +291 -0
- data/version.rb +1 -1
- metadata +16 -41
- data/lib/mdarray/fast_non_numerical.rb +0 -102
- data/lib/mdarray/statistics.rb +0 -86
- data/test/test_slices.rb +0 -146
data/version.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
$gem_name = "mdarray"
|
2
|
-
$version="0.4.
|
2
|
+
$version="0.4.2"
|
metadata
CHANGED
@@ -2,64 +2,44 @@
|
|
2
2
|
name: mdarray
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.4.
|
5
|
+
version: 0.4.2
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- Rodrigo Botafogo
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: map
|
16
16
|
version_requirements: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
21
|
-
MA==
|
20
|
+
version: 6.3.0
|
22
21
|
none: false
|
23
22
|
requirement: !ruby/object:Gem::Requirement
|
24
23
|
requirements:
|
25
24
|
- - ">="
|
26
25
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
28
|
-
MA==
|
26
|
+
version: 6.3.0
|
29
27
|
none: false
|
30
28
|
prerelease: false
|
31
29
|
type: :runtime
|
32
|
-
- !ruby/object:Gem::Dependency
|
33
|
-
name: rspec
|
34
|
-
version_requirements: !ruby/object:Gem::Requirement
|
35
|
-
requirements:
|
36
|
-
- - ">="
|
37
|
-
- !ruby/object:Gem::Version
|
38
|
-
version: 2.0.0
|
39
|
-
none: false
|
40
|
-
requirement: !ruby/object:Gem::Requirement
|
41
|
-
requirements:
|
42
|
-
- - ">="
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version: 2.0.0
|
45
|
-
none: false
|
46
|
-
prerelease: false
|
47
|
-
type: :development
|
48
30
|
- !ruby/object:Gem::Dependency
|
49
31
|
name: simplecov
|
50
32
|
version_requirements: !ruby/object:Gem::Requirement
|
51
33
|
requirements:
|
52
34
|
- - ">="
|
53
35
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
-
MA==
|
36
|
+
version: 0.7.1
|
56
37
|
none: false
|
57
38
|
requirement: !ruby/object:Gem::Requirement
|
58
39
|
requirements:
|
59
40
|
- - ">="
|
60
41
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
62
|
-
MA==
|
42
|
+
version: 0.7.1
|
63
43
|
none: false
|
64
44
|
prerelease: false
|
65
45
|
type: :development
|
@@ -69,15 +49,13 @@ dependencies:
|
|
69
49
|
requirements:
|
70
50
|
- - ">="
|
71
51
|
- !ruby/object:Gem::Version
|
72
|
-
version:
|
73
|
-
MA==
|
52
|
+
version: 0.8.5.2
|
74
53
|
none: false
|
75
54
|
requirement: !ruby/object:Gem::Requirement
|
76
55
|
requirements:
|
77
56
|
- - ">="
|
78
57
|
- !ruby/object:Gem::Version
|
79
|
-
version:
|
80
|
-
MA==
|
58
|
+
version: 0.8.5.2
|
81
59
|
none: false
|
82
60
|
prerelease: false
|
83
61
|
type: :development
|
@@ -87,15 +65,13 @@ dependencies:
|
|
87
65
|
requirements:
|
88
66
|
- - ">="
|
89
67
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
91
|
-
MA==
|
68
|
+
version: 1.0.1
|
92
69
|
none: false
|
93
70
|
requirement: !ruby/object:Gem::Requirement
|
94
71
|
requirements:
|
95
72
|
- - ">="
|
96
73
|
- !ruby/object:Gem::Version
|
97
|
-
version:
|
98
|
-
MA==
|
74
|
+
version: 1.0.1
|
99
75
|
none: false
|
100
76
|
prerelease: false
|
101
77
|
type: :development
|
@@ -114,21 +90,20 @@ files:
|
|
114
90
|
- lib/mdarray/access.rb
|
115
91
|
- lib/mdarray/counter.rb
|
116
92
|
- lib/mdarray/creation.rb
|
117
|
-
- lib/mdarray/fast_non_numerical.rb
|
118
93
|
- lib/mdarray/function_creation.rb
|
119
94
|
- lib/mdarray/function_map.rb
|
120
95
|
- lib/mdarray/hierarchy.rb
|
121
96
|
- lib/mdarray/operators.rb
|
122
97
|
- lib/mdarray/printing.rb
|
123
98
|
- lib/mdarray/proc_util.rb
|
99
|
+
- lib/mdarray/ruby_boolean_functions.rb
|
124
100
|
- lib/mdarray/ruby_functions.rb
|
125
101
|
- lib/mdarray/ruby_generic_functions.rb
|
126
102
|
- lib/mdarray/ruby_math.rb
|
127
103
|
- lib/mdarray/ruby_numeric_functions.rb
|
128
104
|
- lib/mdarray/ruby_operators.rb
|
129
105
|
- lib/mdarray/ruby_stats.rb
|
130
|
-
- lib/mdarray/
|
131
|
-
- lib/mdarray/statistics.rb
|
106
|
+
- lib/mdarray/views.rb
|
132
107
|
- test/arithmetic_casting.rb
|
133
108
|
- test/env.rb
|
134
109
|
- test/test_access.rb
|
@@ -142,15 +117,15 @@ files:
|
|
142
117
|
- test/test_operator.rb
|
143
118
|
- test/test_printing.rb
|
144
119
|
- test/test_shape.rb
|
145
|
-
- test/test_slices.rb
|
146
120
|
- test/test_speed.rb
|
147
121
|
- test/test_statistics.rb
|
148
122
|
- test/test_trigonometry.rb
|
123
|
+
- test/test_views.rb
|
149
124
|
- vendor/netcdfAll-4.3.16.jar
|
150
125
|
- README.md
|
151
126
|
- LICENSE.txt
|
152
127
|
- LICENSE.txt~
|
153
|
-
homepage: http://github.com/rbotafogo/mdarray
|
128
|
+
homepage: http://github.com/rbotafogo/mdarray/wiki
|
154
129
|
licenses: []
|
155
130
|
post_install_message:
|
156
131
|
rdoc_options: []
|
@@ -190,8 +165,8 @@ test_files:
|
|
190
165
|
- test/test_operator.rb
|
191
166
|
- test/test_printing.rb
|
192
167
|
- test/test_shape.rb
|
193
|
-
- test/test_slices.rb
|
194
168
|
- test/test_speed.rb
|
195
169
|
- test/test_statistics.rb
|
196
170
|
- test/test_trigonometry.rb
|
171
|
+
- test/test_views.rb
|
197
172
|
has_rdoc:
|
@@ -1,102 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
##########################################################################################
|
4
|
-
# Copyright © 2013 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
|
5
|
-
# and distribute this software and its documentation, without fee and without a signed
|
6
|
-
# licensing agreement, is hereby granted, provided that the above copyright notice, this
|
7
|
-
# paragraph and the following two paragraphs appear in all copies, modifications, and
|
8
|
-
# distributions.
|
9
|
-
#
|
10
|
-
# IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
|
11
|
-
# INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
|
12
|
-
# THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
|
13
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
14
|
-
#
|
15
|
-
# RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
16
|
-
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
|
17
|
-
# SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
|
18
|
-
# RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
|
19
|
-
# OR MODIFICATIONS.
|
20
|
-
##########################################################################################
|
21
|
-
|
22
|
-
##########################################################################################
|
23
|
-
#
|
24
|
-
##########################################################################################
|
25
|
-
|
26
|
-
class FastBoolean < BooleanMDArray
|
27
|
-
|
28
|
-
|
29
|
-
#---------------------------------------------------------------------------------------
|
30
|
-
#
|
31
|
-
#---------------------------------------------------------------------------------------
|
32
|
-
|
33
|
-
def initialize(storage, section = false)
|
34
|
-
super("boolean", storage, section)
|
35
|
-
end
|
36
|
-
|
37
|
-
#---------------------------------------------------------------------------------------
|
38
|
-
# Executes a boolean operator. Valid boolean operators are: and, or. Only applicable
|
39
|
-
# to boolean operands
|
40
|
-
#---------------------------------------------------------------------------------------
|
41
|
-
|
42
|
-
def exec_boolean_op(dest, other_val, method)
|
43
|
-
|
44
|
-
proc = Proc.new { |elmt, value| method.call(elmt, value) }
|
45
|
-
|
46
|
-
if ((other_val.is_a? TrueClass) || (other_val.is_a? FalseClass))
|
47
|
-
@helper.send("booleanOperationWithBool", dest.nc_array, @nc_array, other_val, proc)
|
48
|
-
elsif (other_val.is_a? MDArray)
|
49
|
-
if (compatible(other_val))
|
50
|
-
@helper.send("booleanOperationWithArray", dest.nc_array, @nc_array,
|
51
|
-
other_val.nc_array, proc)
|
52
|
-
else
|
53
|
-
raise "Invalid operation - arrays are incompatible"
|
54
|
-
end
|
55
|
-
else
|
56
|
-
raise "Invalid operation with: #{other_val}"
|
57
|
-
end
|
58
|
-
|
59
|
-
return dest
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
#---------------------------------------------------------------------------------------
|
64
|
-
# Executes a boolean operator. Valid boolean operators are: and, or. Only applicable
|
65
|
-
# to boolean operands
|
66
|
-
#---------------------------------------------------------------------------------------
|
67
|
-
|
68
|
-
def exec_bin_op(op1, op2, proc, base)
|
69
|
-
|
70
|
-
args = Array.new
|
71
|
-
args << @nc_array
|
72
|
-
(op1)? args << op1.nc_array : nil
|
73
|
-
|
74
|
-
if (op2.is_a? Numeric)
|
75
|
-
name = base + "WithNumber"
|
76
|
-
args << op2
|
77
|
-
elsif (op2.is_a? NumericalMDArray)
|
78
|
-
if (compatible(op2))
|
79
|
-
name = base + "WithArray"
|
80
|
-
args << op2.nc_array
|
81
|
-
else
|
82
|
-
raise "Invalid operation - arrays are incompatible"
|
83
|
-
end
|
84
|
-
else
|
85
|
-
raise "Invalid operation with: #{op2}"
|
86
|
-
=begin
|
87
|
-
# *TODO: make it more general using coerce if other_val type is not recognized
|
88
|
-
if (arg is not recognized)
|
89
|
-
self_equiv, arg_equiv = arg.coerce(self)
|
90
|
-
self_equiv * arg_equiv
|
91
|
-
end
|
92
|
-
=end
|
93
|
-
end
|
94
|
-
|
95
|
-
args << proc
|
96
|
-
@helper.send(make_function_name(name), *args)
|
97
|
-
return self
|
98
|
-
|
99
|
-
end
|
100
|
-
|
101
|
-
end # FastBoolean
|
102
|
-
|
data/lib/mdarray/statistics.rb
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
##########################################################################################
|
4
|
-
# Copyright © 2013 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
|
5
|
-
# and distribute this software and its documentation, without fee and without a signed
|
6
|
-
# licensing agreement, is hereby granted, provided that the above copyright notice, this
|
7
|
-
# paragraph and the following two paragraphs appear in all copies, modifications, and
|
8
|
-
# distributions.
|
9
|
-
#
|
10
|
-
# IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
|
11
|
-
# INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
|
12
|
-
# THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
|
13
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
14
|
-
#
|
15
|
-
# RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
16
|
-
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
|
17
|
-
# SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
|
18
|
-
# RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
|
19
|
-
# OR MODIFICATIONS.
|
20
|
-
##########################################################################################
|
21
|
-
|
22
|
-
class MDArray
|
23
|
-
|
24
|
-
#---------------------------------------------------------------------------------------
|
25
|
-
#
|
26
|
-
#---------------------------------------------------------------------------------------
|
27
|
-
|
28
|
-
def stdev
|
29
|
-
return Math.sqrt(variance)
|
30
|
-
end
|
31
|
-
|
32
|
-
alias standard_deviation :stdev
|
33
|
-
|
34
|
-
#---------------------------------------------------------------------------------------
|
35
|
-
#
|
36
|
-
#---------------------------------------------------------------------------------------
|
37
|
-
|
38
|
-
def error_estimate
|
39
|
-
Math.sqrt(variance/size)
|
40
|
-
end
|
41
|
-
|
42
|
-
#---------------------------------------------------------------------------------------
|
43
|
-
#
|
44
|
-
#---------------------------------------------------------------------------------------
|
45
|
-
|
46
|
-
def skewness
|
47
|
-
|
48
|
-
n = size
|
49
|
-
|
50
|
-
if (n <= 2)
|
51
|
-
raise "Cannot calculate skewness on array with less than 3 elements"
|
52
|
-
end
|
53
|
-
|
54
|
-
x = expectation_value(MDArray.method(:cube).to_proc *
|
55
|
-
MDArray.method(:sub).to_proc.bind2nd(mean),
|
56
|
-
Proc.everywhere)[0]
|
57
|
-
sigma = stdev
|
58
|
-
|
59
|
-
return (x/(sigma*sigma*sigma)) * (n/(n-1)) * (n/(n-2))
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
#---------------------------------------------------------------------------------------
|
64
|
-
#
|
65
|
-
#---------------------------------------------------------------------------------------
|
66
|
-
|
67
|
-
def kurtosis
|
68
|
-
|
69
|
-
n = size
|
70
|
-
|
71
|
-
if (n <= 3)
|
72
|
-
raise "Cannot calculate kurtosis on array with less than 4 elements"
|
73
|
-
end
|
74
|
-
|
75
|
-
x = expectation_value(MDArray.method(:fourth).to_proc *
|
76
|
-
MDArray.method(:sub).to_proc.bind2nd(mean),
|
77
|
-
Proc.everywhere)[0]
|
78
|
-
|
79
|
-
sigma2 = variance
|
80
|
-
c1 = (n/(n-1)) * (n/(n-2)) * ((n+1)/(n-3))
|
81
|
-
c2 = 3 * ((n-1)/(n-2)) * ((n-1)/(n-3))
|
82
|
-
return c1 * (x/(sigma2*sigma2)) - c2
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
data/test/test_slices.rb
DELETED
@@ -1,146 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require "test/unit"
|
3
|
-
require 'shoulda'
|
4
|
-
|
5
|
-
require 'env'
|
6
|
-
require 'mdarray'
|
7
|
-
|
8
|
-
class MDArrayTest < Test::Unit::TestCase
|
9
|
-
|
10
|
-
context "Slice Tests" do
|
11
|
-
|
12
|
-
setup do
|
13
|
-
|
14
|
-
# creates an array from a function (actually a block). The name fromfunction
|
15
|
-
# is preserved to maintain API compatibility with NumPy (is it necessary?)
|
16
|
-
|
17
|
-
# simulating financial data: 1 year, 20 days, 10 securities, 7 values (open,
|
18
|
-
# close, high, low, volume, e1, e2)
|
19
|
-
@a = MDArray.fromfunction("double", [1, 20, 10, 7]) do |x, y, z, k|
|
20
|
-
0.5 * x + y + 10 * (z + 1) + Math.sin(k + x)
|
21
|
-
end
|
22
|
-
|
23
|
-
@b = MDArray.int([2, 2])
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
#-------------------------------------------------------------------------------------
|
28
|
-
#
|
29
|
-
#-------------------------------------------------------------------------------------
|
30
|
-
=begin
|
31
|
-
should "get section with range" do
|
32
|
-
|
33
|
-
@b[/1:2:3/, /1:5/, /3:4/, 1]
|
34
|
-
|
35
|
-
end
|
36
|
-
=end
|
37
|
-
|
38
|
-
#-------------------------------------------------------------------------------------
|
39
|
-
#
|
40
|
-
#-------------------------------------------------------------------------------------
|
41
|
-
|
42
|
-
should "slice array along axes" do
|
43
|
-
|
44
|
-
@a.each_along_axes([3]) do |slice|
|
45
|
-
slice.print
|
46
|
-
print "\n"
|
47
|
-
end
|
48
|
-
|
49
|
-
# each_along_axes returns sub-arrays (sections) of the original array. Each section
|
50
|
-
# is taken by walking along the given axis and getting the all elements of the
|
51
|
-
# axis that were not given. For instance, array @a shape is [1, 20, 10, 7]. Slicing
|
52
|
-
# along axes [0, 2] will get the following sections of @a:
|
53
|
-
# section([0, 0, 0, 0], [1, 20, 1, 7]), section ([0, 0, 1, 0], [1, 20, 1, 7]),
|
54
|
-
# section([0, 0, 2, 0], [1, 20, 1, 7])...
|
55
|
-
# This is actually getting all values for every security for the 20 days.
|
56
|
-
|
57
|
-
@a.each_along_axes([0, 2]) do |slice|
|
58
|
-
slice.print
|
59
|
-
p slice.cum_op(MDArray.method(:add))
|
60
|
-
print "\n"
|
61
|
-
end
|
62
|
-
|
63
|
-
# Here we are getting 7 arrays for "open", "close", "High", "Low", etc. each
|
64
|
-
# containing all the 20 days for each security. So, the first array has 20 elements
|
65
|
-
# each with the "open" value for the first security. The second array returns
|
66
|
-
# has 20 elements, each with the "close" value for the first security.
|
67
|
-
@a.each_along_axes([2, 3]) do |slice|
|
68
|
-
slice.print
|
69
|
-
print "\n"
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
#-------------------------------------------------------------------------------------
|
75
|
-
#
|
76
|
-
#-------------------------------------------------------------------------------------
|
77
|
-
|
78
|
-
should "get array section" do
|
79
|
-
|
80
|
-
# 1 -> first year (only 1 year)
|
81
|
-
# 20 -> 20 days
|
82
|
-
# 10 -> number os secs
|
83
|
-
# 7 - > number of values
|
84
|
-
|
85
|
-
# b is a section of @a, starting a position (0) and taking only the first two
|
86
|
-
# elements of the first dimension. Getting all values, for all secs for the first
|
87
|
-
# 2 days
|
88
|
-
b = @a.section([0, 0, 0, 0], [1, 2, 10, 7])
|
89
|
-
assert_equal(true, b.section?)
|
90
|
-
assert_equal([1, 2, 10, 7], b.shape)
|
91
|
-
ind = b.get_index
|
92
|
-
ind.each do |elmt|
|
93
|
-
assert_equal(@a.get(elmt), b.get(elmt))
|
94
|
-
end
|
95
|
-
|
96
|
-
# getting "open" for the first 2 days of the 3rd sec
|
97
|
-
b = @a.section([0, 0, 3, 0], [1, 2, 1, 1])
|
98
|
-
assert_equal(40.00, b[0, 0, 0, 0])
|
99
|
-
assert_equal(41.00, b[0, 1, 0, 0])
|
100
|
-
|
101
|
-
# getting "close" (2nd) value of the 3rd sec for the second day with
|
102
|
-
# shape reduction. Note that in this case, with shape reduction, b is a
|
103
|
-
# number and not an array any more
|
104
|
-
b = @a.section([0, 1, 2, 1], [1, 1, 1, 1], true)
|
105
|
-
assert_equal(@a[0, 1, 2, 1], b)
|
106
|
-
|
107
|
-
# getting the "close" (2nd) value of the 3rd sec for the second day without
|
108
|
-
# shape reduction
|
109
|
-
b = @a.section([0, 1, 2, 1], [1, 1, 1, 1])
|
110
|
-
assert_equal([1, 1, 1, 1], b.shape)
|
111
|
-
assert_equal(@a[0, 1, 2, 1], b[0, 0, 0, 0])
|
112
|
-
|
113
|
-
# getting the "open" (1rst) value of the second secs for two days
|
114
|
-
b = @a.section([0, 0, 0, 0], [1, 2, 1, 1])
|
115
|
-
assert_equal([1, 2, 1, 1], b.shape)
|
116
|
-
assert_equal(@a[0, 0, 0, 0], b[0, 0, 0, 0])
|
117
|
-
assert_equal(@a[0, 1, 0, 0], b[0, 1, 0, 0])
|
118
|
-
|
119
|
-
# getting the "open" (1rst) value of the second secs for two days with rank
|
120
|
-
# reduction
|
121
|
-
b = @a.section([0, 0, 0, 0], [1, 2, 1, 1], true)
|
122
|
-
assert_equal([2], b.shape)
|
123
|
-
assert_equal(@a[0, 0, 0, 0], b[0])
|
124
|
-
assert_equal(@a[0, 1, 0, 0], b[1])
|
125
|
-
|
126
|
-
# getting the first security, all values
|
127
|
-
b = @a.section([0, 0, 0, 0], [1, 1, 1, 7])
|
128
|
-
# b.print
|
129
|
-
|
130
|
-
# getting the 2 security, all values
|
131
|
-
b = @a.section([0, 0, 1, 0], [1, 1, 1, 7])
|
132
|
-
# b.print
|
133
|
-
|
134
|
-
# getting the 1 day, all then secs
|
135
|
-
b = @a.section([0, 0, 0, 0], [1, 1, 10, 7])
|
136
|
-
# b.print
|
137
|
-
|
138
|
-
# getting the "open" (1st) value of all secs for the first day
|
139
|
-
b = @a.section([0, 0, 0, 0], [1, 1, 10, 1])
|
140
|
-
# b.print
|
141
|
-
|
142
|
-
end
|
143
|
-
|
144
|
-
end
|
145
|
-
|
146
|
-
end
|