SciRuby / daru

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

Issue 391 vector sum skipnil #400

Closed parthm closed 6 years ago

parthm commented 6 years ago

Adds support for skipnil flag as discussed in issue #391 . There is some common code between add_skipnil and v2v_binary but I decided to keep these two separate to avoid performance penalty for all binary operation to support one scenario of vector_sum with skipnil. Suggestions welcome.

parthm commented 6 years ago

Ha ha. Didn't realize @baarkerlounger had created a PR for the same request. Perhaps @zverok and @v0dro can merge one. I am OK if the other PR #398 is merged.

In case this one is to be merged, please let me know, I would like to add documentation for add_skipnil. In the process of fixing this I realized that vector addition v0 + v1 suffers from this issue. So having a public method add_skipnil can give users an option to add two vectors. v0.add_skipnil v1.

parthm commented 6 years ago

Weird failure on Ruby 2.0 travis.

     Failure/Error: @cat_hash = categories.map { |cat, group| [cat, group.map(&:last)] }.to_h
     NoMethodError:
       undefined method `to_h' for [[:a, [0, 2]], [1, [1, 3]], [:c, [4]]]:Array

Anyone knows what that is? Looks like PR #387 is also seeing the same error.

baarkerlounger commented 6 years ago

@parthm it's the removal of backports completely in @zverok's PR. I fixed it here #398 by just requiring the specific backport needed.

baarkerlounger commented 6 years ago

Since this looks to be a better solution I'll close my PR.