decisiontree icon indicating copy to clipboard operation
decisiontree copied to clipboard

Undefined method `sum'

Open ruby232 opened this issue 8 years ago • 6 comments

I'm try run examples/simple.rb in master but throw this error:

entropy': undefined method `sum' for [2, 3, 1]:Array (NoMethodError)

Try gem version 0.5.0 and work find, maybe it introduced in pull request #32

ruby232 avatar May 09 '17 15:05 ruby232

Fix add

require 'active_support'
require 'active_support/core_ext'

but i guess it not best solution

ruby232 avatar May 09 '17 16:05 ruby232

Guessing, you're on an older version of ruby?

This was introduced in https://github.com/igrigorik/decisiontree/commit/13aed0b2ae57e994e3366fedf15530d86c47bccd. /cc @cheerfulstoic

igrigorik avatar May 09 '17 17:05 igrigorik

My version of ruby is 2.3.1

└─ $ ▶ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]

ruby232 avatar May 09 '17 17:05 ruby232

Right, figures... Sum is 2.4+ http://blog.bigbinary.com/2016/11/02/ruby-2-4-introduces-enumerable-sum.html.

@cheerfulstoic I propose we revert the sum update until 2.3 is deprecated.

igrigorik avatar May 09 '17 18:05 igrigorik

Yep, sorry about that! Just created #34 and #35

cheerfulstoic avatar May 09 '17 20:05 cheerfulstoic

(Was editing in the UI and I couldn't see a way to do it in one PR)

cheerfulstoic avatar May 09 '17 20:05 cheerfulstoic