Exemplo n.º 1
0
def test_emd():
    xx = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
    cost = []

    for this_x in xx:
        for this_y in xx:
            cost.append(np.sqrt(sum((this_x - this_y) ** 2)))

    ee = emd.emd([0, 1, 0], [1, 0, 0], list(cost))
    npt.assert_almost_equal(ee, np.sqrt(2), decimal=5)
Exemplo n.º 2
0
def test_emd():
    xx = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
    cost = []

    for this_x in xx:
        for this_y in xx:
            cost.append(np.sqrt(sum((this_x - this_y)**2)))

    ee = emd.emd([0, 1, 0], [1, 0, 0], list(cost))
    npt.assert_almost_equal(ee, np.sqrt(2), decimal=5)