SciRuby / daru

Data Analysis in RUby
BSD 2-Clause "Simplified" License
1.04k stars 139 forks source link

DateTimeIndex bug #338

Closed user919lx closed 7 years ago

user919lx commented 7 years ago

Code Sample

require 'daru'
t1=10.times.map{|i| DateTime.new(2013,i+1,1)}
t2=10.times.map{|i| DateTime.new(2014,i+1,1)}
t3=10.times.map{|i| DateTime.new(2016,i+1,1)}
t=t1|t2|t3
v=Daru::Vector.new(t.size.times.to_a,index:t)
v['2015']

Problem description

excute above codes then return error : NoMethodError: undefined method '[]' for nil:NilClass

I use daru in my project but for some data missing middle date like above ,it makes error. It seems DateTimeIndex has many bug, but I have to use it for some reason.So sad.

Expected Output

Daru::Vector(0)

zverok commented 7 years ago

There was (?) a generic problem with empty DateTimeIndex, that probably nobody have tried to use. I believe I fixed it in https://github.com/SciRuby/daru/pull/339.