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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b73fd7c9b64515cb0d5c39ec11df549bd0f1ae4
4
- data.tar.gz: 36f02c014942abfc3b83dbd766b1410df5952871
3
+ metadata.gz: 77f5fe74aadbbee67156c46c190f73ec8a722226
4
+ data.tar.gz: 9d67c1568ee6d40198c141ba4e7e0a4f6b222122
5
5
  SHA512:
6
- metadata.gz: 8e71952e875add4b1f8a6801a1f16e6e460b1ba71c0ec61d4101c50835599aaf898a0f617f2962a8352b4febbccfa3cb0012620a241d0fdb0531716f0ddae0f4
7
- data.tar.gz: 3a781828fcffcca857d2139ec7719961e7678c06415f564457bfa1a29dc910baafdcafe1b863243bf7ddbcdd160c047645bb392753b0f7a9f3c4513643bb8496
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]
@@ -17,6 +17,10 @@ class SimpleTimeSeries
17
17
  end
18
18
  end
19
19
 
20
+ def find_plus_label(what, date, end_date=nil)
21
+ find(what, date, end_date).unshift(what)
22
+ end
23
+
20
24
  def current(what)
21
25
  send what.to_sym
22
26
  end
@@ -1,3 +1,3 @@
1
1
  class SimpleTimeSeries
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -26,7 +26,7 @@ describe SimpleTimeSeries do
26
26
  @my_data.time_vars["dows"].should == @dows
27
27
  end
28
28
 
29
- it "has the correct methods" do
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 "should calculate the correct vector of cumulative sums for the referenced data_var" do
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 "should let me access a single value in a vector of cumulative sums with any time_var value" do
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 "should let me access a subarray of a vector of differences with any time_var value" do
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_time_series
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Lavin