<commit_before>require 'spec_helper'

describe Average do

  let(:int_array) { [3,4,5] }

  let(:mixed_array) { [3, 4.0, 5, 2.0, 3, 1.0] }

  let(:mode_array) { [1,1,2,2,3,4] }

  let(:mode_mixed_array) { [1,1.0,2,2.0,3.0,4] }

  describe '#mean' do

    context 'with a array of integers' do
      it 'should calculate the correct mean' do
        expect(mean(int_array)).to eq(4)
      end
    end

    context 'with a mixed array of integers and floats' do
      it 'should calculate the correct mean' do
        expect(mean(mixed_array)).to eq(3)
      end
    end

  end

  describe '#median' do

    context 'with a array of integers' do
      it 'should calculate the correct median' do
        expect(median(int_array)).to eq(4)
      end
    end

    context 'with a mixed array of integers and floats' do
      it 'should calculate the correct median' do
        expect(median(mixed_array)).to eq(3)
      end
    end

    context 'with an empty array' do
      it 'should gives back a nil' do
        expect(median([])).to eq(nil)
      end
    end

  end

  describe '#mode' do

    context 'with a array of integers' do
      it 'should calculate the correct mode' do
        expect(mode(mode_array)).to eq([1, 2])
      end
    end

  end

  describe '#unique_mode' do

    context 'with a array of integers' do
      it 'should calculate the correct mode returning only one mode' do
        expect(unique_mode(mode_array)).to eq(1)
      end
    end

    context 'with a mixed array of integers and floats' do
      it 'should calculate the correct mode returning only one mode' do
        expect(unique_mode(mode_mixed_array)).to eq(1)
      end
    end

  end

  describe '#repetition_hash' do
    context 'should return a hash' do
      subject { repetition_hash(mode_array) }<commit_msg>deleted case for mode with moxed array<commit_after>require 'spec_helper'

describe Average do

  let(:int_array) { [3,4,5] }

  let(:mixed_array) { [3, 4.0, 5, 2.0, 3, 1.0] }

  let(:mode_array) { [1,1,2,2,3,4] }

  describe '#mean' do

    context 'with a array of integers' do
      it 'should calculate the correct mean' do
        expect(mean(int_array)).to eq(4)
      end
    end

    context 'with a mixed array of integers and floats' do
      it 'should calculate the correct mean' do
        expect(mean(mixed_array)).to eq(3)
      end
    end

  end

  describe '#median' do

    context 'with a array of integers' do
      it 'should calculate the correct median' do
        expect(median(int_array)).to eq(4)
      end
    end

    context 'with a mixed array of integers and floats' do
      it 'should calculate the correct median' do
        expect(median(mixed_array)).to eq(3)
      end
    end

    context 'with an empty array' do
      it 'should gives back a nil' do
        expect(median([])).to eq(nil)
      end
    end

  end

  describe '#mode' do

    context 'with a array of integers' do
      it 'should calculate the correct mode' do
        expect(mode(mode_array)).to eq([1, 2])
      end
    end

  end

  describe '#unique_mode' do

    context 'with a array of integers' do
      it 'should calculate the correct mode returning only one mode' do
        expect(unique_mode(mode_array)).to eq(1)
      end
    end

  end

  describe '#repetition_hash' do
    context 'should return a hash' do
      subject { repetition_hash(mode_array) }
{'fraction_non_alphanumeric': 0.09284447072738025, 'fraction_numerical': 0.017740981667652277, 'mean_word_length': 2.509336099585062, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '618329', 'n_tokens_mistral': 1134, 'n_tokens_neox': 1044, 'n_words': 391}