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,197 +0,0 @@
1
- describe DaruLite::Vector do
2
- context "#initialize" do
3
- it "accepts DateTimeIndex in index option" do
4
- index = DaruLite::DateTimeIndex.date_range(:start => DateTime.new(2012,2,1), periods: 100)
5
- vector = DaruLite::Vector.new [1,2,3,4,5]*20, index: index
6
-
7
- expect(vector.class).to eq(DaruLite::Vector)
8
- expect(vector['2012-2-3']).to eq(3)
9
- end
10
- end
11
-
12
- context "#[]" do
13
- before do
14
- index = DaruLite::DateTimeIndex.date_range(
15
- :start => DateTime.new(2012,4,4), :end => DateTime.new(2012,4,7), freq: 'H')
16
- @vector = DaruLite::Vector.new([23]*index.size, index: index)
17
- end
18
-
19
- it "returns the element when complete date" do
20
- expect(@vector['2012-4-4 22:00:00']).to eq(23)
21
- end
22
-
23
- it "accepts DateTime object for [] argument" do
24
- expect(@vector[DateTime.new(2012,4,4,22)]).to eq(23)
25
- end
26
-
27
- it "returns slice when partial date" do
28
- slice_index = DaruLite::DateTimeIndex.date_range(
29
- :start => DateTime.new(2012,4,4), :periods => 24, freq: 'H')
30
- expect(@vector['2012-4-4']).to eq(
31
- DaruLite::Vector.new([23]*slice_index.size, index: slice_index))
32
- end
33
-
34
- it "returns a slice when range" do
35
- slice_index = DaruLite::DateTimeIndex.date_range(
36
- :start => DateTime.new(2012,4,4), :end => DateTime.new(2012,4,5,23,), freq: 'H')
37
- expect(@vector['2012-4-4'..'2012-4-5']).to eq(
38
- DaruLite::Vector.new([23]*slice_index.size, index: slice_index))
39
- end
40
-
41
- it "returns a slice when numeric range" do
42
- slice_index = DaruLite::DateTimeIndex.date_range(
43
- :start => DateTime.new(2012,4,4), :periods => 20, :freq => 'H')
44
- expect(@vector[0..19]).to eq(
45
- DaruLite::Vector.new([23]*slice_index.size, index: slice_index))
46
- end
47
-
48
- it "returns the element when number" do
49
- expect(@vector[32]).to eq(23)
50
- end
51
- end
52
-
53
- context "#[]=" do
54
- it "assigns a single element when index complete" do
55
- index = DaruLite::DateTimeIndex.date_range(:start => '2012', :periods => 5, :freq => 'D')
56
- vector = DaruLite::Vector.new([1,2,3,4,5], index: index)
57
- vector['2012-1-4'] = 666
58
- expect(vector).to eq(DaruLite::Vector.new([1,2,3,666,5], index: index))
59
- end
60
-
61
- it "assigns single element when specified a number for indexing" do
62
- index = DaruLite::DateTimeIndex.date_range(:start => '2012', :periods => 5, :freq => 'D')
63
- vector = DaruLite::Vector.new([1,2,3,4,5], index: index)
64
-
65
- vector[2] = 666
66
- expect(vector).to eq(
67
- DaruLite::Vector.new([1,2,666,4,5], index: index))
68
- end
69
-
70
- it "assigns multiple elements when index incomplete" do
71
- index = DaruLite::DateTimeIndex.date_range(:start => '2012', :periods => 100,
72
- :freq => 'MB')
73
- vector = DaruLite::Vector.new([1,2,3,4,5,6,7,8,9,10]*10, index: index)
74
- vector['2012'] = 666
75
- arr = [666]*12 + [3,4,5,6,7,8,9,10] + [1,2,3,4,5,6,7,8,9,10]*8
76
- expect(vector).to eq(DaruLite::Vector.new(arr, index: index))
77
- end
78
- end
79
- end
80
-
81
- describe DaruLite::DataFrame do
82
- before :each do
83
- @index = DaruLite::DateTimeIndex.date_range(:start => '2012-2-1', periods: 100)
84
- @order = DaruLite::DateTimeIndex.new([
85
- DateTime.new(2012,1,3),DateTime.new(2013,2,3),DateTime.new(2012,3,3)])
86
- @a = [1,2,3,4,5]*20
87
- @b = @a.map { |e| e*3 }
88
- @c = @a.map(&:to_s)
89
- @df = DaruLite::DataFrame.new([@a, @b, @c], index: @index, order: @order)
90
- end
91
-
92
- context "#initialize" do
93
- it "accepts DateTimeIndex for index and order options" do
94
- expect(@df.index).to eq(@index)
95
- expect(@df['2013-2-3']).to eq(
96
- DaruLite::Vector.new(@b, index: @index))
97
- end
98
- end
99
-
100
- context "#[]" do
101
- it "returns one Vector when complete index" do
102
- expect(@df['2012-3-3']).to eq(DaruLite::Vector.new(@c, index: @index))
103
- end
104
-
105
- it "returns a Vector when DateTime object specified" do
106
- expect(@df[DateTime.new(2012,3,3)]).to eq(
107
- DaruLite::Vector.new(@c, index: @index))
108
- end
109
-
110
- it "returns DataFrame when incomplete index" do
111
- answer = DaruLite::DataFrame.new(
112
- [@a, @c], index: @index, order: DaruLite::DateTimeIndex.new([
113
- DateTime.new(2012,1,3),DateTime.new(2012,3,3)]))
114
- expect(@df['2012']).to eq(answer)
115
- end
116
-
117
- it "returns Vector when single index specified as a number" do
118
- expect(@df[1]).to eq(DaruLite::Vector.new(@b, index: @index))
119
- end
120
- end
121
-
122
- context "#[]=" do
123
- it "assigns one Vector when complete index" do
124
- answer = DaruLite::DataFrame.new([@a, @b, @a], index: @index, order: @order)
125
- @df['2012-3-3'] = @a
126
- expect(@df).to eq(answer)
127
- end
128
-
129
- it "assigns one Vector when index as DateTime object" do
130
- answer = DaruLite::DataFrame.new([@a, @b, @a], index: @index, order: @order)
131
- @df[DateTime.new(2012,3,3)] = @a
132
- expect(@df).to eq(answer)
133
- end
134
-
135
- it "assigns multiple vectors when incomplete index" do
136
- answer = DaruLite::DataFrame.new([@b,@b,@b], index: @index, order: @order)
137
- @df['2012'] = @b
138
- expect(@df).to eq(answer)
139
- end
140
-
141
- it "assigns Vector when specified position index" do
142
- answer = DaruLite::DataFrame.new([@a, @b, @a], index: @index, order: @order)
143
- @df[2] = @a
144
- expect(@df).to eq(answer)
145
- end
146
- end
147
-
148
- context "#row[]" do
149
- it "returns one row Vector when complete index" do
150
- expect(@df.row['2012-2-1']).to eq(DaruLite::Vector.new([1,3,"1"], index: @order))
151
- end
152
-
153
- it "returns one row when complete DateTime specified" do
154
- expect(@df.row[DateTime.new(2012,2,1)]).to eq(
155
- DaruLite::Vector.new([1,3,"1"], index: @order))
156
- end
157
-
158
- it "returns DataFrame when incomplete index" do
159
- range = 0..28
160
- a = @a[range]
161
- b = @b[range]
162
- c = @c[range]
163
- i = DaruLite::DateTimeIndex.date_range(:start => '2012-2-1', periods: 29)
164
- answer = DaruLite::DataFrame.new([a,b,c], index: i, order: @order)
165
-
166
- expect(@df.row['2012-2']).to eq(answer)
167
- end
168
-
169
- it "returns one row Vector when position index" do
170
- expect(@df.row[2]).to eq(DaruLite::Vector.new([3,9,'3'], index: @order))
171
- end
172
- end
173
-
174
- context "#row[]=" do
175
- it "assigns one row Vector when complete index" do
176
- @df.row['2012-2-4'] = [666,999,0]
177
- expect(@df.row['2012-2-4']).to eq(DaruLite::Vector.new([666,999,0], index: @order))
178
- end
179
-
180
- it "assigns one row Vector when complete index as DateTime" do
181
- @df.row[DateTime.new(2012,2,5)] = [1,2,3]
182
- expect(@df.row[DateTime.new(2012,2,5)]).to eq(
183
- DaruLite::Vector.new([1,2,3], index: @order))
184
- end
185
-
186
- it "assigns multiple rows when incomplete index" do
187
- a = [666]*29
188
- b = [999]*29
189
- c = [0]*29
190
- index = DaruLite::DateTimeIndex.date_range(:start => '2012-2-1', :periods => 29)
191
- answer = DaruLite::DataFrame.new([a,b,c], index: index, order: @order)
192
- @df.row['2012-2'] = [666,999,0]
193
-
194
- expect(@df.row['2012-2']).to eq(answer)
195
- end
196
- end
197
- end
@@ -1,72 +0,0 @@
1
- include DaruLite
2
-
3
- describe DaruLite::DateTimeIndexHelper do
4
-
5
-
6
- describe '.infer_offset' do
7
- subject(:offset) { DaruLite::DateTimeIndexHelper.infer_offset(data) }
8
-
9
- context 'when the dataset does not have a regular offset' do
10
- let(:data) do
11
- [
12
- DateTime.new(2020, 1, 1, 00, 00, 00),
13
- DateTime.new(2020, 1, 1, 00, 01, 00),
14
- DateTime.new(2020, 1, 1, 00, 05, 00),
15
- ]
16
- end
17
-
18
- it 'returns nil' do
19
- expect(offset).to be_nil
20
- end
21
- end
22
-
23
- context 'when the dataset matches a defined offset' do
24
- let(:data) do
25
- [
26
- DateTime.new(2020, 1, 1, 00, 00, 00),
27
- DateTime.new(2020, 1, 1, 00, 01, 00),
28
- DateTime.new(2020, 1, 1, 00, 02, 00),
29
- ]
30
- end
31
-
32
- it 'returns the matched offset' do
33
- expect(offset).to be_an_instance_of(DaruLite::Offsets::Minute)
34
- end
35
- end
36
-
37
- context 'when the offset is a multiple of seconds' do
38
- let(:data) do
39
- [
40
- DateTime.new(2020, 1, 1, 00, 00, 00),
41
- DateTime.new(2020, 1, 1, 00, 00, 03),
42
- DateTime.new(2020, 1, 1, 00, 00, 06),
43
- ]
44
- end
45
-
46
- let(:expected_offset) { DaruLite::Offsets::Second.new(3) }
47
-
48
- it 'returns a Second offset' do
49
- expect(offset).to be_an_instance_of(DaruLite::Offsets::Second)
50
- end
51
-
52
- it 'has the correct multiplier' do
53
- expect(offset.freq_string).to eql(expected_offset.freq_string)
54
- end
55
- end
56
-
57
- context 'when the offset is less than a second' do
58
- let(:data) do
59
- [
60
- DateTime.new(2020, 1, 1, 00, 00, 00) + 0.00001,
61
- DateTime.new(2020, 1, 1, 00, 00, 00) + 0.00002,
62
- DateTime.new(2020, 1, 1, 00, 00, 00) + 0.00003,
63
- ]
64
- end
65
-
66
- it 'returns nil' do
67
- expect(offset).to be_nil
68
- end
69
- end
70
- end
71
-
72
- end