SciRuby / daru

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

[WIP]add test for Daru::DataFrame "#to_category": it can add_row after to_category #388

Closed rainchen closed 6 years ago

rainchen commented 6 years ago

Here is the failure details of test:

Failures:

  1) Daru::DataFrame categorical #to_category can add_row after to_category
     Failure/Error: (new_index.size - @index.size).times { @data << val }

     NoMethodError:
       undefined method `<<' for nil:NilClass
     # ./lib/daru/vector.rb:1574:in `block in insert_vector'
     # ./lib/daru/vector.rb:1574:in `times'
     # ./lib/daru/vector.rb:1574:in `insert_vector'
     # ./lib/daru/vector.rb:1587:in `set'
     # ./lib/daru/dataframe.rb:2350:in `block in insert_or_modify_row'
     # ./lib/daru/dataframe.rb:2349:in `each'
     # ./lib/daru/dataframe.rb:2349:in `each_with_index'
     # ./lib/daru/dataframe.rb:2349:in `insert_or_modify_row'
     # ./lib/daru/dataframe.rb:2172:in `dispatch_to_axis'
     # ./lib/daru/dataframe.rb:521:in `[]='
     # ./lib/daru/accessors/dataframe_by_row.rb:13:in `[]='
     # ./lib/daru/dataframe.rb:525:in `add_row'
     # ./spec/category_spec.rb:1610:in `block (3 levels) in <top (required)>'

the @data is nil after calling dv.to_category

I found this bug, but it is out of my knowledge of daru's source codes, I'm not sure how to fix it. Someone can fix it? Or point out some key tips I can have a try.

rainchen commented 6 years ago

cc @v0dro

rainchen commented 6 years ago

@zverok it's easy to see the code changes and CI failures using a PR. And as I mentioned, if someone can point out some key tips I can have a try. If some one get this bug fixed, I can close this PR.

v0dro commented 6 years ago

@rainchen can you also open an issue that talks of this issue? When people see a PR they assume that someone is working on it. Moreover they need to pull your branch for a very minor change when they just copy-paste the failing test from the issue. You can just paste the failing code in the issue and the error that you received along with that (unless of course you will be finishing this PR).

zverok commented 6 years ago

@v0dro I did it :) https://github.com/SciRuby/daru/issues/390

rainchen commented 6 years ago

@v0dro it's kind for the long explanation, I'm just being lazy :).

@zverok thx for the action :)

v0dro commented 6 years ago

Its just a few lines of code that you add to the issue instead of the specs.