43 lines
1.2 KiB
Ruby
43 lines
1.2 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe Rubella::Weighting::PerCount, '.parse' do
|
|
|
|
it "returns a Rubella::Storage object" do
|
|
input = []
|
|
# input = Rubella::Input::Base.new [] # Does not work atm FIX IT!
|
|
weighting = Rubella::Weighting::PerCount.new
|
|
|
|
expect(weighting.parse(input)).to be_instance_of(Rubella::Storage)
|
|
end
|
|
|
|
it "splits data in given amount of buckets" do
|
|
input = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
|
|
weighting = Rubella::Weighting::PerCount.new 7
|
|
|
|
storage = weighting.parse(input)
|
|
|
|
expect(storage.length).to eq(2)
|
|
expect(storage.dataset_length).to eq(7)
|
|
end
|
|
|
|
it "gives maximum intensity (1) to the maximum value" do
|
|
input = [1, 2, 1, 3, 1, 4, 10, 2, 1, 2, 3, 4, 2, 1]
|
|
weighting = Rubella::Weighting::PerCount.new 7
|
|
|
|
storage = weighting.parse(input)
|
|
|
|
expect(storage.data[0][6]).to eq(1.0)
|
|
end
|
|
|
|
it "computes the intensity on the maximum value" do
|
|
input = [1, 2, 1, 3, 1, 4, 5, 2, 1, 2, 3, 4, 2, 1]
|
|
weighting = Rubella::Weighting::PerCount.new 7
|
|
|
|
storage = weighting.parse(input)
|
|
|
|
expect(storage.data).to eq(
|
|
[[0.2, 0.4, 0.2, 0.6, 0.2, 0.8, 1.0], [0.4, 0.2, 0.4, 0.6, 0.8, 0.4, 0.2]]
|
|
)
|
|
end
|
|
|
|
end |