Skip to content

Commit 7eee534

Browse files
committed
refactor: remove unnecessary approximation in assertions
1 parent 773c298 commit 7eee534

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

tests/test_features.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def test_radius_and_diameter_stats(self):
8585
skeleton[3, 3] = 1
8686

8787
radius_matrix, stats = compute_radii(binary, skeleton)
88-
assert stats["mean_radius"] == pytest.approx(3.0)
88+
assert stats["mean_radius"] == 3
8989
assert radius_matrix.shape == binary.shape
9090
assert stats["mean_diameter"] == stats["mean_radius"] * 2.0
9191
assert stats["min_diameter"] == stats["min_radius"] * 2.0
@@ -155,8 +155,8 @@ def cross_features(
155155
)
156156

157157
def test_cross_shape_topology(self, cross_features):
158-
assert cross_features["num_endpoints"] == pytest.approx(4.0)
159-
assert cross_features["num_bifurcations"] == pytest.approx(1.0)
158+
assert cross_features["num_endpoints"] == 4
159+
assert cross_features["num_bifurcations"] == 1
160160

161161
def test_all_keys_present(self, cross_features):
162162
assert set(cross_features.keys()) == set(_EMPTY_FEATURES.keys())
@@ -218,8 +218,8 @@ def test_single_straight_line(self):
218218
features = extract_vessel_features(
219219
img, graph, branch_data, binary=img, include_fractal=False
220220
)
221-
assert features["num_nodes"] == pytest.approx(2.0)
222-
assert features["num_endpoints"] == pytest.approx(2.0)
221+
assert features["num_nodes"] == 2.0
222+
assert features["num_endpoints"] == 2.0
223223
assert features["total_length"] > 0
224224

225225
def test_empty_branch_data_returns_zeroes(
@@ -241,7 +241,7 @@ def test_hgu_is_total_length_over_num_endpoints(self):
241241
img, graph, branch_data, binary=img, include_fractal=False
242242
)
243243
expected_hgu = features["total_length"] / features["num_endpoints"]
244-
assert features["hgu"] == pytest.approx(expected_hgu)
244+
assert features["hgu"] == expected_hgu
245245

246246
def test_length_statistics_are_consistent(self, cross_features):
247247
assert (
@@ -259,7 +259,8 @@ def test_vessel_area_from_binary(
259259
simple_cross_branch_data,
260260
binary=simple_cross,
261261
)
262-
assert features["vessel_area"] == float(np.count_nonzero(simple_cross))
263-
assert features["vessel_area_fraction"] == pytest.approx(
264-
np.count_nonzero(simple_cross) / simple_cross.size
262+
assert features["vessel_area"] == np.count_nonzero(simple_cross)
263+
assert (
264+
features["vessel_area_fraction"]
265+
== np.count_nonzero(simple_cross) / simple_cross.size
265266
)

0 commit comments

Comments
 (0)