quandl_operation 0.1.8 → 0.1.9

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.
data/UPGRADE.md CHANGED
@@ -1,11 +1,15 @@
1
- ## 0.8
1
+ ## 0.1.9
2
+
3
+ * write failing spec for cumul. make spec pass
4
+
5
+ ## 0.1.8
2
6
 
3
7
  * add Collapse.collapses_greater_than_or_equal_to(freq) add Collapse.collapses_greater_than(freq)
4
8
 
5
- ## 0.7
9
+ ## 0.1.7
6
10
 
7
11
  * date start_of_frequency given invalid input should return the date
8
12
 
9
- ## 0.1
13
+ ## 0.1.0
10
14
 
11
15
  Initial
@@ -4,10 +4,18 @@ module Operation
4
4
  class Transform
5
5
  class << self
6
6
 
7
- def perform( data, type)
7
+ def perform( data, type )
8
+ # original order
9
+ order = Parse.sort_order?(data)
10
+ # operations expect data in ascending order
8
11
  data = Parse.sort( data, :asc )
12
+ # operations expect float values
9
13
  data = Parse.values_to_float(data)
10
- data = transform_and_log( data, type)
14
+ # transform
15
+ data = transform_and_log( data, type )
16
+ # return to original order
17
+ data = Parse.sort( data, :desc ) if order == :desc
18
+ # onwards
11
19
  data
12
20
  end
13
21
 
@@ -133,7 +141,6 @@ class Transform
133
141
  data[i] = [keylist[i], temparr[i]].flatten
134
142
  end
135
143
  else
136
- data = Parse.sort( data, :desc )
137
144
  cumulsum = Array.new(numcols,0)
138
145
  sumstarted = Array.new(numcols,false)
139
146
  #now build temparr
@@ -1,5 +1,5 @@
1
1
  module Quandl
2
2
  module Operation
3
- VERSION = "0.1.8"
3
+ VERSION = "0.1.9"
4
4
  end
5
5
  end
@@ -2,15 +2,24 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  describe Quandl::Operation::Transform do
5
-
6
- context "rdiff_from" do
7
-
8
- it "should transform the data correctly" do
5
+
6
+ describe "#perform" do
7
+ it "should rdiff_from" do
9
8
  data = [[1,3,5],[4,5,4],[5,15,20]]
10
9
  result = Quandl::Operation::Transform.perform(data, :rdiff_from)
11
- result.should eq [[1,4,3],[4,2,4],[5,0,0]]
10
+ result.should eq [[1,4,3],[4,2,4],[5,0,0]]
11
+ end
12
+ it "should cumul asc" do
13
+ data = [[1000, 10], [1001, 20], [1002, 30]]
14
+ result = Quandl::Operation::Transform.perform(data, :cumul)
15
+ result.should eq [[1000, 10], [1001, 30], [1002, 60]]
16
+ end
17
+ it "should cumul desc" do
18
+ data = [[1002, 30], [1001, 20], [1000, 10]]
19
+ result = Quandl::Operation::Transform.perform(data, :cumul)
20
+ result.should eq [[1002, 60], [1001, 30], [1000, 10]]
12
21
  end
13
22
 
14
23
  end
15
-
16
- end
24
+
25
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quandl_operation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-20 00:00:00.000000000 Z
12
+ date: 2013-09-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake