daru_lite 0.3.3 → 0.3.5

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 (150) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +60 -0
  3. data/README.md +1 -1
  4. data/lib/daru_lite/category.rb +1 -1
  5. data/lib/daru_lite/data_frame/duplicatable.rb +7 -1
  6. data/lib/daru_lite/data_frame/fetchable.rb +1 -1
  7. data/lib/daru_lite/data_frame/iterable.rb +5 -2
  8. data/lib/daru_lite/data_frame/sortable.rb +13 -5
  9. data/lib/daru_lite/dataframe.rb +52 -11
  10. data/lib/daru_lite/date_time/index.rb +2 -2
  11. data/lib/daru_lite/index/categorical_index.rb +62 -0
  12. data/lib/daru_lite/index/multi_index.rb +24 -6
  13. data/lib/daru_lite/maths/statistics/dataframe.rb +9 -5
  14. data/lib/daru_lite/maths/statistics/vector.rb +1 -1
  15. data/lib/daru_lite/version.rb +1 -1
  16. data/lib/daru_lite.rb +1 -0
  17. metadata +54 -284
  18. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  19. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  20. data/.github/dependabot.yml +0 -11
  21. data/.github/workflows/ci.yml +0 -33
  22. data/.gitignore +0 -10
  23. data/.rspec +0 -2
  24. data/.rubocop.yml +0 -27
  25. data/.rubocop_todo.yml +0 -139
  26. data/CONTRIBUTING.md +0 -47
  27. data/Gemfile +0 -2
  28. data/Rakefile +0 -69
  29. data/ReleasePolicy.md +0 -20
  30. data/benchmarks/TradeoffData.csv +0 -65
  31. data/benchmarks/csv_reading.rb +0 -22
  32. data/benchmarks/dataframe_creation.rb +0 -39
  33. data/benchmarks/db_loading.rb +0 -33
  34. data/benchmarks/duplicating.rb +0 -45
  35. data/benchmarks/group_by.rb +0 -32
  36. data/benchmarks/joining.rb +0 -52
  37. data/benchmarks/row_access.rb +0 -41
  38. data/benchmarks/row_assign.rb +0 -36
  39. data/benchmarks/sorting.rb +0 -51
  40. data/benchmarks/statistics.rb +0 -28
  41. data/benchmarks/vector_access.rb +0 -31
  42. data/benchmarks/vector_assign.rb +0 -42
  43. data/benchmarks/where_clause.rb +0 -48
  44. data/benchmarks/where_vs_filter.rb +0 -28
  45. data/daru_lite.gemspec +0 -54
  46. data/daru_lite_test-shm +0 -0
  47. data/daru_lite_test-wal +0 -0
  48. data/images/README.md +0 -5
  49. data/images/con0.png +0 -0
  50. data/images/con1.png +0 -0
  51. data/images/init0.png +0 -0
  52. data/images/init1.png +0 -0
  53. data/images/man0.png +0 -0
  54. data/images/man1.png +0 -0
  55. data/images/man2.png +0 -0
  56. data/images/man3.png +0 -0
  57. data/images/man4.png +0 -0
  58. data/images/man5.png +0 -0
  59. data/images/man6.png +0 -0
  60. data/profile/_base.rb +0 -23
  61. data/profile/df_to_a.rb +0 -10
  62. data/profile/filter.rb +0 -13
  63. data/profile/joining.rb +0 -13
  64. data/profile/sorting.rb +0 -12
  65. data/profile/vector_each_with_index.rb +0 -9
  66. data/profile/vector_new.rb +0 -9
  67. data/spec/accessors/array_wrapper_spec.rb +0 -3
  68. data/spec/category_spec.rb +0 -1741
  69. data/spec/core/group_by_spec.rb +0 -655
  70. data/spec/core/merge_spec.rb +0 -179
  71. data/spec/core/query_spec.rb +0 -347
  72. data/spec/daru_lite_spec.rb +0 -22
  73. data/spec/data_frame/aggregatable_example.rb +0 -65
  74. data/spec/data_frame/buildable_example.rb +0 -109
  75. data/spec/data_frame/calculatable_example.rb +0 -135
  76. data/spec/data_frame/convertible_example.rb +0 -180
  77. data/spec/data_frame/duplicatable_example.rb +0 -111
  78. data/spec/data_frame/fetchable_example.rb +0 -481
  79. data/spec/data_frame/filterable_example.rb +0 -456
  80. data/spec/data_frame/indexable_example.rb +0 -221
  81. data/spec/data_frame/iterable_example.rb +0 -465
  82. data/spec/data_frame/joinable_example.rb +0 -131
  83. data/spec/data_frame/missable_example.rb +0 -47
  84. data/spec/data_frame/pivotable_example.rb +0 -297
  85. data/spec/data_frame/queryable_example.rb +0 -92
  86. data/spec/data_frame/setable_example.rb +0 -482
  87. data/spec/data_frame/sortable_example.rb +0 -350
  88. data/spec/dataframe_spec.rb +0 -1306
  89. data/spec/date_time/data_spec.rb +0 -197
  90. data/spec/date_time/date_time_index_helper_spec.rb +0 -72
  91. data/spec/date_time/index_spec.rb +0 -588
  92. data/spec/date_time/offsets_spec.rb +0 -465
  93. data/spec/extensions/which_dsl_spec.rb +0 -38
  94. data/spec/fixtures/bank2.dat +0 -200
  95. data/spec/fixtures/boolean_converter_test.csv +0 -5
  96. data/spec/fixtures/countries.json +0 -7794
  97. data/spec/fixtures/duplicates.csv +0 -32
  98. data/spec/fixtures/eciresults.html +0 -394
  99. data/spec/fixtures/empties.dat +0 -2
  100. data/spec/fixtures/empty_rows_test.csv +0 -17
  101. data/spec/fixtures/macau.html +0 -3691
  102. data/spec/fixtures/macd_data.csv +0 -150
  103. data/spec/fixtures/matrix_test.csv +0 -100
  104. data/spec/fixtures/moneycontrol.html +0 -6812
  105. data/spec/fixtures/music_data.tsv +0 -2501
  106. data/spec/fixtures/repeated_fields.csv +0 -7
  107. data/spec/fixtures/sales-funnel.csv +0 -18
  108. data/spec/fixtures/scientific_notation.csv +0 -4
  109. data/spec/fixtures/string_converter_test.csv +0 -5
  110. data/spec/fixtures/strings.dat +0 -2
  111. data/spec/fixtures/test_xls.xls +0 -0
  112. data/spec/fixtures/test_xls_2.xls +0 -0
  113. data/spec/fixtures/url_test.txt~ +0 -0
  114. data/spec/fixtures/valid_markup.html +0 -62
  115. data/spec/fixtures/wiki_climate.html +0 -1243
  116. data/spec/fixtures/wiki_table_info.html +0 -631
  117. data/spec/formatters/table_formatter_spec.rb +0 -137
  118. data/spec/helpers_spec.rb +0 -8
  119. data/spec/index/categorical_index_spec.rb +0 -221
  120. data/spec/index/index_spec.rb +0 -438
  121. data/spec/index/multi_index_spec.rb +0 -713
  122. data/spec/io/io_spec.rb +0 -357
  123. data/spec/io/sql_data_source_spec.rb +0 -48
  124. data/spec/iruby/dataframe_spec.rb +0 -170
  125. data/spec/iruby/helpers_spec.rb +0 -49
  126. data/spec/iruby/multi_index_spec.rb +0 -37
  127. data/spec/iruby/vector_spec.rb +0 -105
  128. data/spec/maths/arithmetic/dataframe_spec.rb +0 -148
  129. data/spec/maths/arithmetic/vector_spec.rb +0 -165
  130. data/spec/maths/statistics/dataframe_spec.rb +0 -178
  131. data/spec/maths/statistics/vector_spec.rb +0 -756
  132. data/spec/monkeys_spec.rb +0 -42
  133. data/spec/shared/vector_display_spec.rb +0 -213
  134. data/spec/spec_helper.rb +0 -87
  135. data/spec/support/database_helper.rb +0 -29
  136. data/spec/support/matchers.rb +0 -5
  137. data/spec/vector/aggregatable_example.rb +0 -27
  138. data/spec/vector/calculatable_example.rb +0 -82
  139. data/spec/vector/convertible_example.rb +0 -126
  140. data/spec/vector/duplicatable_example.rb +0 -48
  141. data/spec/vector/fetchable_example.rb +0 -463
  142. data/spec/vector/filterable_example.rb +0 -165
  143. data/spec/vector/indexable_example.rb +0 -201
  144. data/spec/vector/iterable_example.rb +0 -111
  145. data/spec/vector/joinable_example.rb +0 -25
  146. data/spec/vector/missable_example.rb +0 -88
  147. data/spec/vector/queryable_example.rb +0 -91
  148. data/spec/vector/setable_example.rb +0 -300
  149. data/spec/vector/sortable_example.rb +0 -242
  150. 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,221 +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 "positional index" do
