flex_array 0.3.5 → 0.3.6
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/.gitignore +0 -15
- data/.reek.yml +17 -0
- data/README.md +11 -0
- data/bench/benchmark.rb +243 -0
- data/bench/results.txt +97 -0
- data/flex_array.gemspec +5 -9
- data/lib/flex_array.rb +13 -30
- data/lib/flex_array/array.rb +9 -24
- data/lib/flex_array/flex_array_append.rb +4 -23
- data/lib/flex_array/flex_array_each.rb +33 -208
- data/lib/flex_array/flex_array_forever.rb +6 -4
- data/lib/flex_array/flex_array_index.rb +4 -29
- data/lib/flex_array/flex_array_new.rb +9 -56
- data/lib/flex_array/flex_array_process.rb +23 -63
- data/lib/flex_array/flex_array_reshape.rb +13 -23
- data/lib/flex_array/flex_array_transpose.rb +7 -16
- data/lib/flex_array/flex_array_validate.rb +5 -14
- data/lib/flex_array/integer.rb +4 -13
- data/lib/flex_array/object.rb +4 -13
- data/lib/flex_array/range.rb +4 -13
- data/lib/flex_array/spec_array.rb +5 -9
- data/lib/flex_array/spec_component.rb +14 -22
- data/lib/flex_array/version.rb +1 -2
- data/rakefile.rb +0 -10
- data/reek.txt +9 -2
- data/tests/array_test.rb +0 -4
- data/tests/flex_array_append_test.rb +0 -23
- data/tests/flex_array_each_test.rb +483 -487
- data/tests/flex_array_index_test.rb +0 -4
- data/tests/flex_array_new_test.rb +0 -4
- data/tests/flex_array_reshape_test.rb +4 -4
- data/tests/flex_array_test.rb +0 -4
- data/tests/flex_array_transpose_test.rb +0 -4
- data/tests/flex_array_validate_test.rb +0 -4
- data/tests/integer_test.rb +0 -4
- data/tests/object_test.rb +0 -4
- data/tests/range_test.rb +0 -4
- data/tests/spec_array_test.rb +0 -4
- data/tests/spec_component_test.rb +0 -4
- metadata +12 -43
- data/docs/Flex_Array_UG.odt +0 -0
- data/docs/Flex_Array_UG_Version_0_3_0.pdf +0 -0
- data/flex_array.reek +0 -109
- data/sire.rb +0 -82
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63cdb72eff0521ddcf4d821c6d1cdf901191414a
|
4
|
+
data.tar.gz: 95937c185aa498a223074cac92eb191206e46122
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1a80120b2cabf12997f3f735f31a949e5d91d6f1a74a4bfbd54cb5f0f19dc9cc925062d55af30f72a69b218197b52086f702e925afd9fb7b7e4d626e48b23ea
|
7
|
+
data.tar.gz: 9edda6248e614cedfe4051e1e5ea1b24dfc6d7dab37a13e9d4089c0f844009d14c22942488b28e68010dc7b0d3178e070881732bb47dd3ea78ea7e56d18e1f3c
|
data/.gitignore
CHANGED
data/.reek.yml
ADDED
data/README.md
CHANGED
@@ -54,3 +54,14 @@ document (.pdf) formats.
|
|
54
54
|
|
55
55
|
Go to the GitHub repository and raise an issue calling attention to some
|
56
56
|
aspect that could use some TLC or a suggestion or an idea.
|
57
|
+
|
58
|
+
## License
|
59
|
+
|
60
|
+
The gem is available as open source under the terms of the
|
61
|
+
[MIT License](./LICENSE.txt).
|
62
|
+
|
63
|
+
## Code of Conduct
|
64
|
+
|
65
|
+
Everyone interacting in the fully_freeze project’s codebases, issue trackers,
|
66
|
+
chat rooms and mailing lists is expected to follow the
|
67
|
+
[code of conduct](./CODE_OF_CONDUCT.md).
|
data/bench/benchmark.rb
ADDED
@@ -0,0 +1,243 @@
|
|
1
|
+
#Benchmark studies of flex array.
|
2
|
+
|
3
|
+
require 'benchmark'
|
4
|
+
require_relative '../lib/flex_array'
|
5
|
+
|
6
|
+
puts "Ruby version = #{RUBY_VERSION}"
|
7
|
+
puts "FlexArray version = #{FlexArray::VERSION}"
|
8
|
+
puts
|
9
|
+
|
10
|
+
enable_creating_tests = true
|
11
|
+
enable_accessing_tests = true
|
12
|
+
|
13
|
+
ct = 1000
|
14
|
+
|
15
|
+
sz = 10000
|
16
|
+
s2d = [100, 100]
|
17
|
+
s3d = [10, 10, 100]
|
18
|
+
s4d = [10, 10, 10, 10]
|
19
|
+
s5d = [5, 5, 4, 10, 10]
|
20
|
+
|
21
|
+
c1s = [1..9998]
|
22
|
+
c2s = [1..98, 1..98]
|
23
|
+
c3s = [1..8, 1..8, 1..98]
|
24
|
+
c4s = [1..8, 1..8, 1..8, 1..8]
|
25
|
+
c5s = [1..3, 1..3, 1..2, 1..8, 1..8]
|
26
|
+
|
27
|
+
|
28
|
+
cyc_ct = ct*sz
|
29
|
+
|
30
|
+
|
31
|
+
puts "Creating arrays:"
|
32
|
+
puts "=============================================================================="
|
33
|
+
|
34
|
+
if enable_creating_tests
|
35
|
+
|
36
|
+
Benchmark.bmbm do |x|
|
37
|
+
|
38
|
+
x.report("Array obj:") {
|
39
|
+
ct.times { Array.new(sz, "cat") }
|
40
|
+
}
|
41
|
+
|
42
|
+
x.report("Flex 1d obj:") {
|
43
|
+
ct.times { FlexArray.new(sz, "cat") }
|
44
|
+
}
|
45
|
+
|
46
|
+
x.report("Flex 2d obj:") {
|
47
|
+
ct.times { FlexArray.new(s2d, "cat") }
|
48
|
+
}
|
49
|
+
|
50
|
+
x.report("Flex 3d obj:") {
|
51
|
+
ct.times { FlexArray.new(s3d, "cat") }
|
52
|
+
}
|
53
|
+
|
54
|
+
x.report("Flex 4d obj:") {
|
55
|
+
ct.times { FlexArray.new(s4d, "cat") }
|
56
|
+
}
|
57
|
+
|
58
|
+
x.report("Flex 5d obj:") {
|
59
|
+
ct.times { FlexArray.new(s5d, "cat") }
|
60
|
+
}
|
61
|
+
|
62
|
+
|
63
|
+
x.report("Array blk:") {
|
64
|
+
ct.times { Array.new(sz) {"cat"} }
|
65
|
+
}
|
66
|
+
|
67
|
+
x.report("Flex 1d blk:") {
|
68
|
+
ct.times { FlexArray.new(sz) {"cat"} }
|
69
|
+
}
|
70
|
+
|
71
|
+
x.report("Flex 2d blk:") {
|
72
|
+
ct.times { FlexArray.new(s2d) {"cat"} }
|
73
|
+
}
|
74
|
+
|
75
|
+
x.report("Flex 3d blk:") {
|
76
|
+
ct.times { FlexArray.new(s3d) {"cat"} }
|
77
|
+
}
|
78
|
+
|
79
|
+
x.report("Flex 4d blk:") {
|
80
|
+
ct.times { FlexArray.new(s4d) {"cat"} }
|
81
|
+
}
|
82
|
+
|
83
|
+
x.report("Flex 5d blk:") {
|
84
|
+
ct.times { FlexArray.new(s5d) {"cat"} }
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
src = Array.new(sz, "cat")
|
89
|
+
|
90
|
+
x.report("Flex 1d from:") {
|
91
|
+
ct.times { FlexArray.new_from(sz, src) }
|
92
|
+
}
|
93
|
+
|
94
|
+
x.report("Flex 2d from:") {
|
95
|
+
ct.times { FlexArray.new_from(s2d, src) }
|
96
|
+
}
|
97
|
+
|
98
|
+
x.report("Flex 3d from:") {
|
99
|
+
ct.times { FlexArray.new_from(s3d, src) }
|
100
|
+
}
|
101
|
+
|
102
|
+
x.report("Flex 4d from:") {
|
103
|
+
ct.times { FlexArray.new_from(s4d, src) }
|
104
|
+
}
|
105
|
+
|
106
|
+
x.report("Flex 5d from:") {
|
107
|
+
ct.times { FlexArray.new_from(s5d, src) }
|
108
|
+
}
|
109
|
+
end
|
110
|
+
|
111
|
+
else
|
112
|
+
puts "Test disabled."
|
113
|
+
end
|
114
|
+
|
115
|
+
puts
|
116
|
+
|
117
|
+
puts "Accessing arrays:"
|
118
|
+
puts "=============================================================================="
|
119
|
+
|
120
|
+
if enable_accessing_tests
|
121
|
+
array = Array.new(sz, 1.0)
|
122
|
+
fa_1d = FlexArray.new(sz, 1.0)
|
123
|
+
fa_2d = FlexArray.new(s2d, 1.0)
|
124
|
+
fa_3d = FlexArray.new(s3d, 1.0)
|
125
|
+
fa_4d = FlexArray.new(s4d, 1.0)
|
126
|
+
fa_5d = FlexArray.new(s5d, 1.0)
|
127
|
+
|
128
|
+
temp = 0.0
|
129
|
+
|
130
|
+
Benchmark.bmbm do |x|
|
131
|
+
|
132
|
+
x.report("Array each:") {
|
133
|
+
ct.times { array.each { |item| temp += item } }
|
134
|
+
}
|
135
|
+
|
136
|
+
x.report("Flex 1d each:") {
|
137
|
+
ct.times { fa_1d.each { |item| temp += item } }
|
138
|
+
}
|
139
|
+
|
140
|
+
x.report("Flex 2d each:") {
|
141
|
+
ct.times { fa_2d.each { |item| temp += item } }
|
142
|
+
}
|
143
|
+
|
144
|
+
x.report("Flex 3d each:") {
|
145
|
+
ct.times { fa_3d.each { |item| temp += item } }
|
146
|
+
}
|
147
|
+
|
148
|
+
x.report("Flex 4d each:") {
|
149
|
+
ct.times { fa_4d.each { |item| temp += item } }
|
150
|
+
}
|
151
|
+
|
152
|
+
x.report("Flex 5d each:") {
|
153
|
+
ct.times { fa_5d.each { |item| temp += item } }
|
154
|
+
}
|
155
|
+
|
156
|
+
|
157
|
+
x.report("Array cycle:") {
|
158
|
+
cyc = array.cycle
|
159
|
+
cyc_ct.times { temp += cyc.next }
|
160
|
+
}
|
161
|
+
|
162
|
+
x.report("Flex 1d cycle:") {
|
163
|
+
cyc = fa_1d.cycle
|
164
|
+
cyc_ct.times { temp += cyc.next }
|
165
|
+
}
|
166
|
+
|
167
|
+
x.report("Flex 2d cycle:") {
|
168
|
+
cyc = fa_2d.cycle
|
169
|
+
cyc_ct.times { temp += cyc.next }
|
170
|
+
}
|
171
|
+
|
172
|
+
x.report("Flex 3d cycle:") {
|
173
|
+
cyc = fa_3d.cycle
|
174
|
+
cyc_ct.times { temp += cyc.next }
|
175
|
+
}
|
176
|
+
|
177
|
+
x.report("Flex 4d cycle:") {
|
178
|
+
cyc = fa_4d.cycle
|
179
|
+
cyc_ct.times { temp += cyc.next }
|
180
|
+
}
|
181
|
+
|
182
|
+
x.report("Flex 5d cycle:") {
|
183
|
+
cyc = fa_5d.cycle
|
184
|
+
cyc_ct.times { temp += cyc.next }
|
185
|
+
}
|
186
|
+
|
187
|
+
|
188
|
+
x.report("Flex 1d cysel:") {
|
189
|
+
cyc = fa_1d.select_cycle(c1s)
|
190
|
+
cyc_ct.times { temp += cyc.next }
|
191
|
+
}
|
192
|
+
|
193
|
+
x.report("Flex 2d cysel:") {
|
194
|
+
cyc = fa_2d.select_cycle(c2s)
|
195
|
+
cyc_ct.times { temp += cyc.next }
|
196
|
+
}
|
197
|
+
|
198
|
+
x.report("Flex 3d cysel:") {
|
199
|
+
cyc = fa_3d.select_cycle(c3s)
|
200
|
+
cyc_ct.times { temp += cyc.next }
|
201
|
+
}
|
202
|
+
|
203
|
+
x.report("Flex 4d cysel:") {
|
204
|
+
cyc = fa_4d.select_cycle(c4s)
|
205
|
+
cyc_ct.times { temp += cyc.next }
|
206
|
+
}
|
207
|
+
|
208
|
+
x.report("Flex 5d cysel:") {
|
209
|
+
cyc = fa_5d.select_cycle(c5s)
|
210
|
+
cyc_ct.times { temp += cyc.next }
|
211
|
+
}
|
212
|
+
|
213
|
+
|
214
|
+
x.report("Array []=:") {
|
215
|
+
ct.times { sz.times { |index| array[index] = 2.0 } }
|
216
|
+
}
|
217
|
+
|
218
|
+
x.report("Flex 1d []=:") {
|
219
|
+
ct.times { fa_1d[:all] = 2.0 }
|
220
|
+
}
|
221
|
+
|
222
|
+
x.report("Flex 2d []=:") {
|
223
|
+
ct.times { fa_2d[:all] = 2.0 }
|
224
|
+
}
|
225
|
+
|
226
|
+
x.report("Flex 3d []=:") {
|
227
|
+
ct.times { fa_3d[:all] = 2.0 }
|
228
|
+
}
|
229
|
+
|
230
|
+
x.report("Flex 4d []=:") {
|
231
|
+
ct.times { fa_4d[:all] = 2.0 }
|
232
|
+
}
|
233
|
+
|
234
|
+
x.report("Flex 5d []=:") {
|
235
|
+
ct.times { fa_5d[:all] = 2.0 }
|
236
|
+
}
|
237
|
+
|
238
|
+
end
|
239
|
+
else
|
240
|
+
puts "Test disabled."
|
241
|
+
end
|
242
|
+
|
243
|
+
puts
|
data/bench/results.txt
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
Ruby version = 2.3.3
|
2
|
+
FlexArray version = 0.3.5
|
3
|
+
|
4
|
+
Creating arrays:
|
5
|
+
==============================================================================
|
6
|
+
Rehearsal -------------------------------------------------
|
7
|
+
Array obj: 0.031000 0.000000 0.031000 ( 0.029280)
|
8
|
+
Flex 1d obj: 0.032000 0.000000 0.032000 ( 0.034108)
|
9
|
+
Flex 2d obj: 0.031000 0.016000 0.047000 ( 0.042788)
|
10
|
+
Flex 3d obj: 0.031000 0.000000 0.031000 ( 0.028039)
|
11
|
+
Flex 4d obj: 0.031000 0.000000 0.031000 ( 0.029970)
|
12
|
+
Flex 5d obj: 0.016000 0.000000 0.016000 ( 0.031100)
|
13
|
+
Array blk: 1.185000 0.016000 1.201000 ( 1.249085)
|
14
|
+
Flex 1d blk: 6.334000 0.000000 6.334000 ( 6.320979)
|
15
|
+
Flex 2d blk: 6.599000 0.000000 6.599000 ( 6.629046)
|
16
|
+
Flex 3d blk: 6.801000 0.000000 6.801000 ( 6.820932)
|
17
|
+
Flex 4d blk: 8.190000 0.000000 8.190000 ( 8.182340)
|
18
|
+
Flex 5d blk: 8.269000 0.000000 8.269000 ( 8.293787)
|
19
|
+
Flex 1d from: 9.750000 0.015000 9.765000 ( 9.760498)
|
20
|
+
Flex 2d from: 9.999000 0.047000 10.046000 ( 10.037197)
|
21
|
+
Flex 3d from: 10.031000 0.047000 10.078000 ( 10.102979)
|
22
|
+
Flex 4d from: 11.607000 0.015000 11.622000 ( 11.644530)
|
23
|
+
Flex 5d from: 11.590000 0.032000 11.622000 ( 11.630430)
|
24
|
+
--------------------------------------- total: 90.715000sec
|
25
|
+
|
26
|
+
user system total real
|
27
|
+
Array obj: 0.031000 0.000000 0.031000 ( 0.028856)
|
28
|
+
Flex 1d obj: 0.047000 0.000000 0.047000 ( 0.041917)
|
29
|
+
Flex 2d obj: 0.031000 0.000000 0.031000 ( 0.035824)
|
30
|
+
Flex 3d obj: 0.016000 0.015000 0.031000 ( 0.033661)
|
31
|
+
Flex 4d obj: 0.047000 0.000000 0.047000 ( 0.040366)
|
32
|
+
Flex 5d obj: 0.031000 0.000000 0.031000 ( 0.038743)
|
33
|
+
Array blk: 1.232000 0.000000 1.232000 ( 1.242158)
|
34
|
+
Flex 1d blk: 6.381000 0.000000 6.381000 ( 6.378779)
|
35
|
+
Flex 2d blk: 6.194000 0.031000 6.225000 ( 6.481757)
|
36
|
+
Flex 3d blk: 6.630000 0.000000 6.630000 ( 6.680507)
|
37
|
+
Flex 4d blk: 8.112000 0.000000 8.112000 ( 8.115420)
|
38
|
+
Flex 5d blk: 8.237000 0.000000 8.237000 ( 8.228091)
|
39
|
+
Flex 1d from: 9.657000 0.016000 9.673000 ( 9.716532)
|
40
|
+
Flex 2d from: 9.937000 0.000000 9.937000 ( 9.999748)
|
41
|
+
Flex 3d from: 10.109000 0.015000 10.124000 ( 10.136534)
|
42
|
+
Flex 4d from: 11.809000 0.016000 11.825000 ( 11.878319)
|
43
|
+
Flex 5d from: 11.685000 0.047000 11.732000 ( 11.723940)
|
44
|
+
|
45
|
+
Accessing arrays:
|
46
|
+
==============================================================================
|
47
|
+
Rehearsal --------------------------------------------------
|
48
|
+
Array each: 1.045000 0.000000 1.045000 ( 1.049537)
|
49
|
+
Flex 1d each: 1.076000 0.000000 1.076000 ( 1.075475)
|
50
|
+
Flex 2d each: 1.092000 0.000000 1.092000 ( 1.086814)
|
51
|
+
Flex 3d each: 1.092000 0.000000 1.092000 ( 1.096500)
|
52
|
+
Flex 4d each: 1.077000 0.000000 1.077000 ( 1.081033)
|
53
|
+
Flex 5d each: 1.092000 0.000000 1.092000 ( 1.084849)
|
54
|
+
Array cycle: 4.337000 0.000000 4.337000 ( 4.344979)
|
55
|
+
Flex 1d cycle: 4.383000 0.000000 4.383000 ( 4.375415)
|
56
|
+
Flex 2d cycle: 4.353000 0.000000 4.353000 ( 4.351397)
|
57
|
+
Flex 3d cycle: 4.305000 0.000000 4.305000 ( 4.297517)
|
58
|
+
Flex 4d cycle: 4.321000 0.000000 4.321000 ( 4.337608)
|
59
|
+
Flex 5d cycle: 4.400000 0.000000 4.400000 ( 4.412436)
|
60
|
+
Flex 1d cysel: 10.265000 0.000000 10.265000 ( 10.272564)
|
61
|
+
Flex 2d cysel: 10.342000 0.031000 10.373000 ( 10.403735)
|
62
|
+
Flex 3d cysel: 10.359000 0.062000 10.421000 ( 10.445309)
|
63
|
+
Flex 4d cysel: 11.482000 0.016000 11.498000 ( 11.535809)
|
64
|
+
Flex 5d cysel: 12.230000 0.140000 12.370000 ( 12.388114)
|
65
|
+
Array []=: 0.983000 0.000000 0.983000 ( 0.974042)
|
66
|
+
Flex 1d []=: 8.486000 0.000000 8.486000 ( 8.487866)
|
67
|
+
Flex 2d []=: 8.705000 0.047000 8.752000 ( 8.779844)
|
68
|
+
Flex 3d []=: 8.923000 0.031000 8.954000 ( 8.971719)
|
69
|
+
Flex 4d []=: 10.281000 0.047000 10.328000 ( 10.338109)
|
70
|
+
Flex 5d []=: 10.296000 0.016000 10.312000 ( 10.406798)
|
71
|
+
--------------------------------------- total: 135.315000sec
|
72
|
+
|
73
|
+
user system total real
|
74
|
+
Array each: 1.030000 0.000000 1.030000 ( 1.037024)
|
75
|
+
Flex 1d each: 1.076000 0.000000 1.076000 ( 1.068122)
|
76
|
+
Flex 2d each: 1.061000 0.000000 1.061000 ( 1.068019)
|
77
|
+
Flex 3d each: 1.092000 0.000000 1.092000 ( 1.073313)
|
78
|
+
Flex 4d each: 1.076000 0.000000 1.076000 ( 1.078664)
|
79
|
+
Flex 5d each: 1.077000 0.000000 1.077000 ( 1.073763)
|
80
|
+
Array cycle: 4.336000 0.000000 4.336000 ( 4.343807)
|
81
|
+
Flex 1d cycle: 4.275000 0.000000 4.275000 ( 4.289805)
|
82
|
+
Flex 2d cycle: 4.227000 0.000000 4.227000 ( 4.248021)
|
83
|
+
Flex 3d cycle: 4.197000 0.000000 4.197000 ( 4.219823)
|
84
|
+
Flex 4d cycle: 4.228000 0.000000 4.228000 ( 4.256224)
|
85
|
+
Flex 5d cycle: 4.196000 0.015000 4.211000 ( 4.273239)
|
86
|
+
Flex 1d cysel: 9.890000 0.016000 9.906000 ( 9.940829)
|
87
|
+
Flex 2d cysel: 10.094000 0.015000 10.109000 ( 10.105926)
|
88
|
+
Flex 3d cysel: 10.202000 0.063000 10.265000 ( 10.352745)
|
89
|
+
Flex 4d cysel: 11.404000 0.062000 11.466000 ( 11.462466)
|
90
|
+
Flex 5d cysel: 11.653000 0.141000 11.794000 ( 11.784468)
|
91
|
+
Array []=: 0.967000 0.000000 0.967000 ( 0.963400)
|
92
|
+
Flex 1d []=: 8.471000 0.031000 8.502000 ( 8.527261)
|
93
|
+
Flex 2d []=: 8.752000 0.000000 8.752000 ( 8.757735)
|
94
|
+
Flex 3d []=: 8.892000 0.015000 8.907000 ( 9.115369)
|
95
|
+
Flex 4d []=: 10.234000 0.016000 10.250000 ( 10.635380)
|
96
|
+
Flex 5d []=: 10.374000 0.062000 10.436000 ( 15.463252)
|
97
|
+
|
data/flex_array.gemspec
CHANGED
@@ -13,25 +13,21 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.version = FlexArray::VERSION
|
14
14
|
s.author = ["Peter Camilleri"]
|
15
15
|
s.email = "peter.c.camilleri@gmail.com"
|
16
|
-
s.homepage = "
|
16
|
+
s.homepage = "https://github.com/PeterCamilleri/flex_array"
|
17
17
|
s.platform = Gem::Platform::RUBY
|
18
18
|
s.required_ruby_version = '>=1.9.3'
|
19
19
|
|
20
20
|
s.add_development_dependency "bundler", "~> 1.3"
|
21
|
-
s.add_development_dependency 'rake'
|
22
|
-
s.add_development_dependency 'reek', "~>
|
21
|
+
s.add_development_dependency 'rake', ">= 12.3.3"
|
22
|
+
s.add_development_dependency 'reek', "~> 5.0.2"
|
23
23
|
s.add_development_dependency 'minitest', "~> 4.7.5"
|
24
|
-
s.add_development_dependency 'rdoc', "~> 4.0.1"
|
25
|
-
s.add_development_dependency 'minitest_visible', ">= 0.1.0"
|
26
24
|
|
27
25
|
s.add_runtime_dependency 'in_array'
|
28
26
|
|
29
|
-
s.files = `git ls-files`.split($/)
|
30
|
-
s.
|
31
|
-
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
27
|
+
s.files = `git ls-files`.split($/).select {|f| f !~ /^docs\//}
|
28
|
+
s.test_files = s.files.grep(%r{^(test)/})
|
32
29
|
|
33
30
|
s.license = 'MIT'
|
34
|
-
s.has_rdoc = true
|
35
31
|
s.require_paths = ["lib"]
|
36
32
|
end
|
37
33
|
|
data/lib/flex_array.rb
CHANGED
@@ -19,79 +19,62 @@ require_relative 'flex_array/flex_array_each'
|
|
19
19
|
require_relative 'flex_array/flex_array_validate'
|
20
20
|
require_relative 'flex_array/flex_array_process'
|
21
21
|
|
22
|
-
|
23
|
-
#* flex_array.rb - The root file that gathers up all the flex array parts.
|
22
|
+
# A flexible array class.
|
24
23
|
class FlexArray
|
25
24
|
include InArrayAlready
|
26
25
|
|
27
|
-
#The version of this class.
|
28
|
-
#<br>Returns
|
29
|
-
#* A version string; <major>.<minor>.<step>
|
26
|
+
# The version of this class. "<major>.<minor>.<step>"
|
30
27
|
def self.version
|
31
28
|
FlexArray::VERSION
|
32
29
|
end
|
33
30
|
|
34
|
-
#The version of the class of this instance.
|
35
|
-
#<br>Returns
|
36
|
-
#* A version string; <major>.<minor>.<step>
|
31
|
+
# The version of the class of this instance.
|
37
32
|
def version
|
38
33
|
FlexArray::VERSION
|
39
34
|
end
|
40
35
|
|
41
|
-
#The array specifications. An array of spec components.
|
36
|
+
# The array specifications. An array of spec components.
|
42
37
|
attr_accessor :array_specs
|
43
38
|
|
44
|
-
#The underlying array data used by the flex array.
|
39
|
+
# The underlying array data used by the flex array.
|
45
40
|
attr_accessor :array_data
|
46
41
|
|
47
|
-
#The total number of elements in this array.
|
42
|
+
# The total number of elements in this array.
|
48
43
|
def length
|
49
44
|
@array_specs.spec_count
|
50
45
|
end
|
51
46
|
|
52
47
|
alias size length
|
53
48
|
|
54
|
-
#The number of dimensions in this array.
|
49
|
+
# The number of dimensions in this array.
|
55
50
|
def dimensions
|
56
51
|
@array_specs.spec_dimensions
|
57
52
|
end
|
58
53
|
|
59
|
-
#Is this flex array transposed?
|
54
|
+
# Is this flex array transposed?
|
60
55
|
attr_reader :transposed
|
61
56
|
|
62
|
-
#Get the limits of the subscripts of the flex array.
|
57
|
+
# Get the limits of the subscripts of the flex array.
|
63
58
|
def limits
|
64
59
|
@array_specs.collect {|spec| spec.range }
|
65
60
|
end
|
66
61
|
|
67
|
-
#Return this flex array as a flex array!
|
68
|
-
#<br>Returns
|
69
|
-
#* A flex array -- self
|
62
|
+
# Return this flex array as a flex array!
|
70
63
|
def to_flex_array
|
71
64
|
self
|
72
65
|
end
|
73
66
|
|
74
|
-
#Are these FlexArrays equal?
|
75
|
-
#<br>Parameters
|
76
|
-
#* other - The object being tested for equality.
|
77
|
-
#<br>Returns
|
78
|
-
#* true if the flex arrays are equal shape and data.
|
67
|
+
# Are these FlexArrays equal?
|
79
68
|
def ==(other)
|
80
69
|
self.compatible?(other) && @array_data == other.array_data
|
81
70
|
end
|
82
71
|
|
83
|
-
#Make FlexArrays comparable.
|
84
|
-
#<br>Parameters
|
85
|
-
#* other - The object being tested for compariositality.
|
86
|
-
#<br>Returns
|
87
|
-
#* 1 if self > other
|
88
|
-
#* 0 if self = other
|
89
|
-
#* -1 if self < other
|
72
|
+
# Make FlexArrays comparable with the compariositality method.
|
90
73
|
def <=>(other)
|
91
74
|
@array_data <=> other.array_data
|
92
75
|
end
|
93
76
|
|
94
|
-
#Is this flex array empty?
|
77
|
+
# Is this flex array empty?
|
95
78
|
def empty?
|
96
79
|
length == 0
|
97
80
|
end
|