Esempio n. 1
0
def test_functions():
    value = random.randint(-100, 100)
    value2 = random.randint(1, 100)
    assert round(c.sin(value)) == round(math.sin(
        value)), "Sin function is not working, you studied this in 10.."
    assert round(c.cos(value)) == round(math.cos(
        value)), "Cos function is not working, you studied this in 10.."
    assert round(c.tan(value)) == round(math.tan(
        value)), "Tan function is not working, you studied this in 10.."
    assert round(c.tanh(value)) == round(math.tanh(
        value)), "Tanh function is not working, you studied this in 10.."
    assert round(c.sigmoid(value)) == round(
        (1 / (1 + math.exp(-value))
         )), "Sigmoid function is not working, this is the basic of DNN.."
    assert round(c.relu(value)) == round(max(
        0, value)), "Relu function is not working, this is the basic of DNN,,"
    assert round(c.log(value2)) == round(math.log(
        value2)), "Log function is not working, you studied this in 10.."
    assert round(c.e(value)) == round(math.exp(
        value)), "Exp function is not working, you studied this in 10.."
    assert [
        0.0003282279149649954, 0.0024252944769113903, 0.01792063694632493,
        0.0008922159768423478, 0.9784336246849563
    ] == c.softmax([1, 3, 5, 2,
                    9]), "Softmax not working bro.. how will you make NN then"
Esempio n. 2
0
def test_all_function_check():
    import calculator
    assert calculator.sin(math.pi / 2) == 1
    assert calculator.cos(math.pi) == -1
    assert calculator.tan(0) == 0
    assert calculator.tanh(0) == 0
    assert calculator.softmax([1,
                               2]) == [0.2689414213699951, 0.7310585786300049]
    assert calculator.e(0) == 1
    assert calculator.log(10, base=10) == 1
    assert calculator.relu(10) == 10
    assert calculator.relu(-10) == 0
    assert calculator.sigmoid(0) == 0.5
def test_functions_e():
    
    assert math.exp(num) == calculator.e(num), 'E implementation failed'
Esempio n. 4
0
def test_e():
    assert math.exp(3) == calc.e(3), 'Check exp function'
Esempio n. 5
0
def test_exp():
    assert calculator.e(4) == exp(4)