36
- it { expect(index.pos 0).to eq 0 }
37
- end
38
-
39
- context "invalid positional index" do
40
- it { expect { index.pos 5 }.to raise_error IndexError }
41
- end
42
-
43
- context "multiple positional indexes" do
44
- subject { index.pos 0, 1, 2 }
45
-
46
- it { is_expected.to be_a Array }
47
- its(:size) { is_expected.to eq 3 }
48
- it { is_expected.to eq [0, 1, 2] }
49
- end
50
- end
51
-
52
- context "when the category is numeric" do
53
- let(:idx) { described_class.new [0, 1, 0, 0, 2] }
54
-
55
- context "first preference to category" do
56
- subject { idx.pos 0 }
57
-
58
- it { is_expected.to be_a Array }
59
- its(:size) { is_expected.to eq 3 }
60
- it { is_expected.to eq [0, 2, 3] }
61
- end
62
-
63
- context "second preference to positional index" do
64
- subject { idx.pos 3 }
65
-
66
- it { is_expected.to eq 3 }
67
- end
68
- end
69
- end
70
-
71
- describe "#[]" do
72
- context "when the category occurs once" do
73
- subject { index[:b] }
74
-
75
- it { is_expected.to eq 1 }
76
- end
77
-
78
- context "when the category occurs multiple times" do
79
- subject { index[:a] }
80
-
81
- it { is_expected.to eq [0, 2, 3] }
82
- end
83
-
84
- context "when given a positional index" do
85
- subject { index[0] }
86
-
87
- it { is_expected.to eq 0 }
88
- end
89
-
90
- context "when given multiple categories" do
91
- subject { index[:a, :c] }
92
-
93
- it { is_expected.to eq [0, 2, 3, 4] }
94
- end
95
-
96
- context "when the category is absent" do
97
- subject { index[:z] }
98
-
99
- it { is_expected.to be_nil }
100
- end
101
- end
102
-
103
- context "#subset" do
104
- let(:idx) { described_class.new [:a, 1, :a, 1, :c] }
105
-
106
- context "single index" do
107
- context "multiple instances" do
108
- subject { idx.subset :a }
109
-
110
- it { is_expected.to be_a described_class }
111
- its(:size) { is_expected.to eq 2 }
112
- its(:to_a) { is_expected.to eq [:a, :a] }
113
- end
114
- end
115
-
116
- context "multiple indexes" do
117
- subject { idx.subset :a, 1 }
118
-
119
- it { is_expected.to be_a described_class }
120
- its(:size) { is_expected.to eq 4 }
121
- its(:to_a) { is_expected.to eq [:a, 1, :a, 1] }
122
- end
123
-
124
- context "multiple positional indexes" do
125
- subject { idx.subset 0, 2 }
126
-
127
- it { is_expected.to be_a described_class }
128
- its(:size) { is_expected.to eq 2 }
129
- its(:to_a) { is_expected.to eq [:a, :a] }
130
- end
131
- end
132
-
133
- context "#at" do
134
- let(:idx) { described_class.new [:a, :a, :a, 1, :c] }
135
-
136
- context "single position" do
137
- it { expect(idx.at 1).to eq :a }
138
- end
139
-
140
- context "multiple positions" do
141
- subject { idx.at 0, 2, 3 }
142
-
143
- it { is_expected.to be_a described_class }
144
- its(:size) { is_expected.to eq 3 }
145
- its(:to_a) { is_expected.to eq [:a, :a, 1] }
146
- end
147
-
148
- context "range" do
149
- subject { idx.at 2..3 }
150
-
151
- it { is_expected.to be_a described_class }
152
- its(:size) { is_expected.to eq 2 }
153
- its(:to_a) { is_expected.to eq [:a, 1] }
154
- end
155
-
156
- context "range with negative integers" do
157
- subject { idx.at 2..-2 }
158
-
159
- it { is_expected.to be_a described_class }
160
- its(:size) { is_expected.to eq 2 }
161
- its(:to_a) { is_expected.to eq [:a, 1] }
162
- end
163
-
164
- context "rangle with single element" do
165
- subject { idx.at 2..2 }
166
-
167
- it { is_expected.to be_a described_class }
168
- its(:size) { is_expected.to eq 1 }
169
- its(:to_a) { is_expected.to eq [:a] }
170
- end
171
-
172
- context "invalid position" do
173
- it { expect { idx.at 5 }.to raise_error IndexError }
174
- end
175
-
176
- context "invalid positions" do
177
- it { expect { idx.at 2, 5 }.to raise_error IndexError }
178
- end
179
- end
180
-
181
- context "#add" do
182
- let(:idx) { described_class.new [:a, 1, :a, 1] }
183
-
184
- context "single index" do
185
- subject { idx.add :c }
186
-
187
- its(:to_a) { is_expected.to eq [:a, 1, :a, 1, :c] }
188
- its(:categories) { is_expected.to eq [:a, 1, :c] }
189
- end
190
-
191
- context "multiple indexes" do
192
- subject { idx.add :c, :d }
193
-
194
- its(:to_a) { is_expected.to eq [:a, 1, :a, 1, :c, :d] }
195
- its(:categories) { is_expected.to eq [:a, 1, :c, :d] }
196
- end
197
- end
198
-
199
- context "#valid?" do
200
- let(:idx) { described_class.new [:a, 1, :a, 1] }
201
-
202
- context "single index" do
203
- it { expect(idx.valid? :a).to eq true }
204
- it { expect(idx.valid? 2).to eq true }
205
- it { expect(idx.valid? 4).to eq false }
206
- end
207
-
208
- context "multiple indexes" do
209
- it { expect(idx.valid? :a, 1).to eq true }
210
- it { expect(idx.valid? :a, 1, 5).to eq false }
211
- end
212
- end
213
-
214
- describe '#delete_at' do
215
- subject { index.delete_at(3) }
216
-
217
- let(:index) { described_class.new([:a, 1, :a, 1, 'c']) }
218
-
219
- it { is_expected.to eq(described_class.new([:a, 1, :a, 'c'])) }
220
- end
221
- end