MCPcopy
hub / github.com/TheAlgorithms/Python / euclidean

Function euclidean

computer_vision/haralick_descriptors.py:338–349  ·  view source on GitHub ↗

Simple method for calculating the euclidean distance between two points, with type np.ndarray. Example: >>> a = np.array([1, 0, -2]) >>> b = np.array([2, -1, 1]) >>> euclidean(a, b) 3.3166247903554

(point_1: np.ndarray, point_2: np.ndarray)

Source from the content-addressed store, hash-verified

336
337
338def euclidean(point_1: np.ndarray, point_2: np.ndarray) -> float:
339 """
340 Simple method for calculating the euclidean distance between two points,
341 with type np.ndarray.
342
343 Example:
344 >>> a = np.array([1, 0, -2])
345 >>> b = np.array([2, -1, 1])
346 >>> euclidean(a, b)
347 3.3166247903554
348 """
349 return float(np.sqrt(np.sum(np.square(point_1 - point_2))))
350
351
352def get_distances(descriptors: np.ndarray, base: int) -> list[tuple[int, float]]:

Callers 1

get_distancesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected