SciRuby / daru

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

bugfix for Vector#proportions, make it return float value #385

Closed rainchen closed 6 years ago

rainchen commented 6 years ago

bugfix for Vector#proportions, make it return float value

v0dro commented 6 years ago

Tests aren't passing because you're using eq instead of be_within. Just make that change and I'll merge.

rainchen commented 6 years ago

@v0dro fixed and all tests passed.

But I'm aware that when using :gsl it will convert result into float values even the input value are integer, e.g.:

@dv = Daru::Vector.new [323, 11, 555, 666, 234, 21, 666, 343, 1, 2], dtype: :gsl

@dv.proportions 
# {323.0=>0.1, 11.0=>0.1, 555.0=>0.1, 666.0=>0.2, 234.0=>0.1, 21.0=>0.1, 343.0=>0.1, 1.0=>0.1, 2.0=>0.1}

This is unexpected for me.

rainchen commented 6 years ago

@v0dro all tests have passed

v0dro commented 6 years ago

Merging your PR but can you please open an issue pointing out the behavior displayed by GSL?

rainchen commented 6 years ago

@v0dro I'm not using GSL, not sure it's issue or not, although that behavior is unexpected for me.