simple_time_series 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/simple_time_series/simple_time_series.rb +4 -0
- data/lib/simple_time_series/version.rb +1 -1
- data/spec/lib/simple_time_series_spec.rb +29 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77f5fe74aadbbee67156c46c190f73ec8a722226
|
4
|
+
data.tar.gz: 9d67c1568ee6d40198c141ba4e7e0a4f6b222122
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc234775ae834f544f18bf21cf04c2127eb80bb07cbaafe34592eb604b3dfbabdba07f04f5c5785eb9ac61454208a1af9ac54dc12355cd09a419993b449b65fa
|
7
|
+
data.tar.gz: 41cfa5ab40b9d5ed128b88df8b264464b6f98742e5a0ab373dcd561851101f8a418d1360afe615dae3cb5ba41c30070849153801174ac5503e64e199d31333c4
|
data/README.md
CHANGED
@@ -73,6 +73,8 @@ You can also get ranges of values using SimpleTimeSeries#find with three argumen
|
|
73
73
|
my_data.find('miles', 'Jan 2, 2014','2014-01-06') # returns [3.1, 0.0, 4.3, 1.2, 12.2]
|
74
74
|
my_data.find('tasks_done', '2014-01-02', 'Friday') # returns [3, 0, 14, 3, 11]
|
75
75
|
|
76
|
+
(If you do the above, but replacing #find with #find_plus_label, the label will be prepended to the array.)
|
77
|
+
|
76
78
|
You can view all the values associated with any variable:
|
77
79
|
|
78
80
|
my_data.miles # prints [2.2, 3.1, 0.0, 4.3, 1.2, 12.2, 2.3]
|
@@ -26,7 +26,7 @@ describe SimpleTimeSeries do
|
|
26
26
|
@my_data.time_vars["dows"].should == @dows
|
27
27
|
end
|
28
28
|
|
29
|
-
it "
|
29
|
+
it "creates the correct methods" do
|
30
30
|
[:time_vars, :time_vars=, :data_vars, :data_vars=, :find, :pizzas, :pizzas=, :pizzas_on, :miles, :miles=, :miles_on, :tasks_done, :tasks_done=, :tasks_done_on, :dows, :dows=, :dates, :dates=].each do |mthd|
|
31
31
|
@my_data.methods.should include(mthd)
|
32
32
|
end
|
@@ -57,6 +57,23 @@ describe SimpleTimeSeries do
|
|
57
57
|
@my_data.find('tasks_done', '2014-01-02', 'Friday').should == [3, 0, 14, 3, 11]
|
58
58
|
end
|
59
59
|
|
60
|
+
#it "creates a #find_plus_label method for finding any data value for any time observation" do
|
61
|
+
# @my_data.find('pizzas', 'Tuesday').should == 1
|
62
|
+
# @my_data.find('pizzas', 'Thursday').should == 0.5
|
63
|
+
# @my_data.find('miles', 'Sunday').should == 2.2
|
64
|
+
# @my_data.find('miles', '2014-01-06').should == 12.2
|
65
|
+
# @my_data.find('tasks_done', '2014-01-02').should == 3
|
66
|
+
#end
|
67
|
+
|
68
|
+
it "creates a #find_plus_label method for finding any data values for a range of observations" do
|
69
|
+
@my_data.find_plus_label('pizzas', 'Tuesday', 'Thursday').should == ['pizzas', 1, 0, 0.5]
|
70
|
+
@my_data.find_plus_label('pizzas', 'Thursday', '2014-01-07').should == ['pizzas', 0.5, 0, 2]
|
71
|
+
#@my_data.find_plus_label('miles', 'Saturday', '2014-01-07').should == 2.3
|
72
|
+
@my_data.find_plus_label('miles', 'Sunday', '2014-01-07').should == ['miles', 2.2, 3.1, 0.0, 4.3, 1.2, 12.2, 2.3]
|
73
|
+
@my_data.find_plus_label('miles', 'Jan 2, 2014','2014-01-06').should == ['miles', 3.1, 0.0, 4.3, 1.2, 12.2]
|
74
|
+
@my_data.find_plus_label('tasks_done', '2014-01-02', 'Friday').should == ['tasks_done', 3, 0, 14, 3, 11]
|
75
|
+
end
|
76
|
+
|
60
77
|
it "creates setter methods for updating a data series" do
|
61
78
|
@my_data.pizzas_on('Tuesday').should == 1
|
62
79
|
@my_data.pizzas = [10, 11, 12, 13, 14, 15, 16]
|
@@ -233,7 +250,7 @@ describe SimpleTimeSeries do
|
|
233
250
|
|
234
251
|
describe "#xyz_cumsum" do
|
235
252
|
|
236
|
-
it "
|
253
|
+
it "calculates the correct vector of cumulative sums for the referenced data_var" do
|
237
254
|
# @tasks_done = [2, 3, 0, 14, 3, 11, 0]
|
238
255
|
@my_data.tasks_done_cumsum.should == [2, 5, 5, 19, 22, 33, 33]
|
239
256
|
@my_data.tasks_done_cumsum[3].should == 19
|
@@ -242,7 +259,7 @@ describe SimpleTimeSeries do
|
|
242
259
|
@my_data.pizzas_cumsum.should == [0, 0, 1, 1, 1.5, 1.5, 3.5]
|
243
260
|
end
|
244
261
|
|
245
|
-
it "
|
262
|
+
it "accesses a single value in a vector of cumulative sums with any time_var value" do
|
246
263
|
@my_data.tasks_done_cumsum('Saturday').should == 33
|
247
264
|
@my_data.tasks_done_cumsum('Sunday').should == 2
|
248
265
|
@my_data.pizzas_cumsum('Saturday').should == 3.5
|
@@ -250,11 +267,19 @@ describe SimpleTimeSeries do
|
|
250
267
|
@my_data.pizzas_cumsum('Jan 4, 2014').should == 1
|
251
268
|
end
|
252
269
|
|
253
|
-
it "
|
270
|
+
it "accesses a subarray of a vector of differences with any time_var value" do
|
254
271
|
@my_data.tasks_done_cumsum('Sunday','Monday').should == [2, 5]
|
255
272
|
@my_data.tasks_done_cumsum('Tuesday','Saturday').should == [5, 19, 22, 33, 33]
|
256
273
|
end
|
257
274
|
|
258
275
|
end
|
259
276
|
|
277
|
+
#describe "#data_array" do
|
278
|
+
|
279
|
+
# it "builds an array of arrays with all time_vars" do
|
280
|
+
# @my_data.data_array('tasks_done').should == [ @my_data.current('tasks_done')]
|
281
|
+
# end
|
282
|
+
|
283
|
+
#end
|
284
|
+
|
260
285
|
end
|