def test_get_e_value():
    error = BackPropagationLogic.get_e_value(np.array([-1, 0, 1]), np.array([-1, 0, 1]))
    assert error == 0

    error = BackPropagationLogic.get_e_value(np.array([-1, 0, 1]), np.array([-1, 0, 0]))
    assert error == 0.5

    error = BackPropagationLogic.get_e_value(np.array([-1, 0, 1]), np.array([0, 0, 0]))
    assert error == 1.0

    error = BackPropagationLogic.get_e_value(np.array([-1, 0, 1]), np.array([0, 0]))
    assert error == None
def test_delta_for_output_layer():
    output_vec      = np.array([1])
    predict_vec     = np.array([1])
    error = BackPropagationLogic.delta_for_output_layer(output_vec, predict_vec)
    assert error == [0]

    output_vec      = np.array([1,2,3])
    predict_vec     = np.array([1,2,3])
    error = BackPropagationLogic.delta_for_output_layer(output_vec, predict_vec)
    assert np.all( error == np.array([0, 0, 0]))

    output_vec      = np.array([1,2,3])
    predict_vec     = np.array([1,2,2])
    error = BackPropagationLogic.delta_for_output_layer(output_vec, predict_vec)
    assert np.all( error == np.array([0, 0, 2]))


    output_vec      = np.array([[1,2,3],[1,2,3]])
    predict_vec     = np.array([[1,2,3],[1,2,3]])
    error = BackPropagationLogic.delta_for_output_layer(output_vec, predict_vec)
    assert np.all( error == np.array([[0, 0, 0],[0, 0, 0]]))
def test_delta_for_middle_layer():
    assert True

    next_wight_mat      = np.array([[1,1,1],[1,1,1],[1,1,1]])
    next_deleta_vec     = np.array([[0,0,0]])
    predict_vec         = np.array([[1,1,2]])
    error = BackPropagationLogic.delta_for_middle_layer(next_wight_mat, next_deleta_vec, predict_vec)

    assert np.all( error == np.array([0, 0, 0]))


    next_wight_mat      = np.array([[1,1,1],[1,1,1],[1,1,1]])
    next_deleta_vec     = np.array([[0,0,1]])
    predict_vec         = np.array([[1,1,2]])
    error = BackPropagationLogic.delta_for_middle_layer(next_wight_mat, next_deleta_vec, predict_vec)

    assert np.all( error == np.array([0, 0, -2]))

    next_wight_mat      = np.array([[1,1,1],[1,1,1],[1,1,1]])
    next_deleta_vec     = np.array([[0,1,0]])
    predict_vec         = np.array([[1,2,1]])
    error = BackPropagationLogic.delta_for_middle_layer(next_wight_mat, next_deleta_vec, predict_vec)

    assert np.all( error == np.array([0, -2, 0]))