Esempio n. 1
0
def test_coincidence_when_not_zero():
    for i in range(10):
        u = np.random.random(3)
        v = np.zeros(3)
        assert euclidean_dist(u, v) != 0


# def test_symmetry():
#     for i in range(10):
#         u = np.random.random(3)
#         v = np.random.random(3)
#         assert euclidean_dist(u, v) == euclidean_dist(v, u)

# def test_triangle():

#     u = np.random.random(3)
#     v = np.random.random(3)
#     w = np.random.random(3)
#     assert euclidean_dist(u, w) <= euclidean_dist(u, v) + euclidean_dist(v, w)

# def test_known1():
#     u = np.array([0])
#     v = np.array([3])
#     assert_almost_equal(euclidean_dist(u, v), 3)

# def test_known2():
#     u = np.array([0,0])
#     v = np.array([3, 4])
#     assert_almost_equal(euclidean_dist(u, v), 5)

# def test_known3():
#     u = np.array([0,0])
#     v = np.array([-3, -4])
#     assert_almost_equal(euclidean_dist(u, v), 5)
Esempio n. 2
0
 def potential_at(self, coord):
     COULOMB = 8.99 * 10**9  # N m²/C²
     r = euclidean_dist(self._coord, coord)
     q = self._charge
     if r == 0:
         return float('inf') if q >= 0 else float('-inf')
     return (COULOMB * q) / r
Esempio n. 3
0
def test_coincidence_when_not_zero():
     for i in range(10):
        u = np.random.random(3)
        v = np.zeros(3)
        assert euclidean_dist(u, v) != 0

# def test_symmetry():
#     for i in range(10):
#         u = np.random.random(3)
#         v = np.random.random(3)
#         assert euclidean_dist(u, v) == euclidean_dist(v, u)

# def test_triangle():
    
#     u = np.random.random(3)
#     v = np.random.random(3)
#     w = np.random.random(3)
#     assert euclidean_dist(u, w) <= euclidean_dist(u, v) + euclidean_dist(v, w)

# def test_known1():
#     u = np.array([0])
#     v = np.array([3])
#     assert_almost_equal(euclidean_dist(u, v), 3)

# def test_known2():
#     u = np.array([0,0])
#     v = np.array([3, 4])
#     assert_almost_equal(euclidean_dist(u, v), 5)

# def test_known3():
#     u = np.array([0,0])
#     v = np.array([-3, -4])
#     assert_almost_equal(euclidean_dist(u, v), 5)
def test_symmetry():
    u = np.random.random(3)
    v = np.random.random(3)
    assert euclidean_dist(u, v) == euclidean_dist(v, u)
def test_coincidence_when_not_zero():
    u = np.random.random(3)
    v = np.zeros(3)
    assert euclidean_dist(u, v) != 0
def test_coincidence_when_zero():
    u = np.zeros(3)
    v = np.zeros(3)
    assert euclidean_dist(u, v) == 0
Esempio n. 7
0
 def __abs__(self):
     return euclidean_dist(self._coord)
 def __abs__(self):
     return euclidean_dist(self._values, (0, 0, 0, 0))
def test_known3():
    u = np.array([0, 0])
    v = np.array([-3, -4])
    assert_almost_equal(euclidean_dist(u, v), 5)
def test_known3():
    u = np.array([0,0])
    v = np.array([-3, -4])
    assert_almost_equal(euclidean_dist(u, v), 5)
def test_known1():
    u = np.array([0])
    v = np.array([3])
    assert_almost_equal(euclidean_dist(u, v), 3)
def test_triangle():
    
    u = np.random.random(3)
    v = np.random.random(3)
    w = np.random.random(3)
    assert euclidean_dist(u, w) <= euclidean_dist(u, v) + euclidean_dist(v, w)
def test_symmetry():
    for i in range(10):
        u = np.random.random(3)
        v = np.random.random(3)
        assert euclidean_dist(u, v) == euclidean_dist(v, u)
def test_coincidence_when_not_zero():
     for i in range(10):
        u = np.random.random(3)
        v = np.zeros(3)
        assert euclidean_dist(u, v) != 0
def test_coincidence_when_zero():
    u = np.zeros(3)
    v = np.zeros(3)
    assert euclidean_dist(u, v) == 0
def test_triangle():
    u = np.random.random(3)
    v = np.random.random(3)
    w = np.random.random(3)
    assert euclidean_dist(u, w) <= euclidean_dist(u, v) + euclidean_dist(v, w)
def test_known1():
    u = np.array([0])
    v = np.array([3])
    assert_almost_equal(euclidean_dist(u, v), 3)
def test_non_negativity():
    for i in range(10):
        u = np.random.normal(3)
        v = np.random.normal(3)
        assert euclidean_dist(u, v) >= 0
def test_non_negativity():
    u = np.random.normal(3)
    v = np.random.normal(3)
    assert euclidean_dist(u, v) >= 0
 def distance_to(self, other):
     return euclidean_dist((self._x, self._y), (other._x, other._y))