quandl_operation 0.1.15 → 0.1.16

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: 9198c1525d4fa61402a393fb1d8a2c28405dbaad
4
- data.tar.gz: 13367768e13f249d3a91711fd93caae574202516
3
+ metadata.gz: e01dc270ba70500cc3987580af7247acae1a1f6c
4
+ data.tar.gz: 4d9aabee9e600e6bb744478a5936c881be5d85f7
5
5
  SHA512:
6
- metadata.gz: 7313a0bb124b860b598c336417580d3c2420a45699577da0765b2ca04827f7ab3e740c23cf044e6c04d0886726c6495a05086a5d1e7c38e7aa4e8f42d4b26bde
7
- data.tar.gz: 04c7150697d0f303420a6bc8e3da5976ff89a5626da1aa2d55186a6490a04d70a50da0134a812a76faa0c9618723c925d47cf85e2d34dd661392f17c833607e2
6
+ metadata.gz: 22c6695a3b11744acbdafad589cc307aa1b77d7a127833a2a2185a632a50cb139e26694619266f167a5083774634c92de8594f18eaa89b4ffe5713816df7a126
7
+ data.tar.gz: 99d5152bf5d87af7f3fd3c431509b9c7fdbde7e2c282654caf60897c1528ea9d5ed3874c99a73eaf167b6d0d86b906fff34d3845eee4dd3c5198b6bf41eca1f3
@@ -9,6 +9,7 @@ class Collapse
9
9
  class << self
10
10
 
11
11
  def perform(data, frequency)
12
+ return data unless data.is_a?(Array) && data.compact.present?
12
13
  # source order
13
14
  order = Parse.sort_order?(data)
14
15
  # operations expect data in ascending order
@@ -5,6 +5,7 @@ class Transform
5
5
  class << self
6
6
 
7
7
  def perform( data, type )
8
+ return data unless data.is_a?(Array) && data.compact.present?
8
9
  # original order
9
10
  order = Parse.sort_order?(data)
10
11
  # operations expect data in ascending order
@@ -1,5 +1,5 @@
1
1
  module Quandl
2
2
  module Operation
3
- VERSION = "0.1.15"
3
+ VERSION = "0.1.16"
4
4
  end
5
5
  end
@@ -59,11 +59,19 @@ describe Quandl::Operation::Collapse do
59
59
  [2456505, 55.4, 135964.0, nil],
60
60
  [2456474, 50.9, 135860.0, nil]]
61
61
  end
62
-
62
+
63
+ it "should handle empty data" do
64
+ subject.perform( [], :weekly ).should eq []
65
+ end
66
+
67
+ it "should handle empty data" do
68
+ subject.perform( [nil], :weekly ).should eq [nil]
69
+ end
70
+
63
71
  end
64
72
 
65
73
  describe ".collapse" do
66
-
74
+
67
75
  it 'should handle data sets with one data point only' do
68
76
 
69
77
  data = [[ 2455875, 42 ]]
@@ -3,20 +3,31 @@ require 'spec_helper'
3
3
 
4
4
  describe Quandl::Operation::Transform do
5
5
 
6
- describe "#perform" do
6
+ subject{ Quandl::Operation::Transform }
7
+
8
+ describe ".perform" do
9
+
10
+ it "should handle empty data" do
11
+ subject.perform( [], :rdiff ).should eq []
12
+ end
13
+
14
+ it "should handle empty data" do
15
+ subject.perform( [nil], :cumul ).should eq [nil]
16
+ end
17
+
7
18
  it "should rdiff_from" do
8
19
  data = [[1,3,5],[4,5,4],[5,15,20]]
9
- result = Quandl::Operation::Transform.perform(data, :rdiff_from)
20
+ result = subject.perform(data, :rdiff_from)
10
21
  result.should eq [[1,4,3],[4,2,4],[5,0,0]]
11
22
  end
12
23
  it "should cumul asc" do
13
24
  data = [[1000, 10], [1001, 20], [1002, 30]]
14
- result = Quandl::Operation::Transform.perform(data, :cumul)
25
+ result = subject.perform(data, :cumul)
15
26
  result.should eq [[1000, 10], [1001, 30], [1002, 60]]
16
27
  end
17
28
  it "should cumul desc" do
18
29
  data = [[1002, 30], [1001, 20], [1000, 10]]
19
- result = Quandl::Operation::Transform.perform(data, :cumul)
30
+ result = subject.perform(data, :cumul)
20
31
  result.should eq [[1002, 60], [1001, 30], [1000, 10]]
21
32
  end
22
33
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quandl_operation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.15
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Hilscher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-07 00:00:00.000000000 Z
11
+ date: 2013-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake