daru_lite 0.3.4 → 0.4.0

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.
Files changed (161) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +84 -0
  3. data/README.md +16 -1
  4. data/lib/daru_lite/category.rb +1 -1
  5. data/lib/daru_lite/core/group_by.rb +0 -4
  6. data/lib/daru_lite/core/merge.rb +2 -2
  7. data/lib/daru_lite/data_frame/calculatable.rb +12 -6
  8. data/lib/daru_lite/data_frame/duplicatable.rb +0 -14
  9. data/lib/daru_lite/data_frame/iterable.rb +2 -2
  10. data/lib/daru_lite/data_frame/missable.rb +0 -9
  11. data/lib/daru_lite/dataframe.rb +34 -9
  12. data/lib/daru_lite/date_time/index.rb +4 -4
  13. data/lib/daru_lite/index/multi_index.rb +1 -2
  14. data/lib/daru_lite/maths/statistics/dataframe.rb +2 -4
  15. data/lib/daru_lite/maths/statistics/vector.rb +3 -8
  16. data/lib/daru_lite/monkeys/array.rb +4 -0
  17. data/lib/daru_lite/monkeys/hash.rb +3 -0
  18. data/lib/daru_lite/monkeys/matrix.rb +3 -0
  19. data/lib/daru_lite/monkeys/range.rb +4 -0
  20. data/lib/daru_lite/vector/missable.rb +0 -55
  21. data/lib/daru_lite/vector/sortable.rb +2 -2
  22. data/lib/daru_lite/vector.rb +3 -9
  23. data/lib/daru_lite/version.rb +1 -1
  24. data/lib/daru_lite.rb +8 -10
  25. metadata +54 -287
  26. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  27. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  28. data/.github/dependabot.yml +0 -11
  29. data/.github/workflows/ci.yml +0 -33
  30. data/.gitignore +0 -10
  31. data/.rspec +0 -2
  32. data/.rubocop.yml +0 -27
  33. data/.rubocop_todo.yml +0 -139
  34. data/CONTRIBUTING.md +0 -47
  35. data/Gemfile +0 -2
  36. data/Rakefile +0 -69
  37. data/ReleasePolicy.md +0 -20
  38. data/benchmarks/TradeoffData.csv +0 -65
  39. data/benchmarks/csv_reading.rb +0 -22
  40. data/benchmarks/dataframe_creation.rb +0 -39
  41. data/benchmarks/db_loading.rb +0 -33
  42. data/benchmarks/duplicating.rb +0 -45
  43. data/benchmarks/group_by.rb +0 -32
  44. data/benchmarks/joining.rb +0 -52
  45. data/benchmarks/row_access.rb +0 -41
  46. data/benchmarks/row_assign.rb +0 -36
  47. data/benchmarks/sorting.rb +0 -51
  48. data/benchmarks/statistics.rb +0 -28
  49. data/benchmarks/vector_access.rb +0 -31
  50. data/benchmarks/vector_assign.rb +0 -42
  51. data/benchmarks/where_clause.rb +0 -48
  52. data/benchmarks/where_vs_filter.rb +0 -28
  53. data/daru_lite.gemspec +0 -54
  54. data/daru_lite_test-shm +0 -0
  55. data/daru_lite_test-wal +0 -0
  56. data/images/README.md +0 -5
  57. data/images/con0.png +0 -0
  58. data/images/con1.png +0 -0
  59. data/images/init0.png +0 -0
  60. data/images/init1.png +0 -0
  61. data/images/man0.png +0 -0
  62. data/images/man1.png +0 -0
  63. data/images/man2.png +0 -0
  64. data/images/man3.png +0 -0
  65. data/images/man4.png +0 -0
  66. data/images/man5.png +0 -0
  67. data/images/man6.png +0 -0
  68. data/lib/daru_lite/accessors/mdarray_wrapper.rb +0 -7
  69. data/lib/daru_lite/monkeys/m_d_array.rb +0 -7
  70. data/lib/daru_lite/monkeys/object.rb +0 -7
  71. data/profile/_base.rb +0 -23
  72. data/profile/df_to_a.rb +0 -10
  73. data/profile/filter.rb +0 -13
  74. data/profile/joining.rb +0 -13
  75. data/profile/sorting.rb +0 -12
  76. data/profile/vector_each_with_index.rb +0 -9
  77. data/profile/vector_new.rb +0 -9
  78. data/spec/accessors/array_wrapper_spec.rb +0 -3
  79. data/spec/category_spec.rb +0 -1767
  80. data/spec/core/group_by_spec.rb +0 -655
  81. data/spec/core/merge_spec.rb +0 -179
  82. data/spec/core/query_spec.rb +0 -347
  83. data/spec/daru_lite_spec.rb +0 -22
  84. data/spec/data_frame/aggregatable_example.rb +0 -65
  85. data/spec/data_frame/buildable_example.rb +0 -109
  86. data/spec/data_frame/calculatable_example.rb +0 -135
  87. data/spec/data_frame/convertible_example.rb +0 -180
  88. data/spec/data_frame/duplicatable_example.rb +0 -134
  89. data/spec/data_frame/fetchable_example.rb +0 -510
  90. data/spec/data_frame/filterable_example.rb +0 -456
  91. data/spec/data_frame/indexable_example.rb +0 -221
  92. data/spec/data_frame/iterable_example.rb +0 -481
  93. data/spec/data_frame/joinable_example.rb +0 -131
  94. data/spec/data_frame/missable_example.rb +0 -47
  95. data/spec/data_frame/pivotable_example.rb +0 -297
  96. data/spec/data_frame/queryable_example.rb +0 -92
  97. data/spec/data_frame/setable_example.rb +0 -513
  98. data/spec/data_frame/sortable_example.rb +0 -368
  99. data/spec/dataframe_spec.rb +0 -1342
  100. data/spec/date_time/data_spec.rb +0 -197
  101. data/spec/date_time/date_time_index_helper_spec.rb +0 -72
  102. data/spec/date_time/index_spec.rb +0 -588
  103. data/spec/date_time/offsets_spec.rb +0 -465
  104. data/spec/extensions/which_dsl_spec.rb +0 -38
  105. data/spec/fixtures/bank2.dat +0 -200
  106. data/spec/fixtures/boolean_converter_test.csv +0 -5
  107. data/spec/fixtures/countries.json +0 -7794
  108. data/spec/fixtures/duplicates.csv +0 -32
  109. data/spec/fixtures/eciresults.html +0 -394
  110. data/spec/fixtures/empties.dat +0 -2
  111. data/spec/fixtures/empty_rows_test.csv +0 -17
  112. data/spec/fixtures/macau.html +0 -3691
  113. data/spec/fixtures/macd_data.csv +0 -150
  114. data/spec/fixtures/matrix_test.csv +0 -100
  115. data/spec/fixtures/moneycontrol.html +0 -6812
  116. data/spec/fixtures/music_data.tsv +0 -2501
  117. data/spec/fixtures/repeated_fields.csv +0 -7
  118. data/spec/fixtures/sales-funnel.csv +0 -18
  119. data/spec/fixtures/scientific_notation.csv +0 -4
  120. data/spec/fixtures/string_converter_test.csv +0 -5
  121. data/spec/fixtures/strings.dat +0 -2
  122. data/spec/fixtures/test_xls.xls +0 -0
  123. data/spec/fixtures/test_xls_2.xls +0 -0
  124. data/spec/fixtures/url_test.txt~ +0 -0
  125. data/spec/fixtures/valid_markup.html +0 -62
  126. data/spec/fixtures/wiki_climate.html +0 -1243
  127. data/spec/fixtures/wiki_table_info.html +0 -631
  128. data/spec/formatters/table_formatter_spec.rb +0 -137
  129. data/spec/helpers_spec.rb +0 -8
  130. data/spec/index/categorical_index_spec.rb +0 -289
  131. data/spec/index/index_spec.rb +0 -438
  132. data/spec/index/multi_index_spec.rb +0 -752
  133. data/spec/io/io_spec.rb +0 -357
  134. data/spec/io/sql_data_source_spec.rb +0 -48
  135. data/spec/iruby/dataframe_spec.rb +0 -170
  136. data/spec/iruby/helpers_spec.rb +0 -49
  137. data/spec/iruby/multi_index_spec.rb +0 -37
  138. data/spec/iruby/vector_spec.rb +0 -105
  139. data/spec/maths/arithmetic/dataframe_spec.rb +0 -148
  140. data/spec/maths/arithmetic/vector_spec.rb +0 -165
  141. data/spec/maths/statistics/dataframe_spec.rb +0 -191
  142. data/spec/maths/statistics/vector_spec.rb +0 -756
  143. data/spec/monkeys_spec.rb +0 -42
  144. data/spec/shared/vector_display_spec.rb +0 -213
  145. data/spec/spec_helper.rb +0 -87
  146. data/spec/support/database_helper.rb +0 -29
  147. data/spec/support/matchers.rb +0 -5
  148. data/spec/vector/aggregatable_example.rb +0 -27
  149. data/spec/vector/calculatable_example.rb +0 -82
  150. data/spec/vector/convertible_example.rb +0 -126
  151. data/spec/vector/duplicatable_example.rb +0 -48
  152. data/spec/vector/fetchable_example.rb +0 -463
  153. data/spec/vector/filterable_example.rb +0 -165
  154. data/spec/vector/indexable_example.rb +0 -201
  155. data/spec/vector/iterable_example.rb +0 -111
  156. data/spec/vector/joinable_example.rb +0 -25
  157. data/spec/vector/missable_example.rb +0 -88
  158. data/spec/vector/queryable_example.rb +0 -91
  159. data/spec/vector/setable_example.rb +0 -300
  160. data/spec/vector/sortable_example.rb +0 -242
  161. data/spec/vector_spec.rb +0 -599
@@ -1,137 +0,0 @@
1
- describe DaruLite::Formatters::Table do
2
- let(:options) { {} }
3
- subject {
4
- DaruLite::Formatters::Table
5
- .format(data, options.merge(headers: headers, row_headers: row_headers))
6
- }
7
-
8
- let(:data) { [[1,2,3], [4,5,6], [7,8,9]] }
9
- let(:headers) { [:col1, :col2, :col3] }
10
- let(:row_headers) { [:row1, :row2, :row3] }
11
-
12
- context 'simple table' do
13
- it { is_expected.to eq %Q{
14
- | col1 col2 col3
15
- | row1 1 2 3
16
- | row2 4 5 6
17
- | row3 7 8 9
18
- }.unindent}
19
- end
20
-
21
- context 'with nils' do
22
- let(:data) { [[1,nil,3], [4,5,nil], [7,8,9]] }
23
- let(:headers) { [:col1, :col2, nil] }
24
- let(:row_headers) { [:row1, nil, :row3] }
25
-
26
- it { is_expected.to eq %Q{
27
- | col1 col2 |
28
- | row1 1 nil 3|
29
- | 4 5 nil|
30
- | row3 7 8 9|
31
- }.unindent}
32
- end
33
-
34
- context 'with multivalue row headers' do
35
- let(:row_headers) { [[:row,1], [:row,2], [:row,3]] }
36
- it { is_expected.to eq %Q{
37
- | col1 col2 col3
38
- | row 1 1 2 3
39
- | row 2 4 5 6
40
- | row 3 7 8 9
41
- }.unindent}
42
- end
43
-
44
- context 'with multivalue column headers' do
45
- let(:headers) { [[:col,1], [:col,2], [:col,3]] }
46
- end
47
-
48
- context 'rows only' do
49
- let(:data) { [] }
50
- let(:headers) { nil }
51
- it { is_expected.to eq %Q{
52
- | row1
53
- | row2
54
- | row3
55
- }.unindent}
56
- end
57
-
58
- context 'columns only' do
59
- let(:data) { [] }
60
- let(:row_headers) { nil }
61
- it { is_expected.to eq %Q{
62
- | col1 col2 col3
63
- }.unindent}
64
- end
65
-
66
- context 'wide values' do
67
- let(:options) { {spacing: 2} }
68
-
69
- it { is_expected.to eq %Q{
70
- | co co co
71
- | ro 1 2 3
72
- | ro 4 5 6
73
- | ro 7 8 9
74
- }.unindent}
75
- end
76
-
77
- context 'with empty data' do
78
- let(:data) { [] }
79
- let(:headers) { [] }
80
- let(:row_headers) { [] }
81
-
82
- it { is_expected.to eq '' }
83
- end
84
-
85
-
86
- context '<more> threshold' do
87
- let(:options) { {threshold: threshold} }
88
- context 'lower than data size' do
89
- let(:threshold) { 2 }
90
- it { is_expected.to eq %Q{
91
- | col1 col2 col3
92
- | row1 1 2 3
93
- | row2 4 5 6
94
- | ... ... ... ...
95
- }.unindent}
96
- end
97
-
98
- context 'greater than data size' do
99
- let(:threshold) { 5 }
100
- it { is_expected.to eq %Q{
101
- | col1 col2 col3
102
- | row1 1 2 3
103
- | row2 4 5 6
104
- | row3 7 8 9
105
- }.unindent}
106
- end
107
- end
108
-
109
- context 'no row and column headers' do
110
- let(:headers) { nil }
111
- let(:row_headers) { nil }
112
- it { is_expected.to eq %Q{
113
- | 1 2 3
114
- | 4 5 6
115
- | 7 8 9
116
- }.unindent }
117
- end
118
-
119
- context 'row headers only' do
120
- let(:headers) { nil }
121
- it { is_expected.to eq %Q{
122
- | row1 1 2 3
123
- | row2 4 5 6
124
- | row3 7 8 9
125
- }.unindent }
126
- end
127
-
128
- context 'column headers only' do
129
- let(:row_headers) { nil }
130
- it { is_expected.to eq %Q{
131
- | col1 col2 col3
132
- | 1 2 3
133
- | 4 5 6
134
- | 7 8 9
135
- }.unindent }
136
- end
137
- end
data/spec/helpers_spec.rb DELETED
@@ -1,8 +0,0 @@
1
- describe DaruLite::ArrayHelper do
2
- context '#recode_repeated' do
3
- let(:source) { [1,'a',1,'a','b',:c,2] }
4
- subject { described_class.recode_repeated(source) }
5
-
6
- it { is_expected.to eq ['1_1','a_1', '1_2','a_2','b',:c,2] }
7
- end
8
- end
@@ -1,289 +0,0 @@
1
- require 'spec_helper.rb'
2
-
3
- describe DaruLite::CategoricalIndex do
4
- let(:index) { described_class.new(keys) }
5
- let(:keys) { [:a, :b, :a, :a, :c] }
6
-
7
- describe "#to_a" do
8
- subject { index.to_a }
9
-
10
- it { is_expected.to eq(keys) }
11
-
12
- it 'the returns array is not a variable of the index' do
13
- expect { subject << 'four' }.not_to change { index.to_a }
14
- end
15
- end
16
-
17
- context "#pos" do
18
- context "when the category is non-numeric" do
19
- context "single category" do
20
- subject { index.pos :a }
21
-
22
- it { is_expected.to eq [0, 2, 3] }
23
- end
24
-
25
- context "multiple categories" do
26
- subject { index.pos :a, :c }
27
-
28
- it { is_expected.to eq [0, 2, 3, 4] }
29
- end
30
-
31
- context "invalid category" do
32
- it { expect { index.pos :e }.to raise_error IndexError }
33
- end
34
-
35
- context "label range argument" do
36
- it { expect { index.pos :a..:c }.to raise_error ArgumentError }
37
- end
38
-
39
- context "positional (integer) range argument" do
40
- it { expect(index.pos(0..2)).to eq [0, 1, 2] }
41
-
42
- context "when the range extends past the end" do
43
- it { expect(index.pos(0..99)).to eq [0, 1, 2, 3, 4] }
44
- end
45
- end
46
-
47
- context "when a category is itself a Range" do
48
- let(:index) { described_class.new [(1..2), (3..4), (1..2)] }
49
-
50
- it { expect(index.pos(1..2)).to eq [0, 2] }
51
- end
52
-
53
- context "positional index" do
54
- it { expect(index.pos 0).to eq 0 }
55
- end
56
-
57
- context "invalid positional index" do
58
- it { expect { index.pos 5 }.to raise_error IndexError }
59
- end
60
-
61
- context "multiple positional indexes" do
62
- subject { index.pos 0, 1, 2 }
63
-
64
- it { is_expected.to be_a Array }
65
- its(:size) { is_expected.to eq 3 }
66
- it { is_expected.to eq [0, 1, 2] }
67
- end
68
- end
69
-
70
- context "when the category is numeric" do
71
- let(:idx) { described_class.new [0, 1, 0, 0, 2] }
72
-
73
- context "first preference to category" do
74
- subject { idx.pos 0 }
75
-
76
- it { is_expected.to be_a Array }
77
- its(:size) { is_expected.to eq 3 }
78
- it { is_expected.to eq [0, 2, 3] }
79
- end
80
-
81
- context "second preference to positional index" do
82
- subject { idx.pos 3 }
83
-
84
- it { is_expected.to eq 3 }
85
- end
86
- end
87
- end
88
-
89
- describe "#[]" do
90
- context "when the category occurs once" do
91
- subject { index[:b] }
92
-
93
- it { is_expected.to eq 1 }
94
- end
95
-
96
- context "when the category occurs multiple times" do
97
- subject { index[:a] }
98
-
99
- it { is_expected.to eq [0, 2, 3] }
100
- end
101
-
102
- context "when given a positional index" do
103
- subject { index[0] }
104
-
105
- it { is_expected.to eq 0 }
106
- end
107
-
108
- context "when given multiple categories" do
109
- subject { index[:a, :c] }
110
-
111
- it { is_expected.to eq [0, 2, 3, 4] }
112
- end
113
-
114
- context "when the category is absent" do
115
- subject { index[:z] }
116
-
117
- it { is_expected.to be_nil }
118
- end
119
-
120
- context "when given a label range" do
121
- it { expect { index[:a..:c] }.to raise_error ArgumentError }
122
- end
123
-
124
- context "when given a positional (integer) range" do
125
- subject { index[0..2] }
126
-
127
- it { is_expected.to eq [0, 1, 2] }
128
- end
129
-
130
- context "when a category is itself a Range" do
131
- let(:index) { described_class.new [(1..2), (3..4), (1..2)] }
132
-
133
- it { expect(index[1..2]).to eq [0, 2] }
134
- end
135
- end
136
-
137
- describe "#key" do
138
- context "when given a position" do
139
- subject { index.key(1) }
140
-
141
- it { is_expected.to eq :b }
142
- end
143
-
144
- context "when the position holds a duplicated category" do
145
- subject { index.key(3) }
146
-
147
- it { is_expected.to eq :a }
148
- end
149
-
150
- context "when the position is out of range" do
151
- subject { index.key(99) }
152
-
153
- it { is_expected.to be_nil }
154
- end
155
-
156
- context "when given a non-numeric value" do
157
- subject { index.key(:a) }
158
-
159
- it { is_expected.to be_nil }
160
- end
161
- end
162
-
163
- describe "#slice" do
164
- it { expect { index.slice(:a, :c) }.to raise_error ArgumentError }
165
- end
166
-
167
- describe "#subset_slice" do
168
- it { expect { index.subset_slice(:a, :c) }.to raise_error ArgumentError }
169
- end
170
-
171
- context "#subset" do
172
- let(:idx) { described_class.new [:a, 1, :a, 1, :c] }
173
-
174
- context "single index" do
175
- context "multiple instances" do
176
- subject { idx.subset :a }
177
-
178
- it { is_expected.to be_a described_class }
179
- its(:size) { is_expected.to eq 2 }
180
- its(:to_a) { is_expected.to eq [:a, :a] }
181
- end
182
- end
183
-
184
- context "multiple indexes" do
185
- subject { idx.subset :a, 1 }
186
-
187
- it { is_expected.to be_a described_class }
188
- its(:size) { is_expected.to eq 4 }
189
- its(:to_a) { is_expected.to eq [:a, 1, :a, 1] }
190
- end
191
-
192
- context "multiple positional indexes" do
193
- subject { idx.subset 0, 2 }
194
-
195
- it { is_expected.to be_a described_class }
196
- its(:size) { is_expected.to eq 2 }
197
- its(:to_a) { is_expected.to eq [:a, :a] }
198
- end
199
- end
200
-
201
- context "#at" do
202
- let(:idx) { described_class.new [:a, :a, :a, 1, :c] }
203
-
204
- context "single position" do
205
- it { expect(idx.at 1).to eq :a }
206
- end
207
-
208
- context "multiple positions" do
209
- subject { idx.at 0, 2, 3 }
210
-
211
- it { is_expected.to be_a described_class }
212
- its(:size) { is_expected.to eq 3 }
213
- its(:to_a) { is_expected.to eq [:a, :a, 1] }
214
- end
215
-
216
- context "range" do
217
- subject { idx.at 2..3 }
218
-
219
- it { is_expected.to be_a described_class }
220
- its(:size) { is_expected.to eq 2 }
221
- its(:to_a) { is_expected.to eq [:a, 1] }
222
- end
223
-
224
- context "range with negative integers" do
225
- subject { idx.at 2..-2 }
226
-
227
- it { is_expected.to be_a described_class }
228
- its(:size) { is_expected.to eq 2 }
229
- its(:to_a) { is_expected.to eq [:a, 1] }
230
- end
231
-
232
- context "rangle with single element" do
233
- subject { idx.at 2..2 }
234
-
235
- it { is_expected.to be_a described_class }
236
- its(:size) { is_expected.to eq 1 }
237
- its(:to_a) { is_expected.to eq [:a] }
238
- end
239
-
240
- context "invalid position" do
241
- it { expect { idx.at 5 }.to raise_error IndexError }
242
- end
243
-
244
- context "invalid positions" do
245
- it { expect { idx.at 2, 5 }.to raise_error IndexError }
246
- end
247
- end
248
-
249
- context "#add" do
250
- let(:idx) { described_class.new [:a, 1, :a, 1] }
251
-
252
- context "single index" do
253
- subject { idx.add :c }
254
-
255
- its(:to_a) { is_expected.to eq [:a, 1, :a, 1, :c] }
256
- its(:categories) { is_expected.to eq [:a, 1, :c] }
257
- end
258
-
259
- context "multiple indexes" do
260
- subject { idx.add :c, :d }
261
-
262
- its(:to_a) { is_expected.to eq [:a, 1, :a, 1, :c, :d] }
263
- its(:categories) { is_expected.to eq [:a, 1, :c, :d] }
264
- end
265
- end
266
-
267
- context "#valid?" do
268
- let(:idx) { described_class.new [:a, 1, :a, 1] }
269
-
270
- context "single index" do
271
- it { expect(idx.valid? :a).to eq true }
272
- it { expect(idx.valid? 2).to eq true }
273
- it { expect(idx.valid? 4).to eq false }
274
- end
275
-
276
- context "multiple indexes" do
277
- it { expect(idx.valid? :a, 1).to eq true }
278
- it { expect(idx.valid? :a, 1, 5).to eq false }
279
- end
280
- end
281
-
282
- describe '#delete_at' do
283
- subject { index.delete_at(3) }
284
-
285
- let(:index) { described_class.new([:a, 1, :a, 1, 'c']) }
286
-
287
- it { is_expected.to eq(described_class.new([:a, 1, :a, 'c'])) }
288
- end
289
- end