Sha256: 9d23a7d4157a2af00e4965caf81f5690002837a1fbff611992d02047ab03c26b
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
require 'spec_helper' describe LinearInterpolation do let(:arr_t) { [1.0, 2.0, 3.0] } let(:arr_v) { [100, 200, 300] } let(:arr_v_a) { [[100], [200], [300]] } let(:arr_v_h) { [{ x: 100 }, { x: 200 }, { x: 300 }] } it { expect { TimeSeries.new.use(LinearInterpolation) }.to_not raise_error } context 'when values are floats' do subject { TimeSeries.new(arr_t, arr_v).use(LinearInterpolation) } it { expect(subject[1.5]).to eql 150.to_f } end context 'when values are arrays' do subject { TimeSeries.new(arr_t, arr_v_a).use(LinearInterpolation) } it { expect(subject[1.5]).to eql [150.to_f] } end context 'when values are hashes' do subject { TimeSeries.new(arr_t, arr_v_h).use(LinearInterpolation) } it { expect(subject[1.5]).to eql({ x: 150.to_f }) } end context 'when requested value is out of range' do subject { TimeSeries.new(arr_t, arr_v).use(LinearInterpolation) } it { expect(subject[-1.0].to_f).to eql 100.to_f } it { expect(subject[10.0].to_f).to eql 300.to_f } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
time_series_math-0.1.1 | spec/time_series_math/linear_interpolation_spec.rb |