Example #1
0
def test_vincenty_decomposition():
    # Distancia a-->c <= a-->b + b-->c (metric='vincenty')
    p_a = [1, 1]
    p_b = [2, 2]
    p_c = [1, 2]
    dist_ab = distances.vincenty(np.array(p_a), np.array([p_b]), 2)
    dist_ac = distances.vincenty(np.array(p_a), np.array([p_c]), 2)
    dist_bc = distances.vincenty(np.array(p_b), np.array([p_c]), 2)
    assert dist_ac <= dist_ab + dist_bc
Example #2
0
def test_vincenty_simetric():
    # Distancia a-->b = b-->a (metric='vincenty')
    dist1 = distances.vincenty(c0=np.array([1, 1]),
                               centres=np.array([[2, 2]]),
                               dim=2)
    dist2 = distances.vincenty(c0=np.array([2, 2]),
                               centres=np.array([[1, 1]]),
                               dim=2)
    np.testing.assert_almost_equal(dist1, dist2, decimal=10)
Example #3
0
def test_vincenty_not_nan():
    # Distancias != NaN (metric='vincenty')
    random = np.random.RandomState(42)
    data = random.uniform(-10, 10, size=(10, 2))
    centre_0 = random.uniform(-10, 10, size=(2, ))
    dist = distances.vincenty(centre_0, data, 2)
    assert not np.isnan(dist).any()
Example #4
0
def test_vincenty_gt0():
    # Distancias >= 0 (metric='vincenty')
    random = np.random.RandomState(42)
    data = random.uniform(-10, 10, size=(10, 2))
    centre_0 = random.uniform(-10, 10, size=(2, ))
    dist = distances.vincenty(centre_0, data, 2)
    assert (dist >= 0).all()