<commit_before># -*- coding: utf8 -*-
__author__ = '<NAME>'
import unittest
from Spectrum import Spectrum
import numpy as np


class SpectrumTest(unittest.TestCase):
    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_operators(self):
        x = np.linspace(0, 10, 100)
        spectrum1 = Spectrum(x, np.sin(x))
        spectrum2 = Spectrum(x, np.sin(x))

        spectrum3 = spectrum1+spectrum2
        self.assertTrue(np.array_equal(spectrum3._y, np.sin(x)*2))
        self.assertTrue(np.array_equal(spectrum2._y, np.sin(x)*1))
        self.assertTrue(np.array_equal(spectrum1._y, np.sin(x)*1))

        spectrum3 = spectrum1+spectrum1
        self.assertTrue(np.array_equal(spectrum3._y, np.sin(x)*2))
        self.assertTrue(np.array_equal(spectrum1._y, np.sin(x)*1))
        self.assertTrue(np.array_equal(spectrum1._y, np.sin(x)*1))

        spectrum3 = spectrum2-spectrum1
        self.assertTrue(np.array_equal(spectrum3._y, np.sin(x)*0))
        self.assertTrue(np.array_equal(spectrum2._y, np.sin(x)*1))
        self.assertTrue(np.array_equal(spectrum1._y, np.sin(x)*1))

        spectrum3 = spectrum1-spectrum1
        self.assertTrue(np.array_equal(spectrum3._y, np.sin(x)*0))
        self.assertTrue(np.array_equal(spectrum1._y, np.sin(x)*1))
        self.assertTrue(np.array_equal(spectrum1._y, np.sin(x)*1))<commit_msg>implementing tests for spectrum operators<commit_after># -*- coding: utf8 -*-
__author__ = '<NAME>'
import unittest
from Spectrum import Spectrum
import numpy as np


class SpectrumTest(unittest.TestCase):
    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_plus_and_minus_operators(self):
        x = np.linspace(0, 10, 100)
        spectrum1 = Spectrum(x, np.sin(x))
        spectrum2 = Spectrum(x, np.sin(x))

        spectrum3 = spectrum1+spectrum2
        self.assertTrue(np.array_equal(spectrum3._y, np.sin(x)*2))
        self.assertTrue(np.array_equal(spectrum2._y, np.sin(x)*1))
        self.assertTrue(np.array_equal(spectrum1._y, np.sin(x)*1))

        spectrum3 = spectrum1+spectrum1
        self.assertTrue(np.array_equal(spectrum3._y, np.sin(x)*2))
        self.assertTrue(np.array_equal(spectrum1._y, np.sin(x)*1))
        self.assertTrue(np.array_equal(spectrum1._y, np.sin(x)*1))

        spectrum3 = spectrum2-spectrum1
        self.assertTrue(np.array_equal(spectrum3._y, np.sin(x)*0))
        self.assertTrue(np.array_equal(spectrum2._y, np.sin(x)*1))
        self.assertTrue(np.array_equal(spectrum1._y, np.sin(x)*1))

        spectrum3 = spectrum1-spectrum1
        self.assertTrue(np.array_equal(spectrum3._y, np.sin(x)*0))
        self.assertTrue(np.array_equal(spectrum1._y, np.sin(x)*1))
        self.assertTrue(np.array_equal(spectrum1._y, np.sin(x)*1))

    def test_multiply_operator(self):
        x = np.linspace(0, 10, 100)
        spectrum1 = 2*Spectrum(x, np.sin(x))

        spectrum2 = 2*Spectrum(x, np.sin(x))

        self.assertTrue(np.array_equal(spectrum2._y, np.sin(x)*2))
{'fraction_non_alphanumeric': 0.14550878355982763, 'fraction_numerical': 0.03380841895923102, 'mean_word_length': 3.2387640449438204, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6113811', 'n_tokens_mistral': 1109, 'n_tokens_neox': 1058, 'n_words': 151}