Sha256: 269868b3ee02506823d19dd32bca0569b30991cd3bbde6892d3431147de457e6

Contents?: true

Size: 591 Bytes

Versions: 27

Compression:

Stored size: 591 Bytes

Contents

require 'epitools/core_ext/array'

describe "Array#histogram" do

  it "does 1..10" do
    nums = (1..10).to_a
    nums.histogram(2).should == [ 5, 5 ]
    nums.histogram(5).should == [ 2, 2, 2, 2, 2 ]
  end

  it "does -10..10" do
    nums = (-9..10).to_a
    nums.histogram(2).should == [ 10, 10 ]
  end

  it "does floats" do
    nums = [0.12, 1.0, 2.2, 3.5, 4.7, 5.9, 6.6, 7.777, 8.898]
    nums.histogram(3).should == [3,3,3]
  end

  it "does ranges" do
    nums = (0..9).to_a
    nums.histogram(2, ranges: true).should == {
      0.0...4.5 => 5,
      4.5...9.0 => 5
    }
  end

end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
epitools-0.5.136 spec/histogram_spec.rb
epitools-0.5.134 spec/histogram_spec.rb
epitools-0.5.133 spec/histogram_spec.rb
epitools-0.5.131 spec/histogram_spec.rb
epitools-0.5.130 spec/histogram_spec.rb
epitools-0.5.129 spec/histogram_spec.rb
epitools-0.5.128 spec/histogram_spec.rb
epitools-0.5.126 spec/histogram_spec.rb
epitools-0.5.125 spec/histogram_spec.rb
epitools-0.5.124 spec/histogram_spec.rb
epitools-0.5.123 spec/histogram_spec.rb
epitools-0.5.122 spec/histogram_spec.rb
epitools-0.5.121 spec/histogram_spec.rb
epitools-0.5.119 spec/histogram_spec.rb
epitools-0.5.118 spec/histogram_spec.rb
epitools-0.5.116 spec/histogram_spec.rb
epitools-0.5.115 spec/histogram_spec.rb
epitools-0.5.114 spec/histogram_spec.rb
epitools-0.5.113 spec/histogram_spec.rb
epitools-0.5.112 spec/histogram_spec.rb