Example #1
0
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
Example #2
0
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
Example #3
0
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
Example #4
0
def test_check_five():
    x = factorial(5)
    assert x == 120
Example #5
0
def test_check_string():
    try:
        x = factorial('x')
        assert False
    except TypeError as exception_out:
        assert True
Example #6
0
def test_factorial(n, result):
    assert factorial(n) == result
Example #7
0
def test_check_three():
    x = factorial(3)
    assert x == 6
Example #8
0
def test_check_dict():
    try:
        x = factorial({'a': 3, 'b': 4})
        assert False
    except TypeError as exception_out:
        assert True
Example #9
0
def test_negative():
    assert factorial(-5) == False
    def test_factorial(self):
        self.assertEqual(120, factorial(5))

        self.assertEqual(479001600, factorial(12))
Example #11
0
def test_check_float():
    try:
        x = factorial(3.141)
        assert False
    except TypeError as exception_out:
        assert True
Example #12
0
 def test_factorial_on_zero(self):
     self.assertEqual(factorial.factorial(0), 1)
Example #13
0
 def test_factorial_on_negative_number_raises_value_error(self):
     with self.assertRaises(ValueError):
         factorial.factorial(-1)
Example #14
0
    def test_factorial_on_random_number(self):
        number = random.randint(1,100)

        self.assertEqual(factorial.factorial(number), math.factorial(number))
Example #15
0
 def test_factorial(self):
     for n,f in [(1,1), (2,2), (3,6), (4, 24), (5,120)]:
         self.assertEqual(factorial.factorial(n), f)
Example #16
0
def test_zero():
    assert factorial(0) == 1
Example #17
0
def test_check_one():
    x = factorial(1)
    assert x == 1
Example #18
0
def get_div_mat(matrice, n):
    elevated_matrice = powering_mat(n, matrice, matrice)
    return div_matrice(factorial(n), elevated_matrice)
Example #19
0
def test_check_boolean():
    try:
        x = factorial(True)
        assert False
    except TypeError as exception_out:
        assert True
Example #20
0
def test_string():
    assert factorial("test") == False
Example #21
0
def test_check_list():
    try:
        x = factorial([1, 2, 3, 34])
        assert False
    except TypeError as exception_out:
        assert True
Example #22
0
def test_float():
    assert factorial(1.5) == False
Example #23
0
def test_check_two():
    x = factorial(2)
    assert x == 2
Example #24
0
def test_positive():
    assert factorial(4) == 24