jsvd-sequel_vectorized 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,4 +1,12 @@
1
- == 0.0.5 / 2009-06-04
1
+ == 0.1.0 / 2009-09-25
2
+
3
+ * Prevent exception if trying to interpolate insufficient data
4
+
5
+ == 0.0.6 / 2009-09-25
6
+
7
+ * Prevent exception if trying to interpolate insufficient data
8
+
9
+ == 0.0.5 / 2009-09-24
2
10
 
3
11
  * Axis range is now a ruby Range
4
12
  * Proper creation of data vectors if end of range is excluded or not
@@ -53,12 +53,15 @@ class Sequel::Dataset
53
53
 
54
54
  new_size = (range.last - range.first)/step.to_f
55
55
  new_size +=1 unless range.exclude_end?
56
+
56
57
  raw_axis = data[axis_col]
58
+ interpolate = false if raw_axis.size <= 1 # turn off interpolation of insufficient data
59
+
57
60
  data["__#{axis_col}".to_sym] = raw_axis
58
61
 
59
62
  interp = GSL::Interp.alloc("linear", raw_axis.size) if interpolate
60
63
 
61
- data[axis_col] = NArray.float(new_size).indgen!(range.first,step)
64
+ data[axis_col] = NArray.float(new_size).indgen!(range.first.to_f,step)
62
65
 
63
66
  data[:__raw_mask] = NArray.byte(new_size)
64
67
  data[:__raw_mask][(raw_axis - range.first)/step.to_f] = 1
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = "sequel_vectorized"
3
- s.version = "0.0.5"
3
+ s.version = "0.1.0"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.has_rdoc = false
6
6
  s.summary = ""
@@ -145,9 +145,24 @@ describe Sequel::Dataset do
145
145
  @items.filter(:name => 'abc').vectorize(:axis => {:column => :price, :range => 0 ... 100, :step => 20 }).should_not be_empty
146
146
  end
147
147
 
148
- it "should not raise error for an interval" do
148
+ it "should not raise error if there's not enough data for interpolation" do
149
+
150
+ axis = {
151
+ :column => :ts,
152
+ :step => 60,
153
+ :range => Time.local(2008,1,1,12,30).to_f .. Time.local(2008,1,1,12,31).to_f,
154
+ :interpolate => true
155
+ }
156
+
157
+ lambda { @events.vectorize :axis => axis }.should_not raise_error
158
+ @events.vectorize(:axis => axis).should include :__value
159
+ @events.vectorize(:axis => axis).should include :__raw_mask
160
+ @events.vectorize(:axis => axis)[:__value].size.should == 1
161
+ @events.vectorize(:axis => axis)[:__raw_mask].size.should == 2
149
162
 
150
- require 'lib/sequel_vectorized'
163
+ end
164
+
165
+ it "should not raise error for an interval" do
151
166
 
152
167
  @events << {:value => 2.2, :ts => Time.local(2009,8,14,21,0).to_f}
153
168
  @events << {:value => 2.2, :ts => Time.local(2009,8,14,22,0).to_f}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsvd-sequel_vectorized
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Jo\xC3\xA3o Duarte"