Skip to content

Commit

Permalink
Add unit tests for euclidean()
Browse files Browse the repository at this point in the history
  • Loading branch information
mhostetter committed Nov 19, 2023
1 parent 4811531 commit 7b0fd32
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/measurements/test_euclidean.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import numpy as np
import pytest

import sdr

X = np.array([[6, 5, 0, 0, 5], [0, 1, 5, 0, 3], [4, 3, 3, 0, 5]])
Y = np.array([[7, 5, 2, 4, 0], [0, 0, 4, 1, 5], [5, 0, 7, 5, 6]])


def test_axis_none():
d = sdr.euclidean(X, Y)
assert d.shape == ()
assert d == pytest.approx(10.246950765959598)


def test_axis_0():
d = sdr.euclidean(X, Y, axis=0)
assert d.shape == (5,)
assert np.allclose(d, [1.41421356, 3.16227766, 4.58257569, 6.4807407, 5.47722558])


def test_axis_1():
d = sdr.euclidean(X, Y, axis=1)
assert d.shape == (3,)
assert np.allclose(d, [6.78232998, 2.64575131, 7.21110255])

0 comments on commit 7b0fd32

Please sign in to comment.