-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#sum method breaks with Ruby 2.4 #44
Comments
@moveson how did you solve this? |
@mhluska I got no response from this issue, so I was forced to remove this gem. |
If you read the docs carefully you will notice there is a way of working with the gem without using the monkey patch approach which is what will solve your problem. Import refinements and include descriptive_statistics on the objects you want to use it on |
@thirtysixthspan This doesn't look like it's been solved. Is there anything blocking from pushing a PR and merging it? Is it blocked by supporting Ruby 2.4? |
@moveson You didn't used gem in the right way. require 'descriptive_statistics/safe'
data = []
data.extend(DescriptiveStatistics)
data.sum In that way everything works. |
With rake tasks I had to do the import inside the task block like: task my_task: :environment do
require 'word-to-markdown' # avoid it being auto loaded in other tasks This way I can safely work with rails 7 models in other tasks. Note, word-to-markdown uses |
Rails does some gymnastics to use the Enumerable#sum method built into Ruby 2.4+, and it falls back to the ActiveSupport Enumerable#sum method to handle situations in which the Ruby method doesn't handle it, such as an Array of Strings. Unfortunately, DescriptiveStatistics' #sum method gets in the way and breaks things when the Array is empty.
Using Ruby 2.4.2 and Rails 5.1.4 with descriptive_statistics 2.5.1:
See this post on StackOverflow for details.
The text was updated successfully, but these errors were encountered: