def test_number_eq(self): main_n = Number(3) n = Number(3) n2 = Number(2) n3 = 3 self.assertEqual(True, main_n == n) self.assertEqual(False, main_n == -n) self.assertEqual(False, main_n == n2) self.assertEqual(True, main_n == n3)
def test_chain_add(self): main_chain = Chain([1, 2, 3]) n = Number(4) result = main_chain + n result_latex = "1+2+3+4" result_value = 10 self.assertEqual(result.latex(), result_latex) self.assertEqual(result.evaluate(), result_value)
def test_number_mul(self): main_fr = Fraction(12, 2) n = Number(3) result = main_fr * n result_latex = "\\frac{12}{2} \\cdot 3" result_value = 18 self.assertEqual(result.latex(), result_latex) self.assertEqual(result.evaluate(), result_value)
def test_number_add(self): main_fr = Fraction(12,2) n = Number(3) result = main_fr + n result_latex = "\\frac{12}{2}+3" result_value = 9 self.assertEqual(result.latex(), result_latex) self.assertEqual(result.evaluate(), result_value)
def test_number_add(self): main_log = Logarithm(9, 3) n = Number(3) result = main_log + n result_latex = "log_{3}9+3" result_value = 5 self.assertEqual(result.latex(), result_latex) self.assertAlmostEqual(result.evaluate(), result_value)
def test_number_add(self): x = Variable("x", value=1) main_poly = SimplePoly([1, 2, 3], x) n = Number(3) result = main_poly + n result_latex = "1x^{2}+2x+3+3" result_value = 9 self.assertEqual(result.latex(), result_latex) self.assertEqual(result.evaluate(), result_value)
def test_block_eval(self): ch = Chain([Number(3), -Fraction(3, 2), Product([2, 2])]) self.assertEqual(ch.evaluate(), 5.5) ch2 = -ch self.assertEqual(ch2.evaluate(), -5.5)
def test_number_eq(self): main_v = Variable("z", 2) n = Number(3) self.assertEqual(False, main_v == n)
def test_basic_latex(self): c1 = ComplexNumber(Number(2), -Chain([2, -3])) self.assertEqual(c1.latex(), "2-(2-3)i")
def test_number_eq(self): main_chain = Chain([1, 2, 3]) n = Number(3) self.assertEqual(False, main_chain == n)
def test_basic_latex(self): c1 = ComplexNumber(Number(2), -Chain([2, -3])) self.assertEqual(c1.evaluate(), 2 + 1j)
def test_basic_latex(self): n = Number(5) self.assertEqual(n.latex(), "5") n2 = Number(-5) self.assertEqual(n2.latex(), "-5") n3 = Number(-5, sign=False) self.assertEqual(n3.latex(), "5") n4 = Number(4.5, sign=False) self.assertEqual(n4.latex(), "-4.5")
def test_block_latex(self): ch = Chain([Number(3), -Fraction(3, 2), Product([2, 2])]) self.assertEqual(ch.latex(), "3-\\frac{3}{2}+(2 \\cdot 2)") ch2 = -ch self.assertEqual(ch2.latex(), "-(3-\\frac{3}{2}+(2 \\cdot 2))")
def test_basic_eval(self): n = Number(5) self.assertEqual(n.evaluate(), 5) n2 = Number(-5) self.assertEqual(n2.evaluate(), -5) n3 = Number(-5, sign=False) self.assertEqual(n3.evaluate(), 5) n4 = Number(4.5, sign=False) self.assertEqual(n4.evaluate(), -4.5)
def test_number_eq(self): main_fr = Fraction(1, 2) n = Number(3) self.assertEqual(False, main_fr == n)
def test_number_eq(self): x = Variable("x") main_poly = SimplePoly([1, 2, 3], x) n = Number(3) self.assertEqual(False, main_poly == n)
def test_number_eq(self): main_p = Product([1,2,3]) n = Number(2) self.assertEqual(False, main_p == n)
def test_product_eq(self): main_n = Number(3) p = Product([1, 2, 3]) self.assertEqual(False, main_n == p)
def test_number_eq(self): main_lg = Logarithm(1,2) n = Number(3) self.assertEqual(False, main_lg == n)
def test_number_eq(self): main_cx = ComplexNumber(1, 2) n = Number(3) self.assertEqual(False, main_cx == n)