jsvd-sequel_vectorized 0.0.5 → 0.1.0
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/ChangeLog +9 -1
- data/lib/sequel_vectorized.rb +4 -1
- data/sequel_vectorized.gemspec +1 -1
- data/spec/sequel_vectorized_spec.rb +17 -2
- metadata +1 -1
data/ChangeLog
CHANGED
@@ -1,4 +1,12 @@
|
|
1
|
-
== 0.0
|
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
|
data/lib/sequel_vectorized.rb
CHANGED
@@ -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
|
data/sequel_vectorized.gemspec
CHANGED
@@ -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
|
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
|
-
|
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}
|