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

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

        self.assertEqual(factorial.factorial(number), math.factorial(number))
Ejemplo n.º 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)
Ejemplo n.º 16
0
def test_zero():
    assert factorial(0) == 1
Ejemplo n.º 17
0
def test_check_one():
    x = factorial(1)
    assert x == 1
Ejemplo n.º 18
0
def get_div_mat(matrice, n):
    elevated_matrice = powering_mat(n, matrice, matrice)
    return div_matrice(factorial(n), elevated_matrice)
Ejemplo n.º 19
0
def test_check_boolean():
    try:
        x = factorial(True)
        assert False
    except TypeError as exception_out:
        assert True
Ejemplo n.º 20
0
def test_string():
    assert factorial("test") == False
Ejemplo n.º 21
0
def test_check_list():
    try:
        x = factorial([1, 2, 3, 34])
        assert False
    except TypeError as exception_out:
        assert True
Ejemplo n.º 22
0
def test_float():
    assert factorial(1.5) == False
Ejemplo n.º 23
0
def test_check_two():
    x = factorial(2)
    assert x == 2
Ejemplo n.º 24
0
def test_positive():
    assert factorial(4) == 24