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,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