示例#1
0
def test_euclidean_distance():
    x = np.asarray([1, 2])
    y = np.asarray([3, 4])

    dist = distance.euclidean_distance(x, y)

    assert dist == 2.8284271247461903
示例#2
0
def test_euclidean_distance():
    x = np.asarray([5.1, 3.5, 1.4, 0.3])
    y = np.asarray([5.4, 3.4, 1.7, 0.2])

    dist = distance.euclidean_distance(x, y)

    assert dist == 0.4472135954999584
import numpy as np

import opfython.math.distance as d

# Defining an array
x = np.asarray([2, 3, 4, 5])

# Defining an second array
y = np.asarray([1, 2, 3, 1])

# Calculating their distance
dist = d.euclidean_distance(x, y)

print(dist)