Calculate the distance between the two endpoints of two vectors without numpy. A vector is defined as a list, tuple, or numpy 1D array. >>> euclidean_distance_no_np((0, 0), (2, 2)) 2.8284271247461903 >>> euclidean_distance_no_np([1, 2, 3, 4], [5, 6, 7, 8]) 8.0
(vector_1: Vector, vector_2: Vector)
| 26 | |
| 27 | |
| 28 | def euclidean_distance_no_np(vector_1: Vector, vector_2: Vector) -> VectorOut: |
| 29 | """ |
| 30 | Calculate the distance between the two endpoints of two vectors without numpy. |
| 31 | A vector is defined as a list, tuple, or numpy 1D array. |
| 32 | >>> euclidean_distance_no_np((0, 0), (2, 2)) |
| 33 | 2.8284271247461903 |
| 34 | >>> euclidean_distance_no_np([1, 2, 3, 4], [5, 6, 7, 8]) |
| 35 | 8.0 |
| 36 | """ |
| 37 | return sum((v1 - v2) ** 2 for v1, v2 in zip(vector_1, vector_2)) ** (1 / 2) |
| 38 | |
| 39 | |
| 40 | if __name__ == "__main__": |
nothing calls this directly
no outgoing calls
no test coverage detected