SciRuby / daru

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

Vector initialization failed when dtype is nmatrix #153

Closed lokeshh closed 7 years ago

lokeshh commented 8 years ago

Vector containing nils can't be initialized using :nmatrix even though nmatrix supports nil's.

[12] pry(main)> x = Daru::Vector.new [2, nil], dtype: :nmatrix
TypeError: no implicit conversion from nil to integer
from /home/ubuntu/workspace/daru/lib/daru/accessors/nmatrix_wrapper.rb:28:in `initialize'

(Discovered this while working with https://github.com/v0dro/daru/pull/134; writing it down in case I forget it.)

v0dro commented 8 years ago

You'll need to specify :nm_dtype as :object or alternatively catch the error and change the required data type to :object from the default :int32.