def sinh(matrice): result = deepcopy(matrice) for n in range(1, 50): next_mat = div_matrice(factorial((2 * n) + 1), powering_mat((2 * n + 1), matrice, matrice)) result = add_matrices(result, next_mat) return result
def cosh(matrice): result = basic_mat(matrice) for n in range(1, 50): next_mat = div_matrice(factorial(2 * n), powering_mat(2 * n, matrice, matrice)) result = add_matrices(result, next_mat) return result
def sin(matrice): result = deepcopy(matrice) for n in range(1, 50): next_mat = div_matrice(factorial(2 * n + 1) , powering_mat(2 * n + 1, matrice, matrice)) if n % 2 != 0: result = sub_matrices(result, next_mat) else: result = add_matrices(result, next_mat) return result
def test_check_five(): x = factorial(5) assert x == 120
def test_check_string(): try: x = factorial('x') assert False except TypeError as exception_out: assert True
def test_factorial(n, result): assert factorial(n) == result
def test_check_three(): x = factorial(3) assert x == 6
def test_check_dict(): try: x = factorial({'a': 3, 'b': 4}) assert False except TypeError as exception_out: assert True
def test_negative(): assert factorial(-5) == False
def test_factorial(self): self.assertEqual(120, factorial(5)) self.assertEqual(479001600, factorial(12))
def test_check_float(): try: x = factorial(3.141) assert False except TypeError as exception_out: assert True
def test_factorial_on_zero(self): self.assertEqual(factorial.factorial(0), 1)
def test_factorial_on_negative_number_raises_value_error(self): with self.assertRaises(ValueError): factorial.factorial(-1)
def test_factorial_on_random_number(self): number = random.randint(1,100) self.assertEqual(factorial.factorial(number), math.factorial(number))
def test_factorial(self): for n,f in [(1,1), (2,2), (3,6), (4, 24), (5,120)]: self.assertEqual(factorial.factorial(n), f)
def test_zero(): assert factorial(0) == 1
def test_check_one(): x = factorial(1) assert x == 1
def get_div_mat(matrice, n): elevated_matrice = powering_mat(n, matrice, matrice) return div_matrice(factorial(n), elevated_matrice)
def test_check_boolean(): try: x = factorial(True) assert False except TypeError as exception_out: assert True
def test_string(): assert factorial("test") == False
def test_check_list(): try: x = factorial([1, 2, 3, 34]) assert False except TypeError as exception_out: assert True
def test_float(): assert factorial(1.5) == False
def test_check_two(): x = factorial(2) assert x == 2
def test_positive(): assert factorial(4) == 24