<commit_before>from __future__ import division

import unittest

import math

from complex_numbers import ComplexNumber


# Tests adapted from `problem-specifications//canonical-data.json` @ v1.3.0

class ComplexNumbersTest(unittest.TestCase):

    def test_real_part_of_a_purely_real_number(self):
        input_number = ComplexNumber(1, 0)
        self.assertEqual(input_number.real, 1)

    def test_real_part_of_a_purely_imaginary_number(self):
        input_number = ComplexNumber(0, 1)
        self.assertEqual(input_number.real, 0)

    def test_real_part_of_a_number_with_real_and_imaginary_part(self):
        input_number = ComplexNumber(1, 2)
        self.assertEqual(input_number.real, 1)

    def test_imaginary_part_of_a_purely_real_number(self):
        input_number = ComplexNumber(1, 0)
        self.assertEqual(input_number.imaginary, 0)

    def test_imaginary_part_of_a_purely_imaginary_number(self):
        input_number = ComplexNumber(0, 1)
        self.assertEqual(input_number.imaginary, 1)

    def test_imaginary_part_of_a_number_with_real_and_imaginary_part(self):
        input_number = ComplexNumber(1, 2)
        self.assertEqual(input_number.imaginary, 2)

    def test_equality_of_complex_numbers(self):
        self.assertEqual(ComplexNumber(1, 2), ComplexNumber(1, 2))

    def test_inequality_of_complex_numbers(self):
        self.assertNotEqual(ComplexNumber(1, 2), ComplexNumber(2, 1))

    def test_imaginary_unit(self):
        first_input = ComplexNumber(0, 1)
        second_input = ComplexNumber(0, 1)
        expected = ComplexNumber(-1, 0)
        self.assertEqual(first_input * second_input, expected)

    def test_add_purely_real_numbers(self):
        first_input = ComplexNumber(1, 0)
        second_input = ComplexNumber(2, 0)
        expected = ComplexNumber(3, 0)
        self.assertEqual(first_input + second_input, expected)

    def test_add_purely_imaginary_numbers(self):
        first_input = ComplexNumber(0, 1)
        second_input = ComplexNumber(0, 2)
        expected = ComplexNumber(0, 3)
        self.assertEqual(first_input + second_input, expected)

    def test_add_numbers_with_real_and_imaginary_part(self):
        first_input = ComplexNumber(1, 2)
        second_input = ComplexNumber(3, 4)
        expected = ComplexNumber(4, 6)
        self.assertEqual(first_input + second_input, expected)

    def test_subtract_purely_real_numbers(self):<commit_msg>test: handle different real and imaginary parts separately (#1837)<commit_after>from __future__ import division

import unittest

import math

from complex_numbers import ComplexNumber


# Tests adapted from `problem-specifications//canonical-data.json` @ v1.3.0

class ComplexNumbersTest(unittest.TestCase):

    def test_real_part_of_a_purely_real_number(self):
        input_number = ComplexNumber(1, 0)
        self.assertEqual(input_number.real, 1)

    def test_real_part_of_a_purely_imaginary_number(self):
        input_number = ComplexNumber(0, 1)
        self.assertEqual(input_number.real, 0)

    def test_real_part_of_a_number_with_real_and_imaginary_part(self):
        input_number = ComplexNumber(1, 2)
        self.assertEqual(input_number.real, 1)

    def test_imaginary_part_of_a_purely_real_number(self):
        input_number = ComplexNumber(1, 0)
        self.assertEqual(input_number.imaginary, 0)

    def test_imaginary_part_of_a_purely_imaginary_number(self):
        input_number = ComplexNumber(0, 1)
        self.assertEqual(input_number.imaginary, 1)

    def test_imaginary_part_of_a_number_with_real_and_imaginary_part(self):
        input_number = ComplexNumber(1, 2)
        self.assertEqual(input_number.imaginary, 2)

    def test_equality_of_complex_numbers(self):
        self.assertEqual(ComplexNumber(1, 2), ComplexNumber(1, 2))

    def test_inequality_of_complex_numbers(self):
        number = ComplexNumber(1, 2)
        number_different_real_part = ComplexNumber(2, 2)
        number_different_imaginary_part = ComplexNumber(1, 1)
        self.assertNotEqual(number, number_different_real_part)
        self.assertNotEqual(number, number_different_imaginary_part)

    def test_imaginary_unit(self):
        first_input = ComplexNumber(0, 1)
        second_input = ComplexNumber(0, 1)
        expected = ComplexNumber(-1, 0)
        self.assertEqual(first_input * second_input, expected)

    def test_add_purely_real_numbers(self):
        first_input = ComplexNumber(1, 0)
        second_input = ComplexNumber(2, 0)
        expected = ComplexNumber(3, 0)
        self.assertEqual(first_input + second_input, expected)

    def test_add_purely_imaginary_numbers(self):
        first_input = ComplexNumber(0, 1)
        second_input = ComplexNumber(0, 2)
        expected = ComplexNumber(0, 3)
        self.assertEqual(first_input + second_input, expected)

    def test_add_numbers_with_real_and_imaginary_part(self):
        first_input = ComplexNumber(1, 2)
        second_input = ComplexNumber(3, 4)
        expected = ComplexNumber(4, 6)
        self.assertEqual(first_input + second_input, expected)

    def test_subtract_purely_real_numbers(self):
{'fraction_non_alphanumeric': 0.08073322932917316, 'fraction_numerical': 0.0218408736349454, 'mean_word_length': 3.9412331406551058, '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': '6195604', 'n_tokens_mistral': 1706, 'n_tokens_neox': 1578, 'n_words': 278}