spec/vector_spec.rb in daru-0.2.0 vs spec/vector_spec.rb in daru-0.2.1
- old
+ new
@@ -1806,9 +1806,25 @@
before { subject.rolling_fillna!(direction: :backward) }
it { is_expected.to eq Daru::Vector.new([2, 2, 1, 4, 3, 3, 3, 0, 0], index: %w[a b c d e f g h i]) }
end
end
+ context '#rolling_fillna' do
+ subject do
+ Daru::Vector.new(
+ [Float::NAN, 2, 1, 4, nil, Float::NAN, 3, nil, Float::NAN]
+ )
+ end
+
+ context 'rolling_fillna forwards' do
+ it { expect(subject.rolling_fillna(:forward).to_a).to eq [0, 2, 1, 4, 4, 4, 3, 3, 3] }
+ end
+
+ context 'rolling_fillna backwards' do
+ it { expect(subject.rolling_fillna(direction: :backward).to_a).to eq [2, 2, 1, 4, 3, 3, 3, 0, 0] }
+ end
+ end
+
context "#type" do
before(:each) do
@numeric = Daru::Vector.new([1,2,3,4,5])
@multi = Daru::Vector.new([1,2,3,'sameer','d'])
@with_nils = Daru::Vector.new([1,2,3,4,nil])