Skip to content

Commit

Permalink
Fix test errors
Browse files Browse the repository at this point in the history
This commit adds the slow_generation decorator where appropriate to
disable the health checks for tests where data generation is slow.
Additionally, delete the view that is created from plot_ortho for memory
considerations (`close()` is not a valid command for these views).
  • Loading branch information
kaitj committed Dec 6, 2023
1 parent 4bcfe06 commit 7c8cc94
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion afids_utils/tests/test_afids.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
AfidSet,
)
from afids_utils.exceptions import InvalidFiducialError, InvalidFileError
from afids_utils.tests.helpers import allow_function_scoped
from afids_utils.tests.helpers import allow_function_scoped, slow_generation


@pytest.fixture
Expand Down Expand Up @@ -79,6 +79,7 @@ class TestAfidSet:
coord_system=st.sampled_from(["RAS", "LPS", "0", "1"]),
positions=af_st.position_lists(),
)
@slow_generation
def test_valid_afid_set(
self,
slicer_version: str,
Expand Down Expand Up @@ -117,6 +118,7 @@ def test_incomplete_afid_set(
coord_system=st.sampled_from(["RAS", "LPS", "0", "1"]),
positions=af_st.position_lists(unique=False),
)
@slow_generation
def test_repeated_afid_set(
self,
slicer_version: str,
Expand Down Expand Up @@ -417,6 +419,7 @@ def test_valid_afid_set(self, afid_set1: AfidSet, afid_set2: AfidSet):
afid_set1=af_st.afid_sets(randomize_header=False),
afid_set2=af_st.afid_sets(randomize_header=False),
)
@slow_generation
def test_mismatched_coords(self, afid_set1: AfidSet, afid_set2: AfidSet):
# Manually mismatch the coord system due to slow data generation
afid_set2.coord_system = "LPS"
Expand Down
2 changes: 2 additions & 0 deletions afids_utils/tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import afids_utils.metrics as af_metrics
import afids_utils.tests.strategies as af_st
from afids_utils.afids import AfidPosition, AfidSet
from afids_utils.tests.helpers import slow_generation


class TestMeanAfidSet:
Expand All @@ -26,6 +27,7 @@ def test_mismatched_coords(self, afid_set1: AfidSet):
@given(
afid_set1=af_st.afid_sets(randomize_header=False),
)
@slow_generation
def test_valid_afid_sets(self, afid_set1: AfidSet):
mean_afid_set = af_metrics.mean_afid_sets([afid_set1, afid_set1])

Expand Down
8 changes: 4 additions & 4 deletions afids_utils/tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_plot_ortho_afid_voxel(
afid_nii=template_t1w,
)
assert isinstance(view, StatMapView)
view.close() # pyright: ignore
del view

Check warning on line 77 in afids_utils/tests/test_plotting.py

View check run for this annotation

Codecov / codecov/patch

afids_utils/tests/test_plotting.py#L77

Added line #L77 was not covered by tests

@given(afid_voxels=af_st.afid_voxels())
@af_helpers.allow_function_scoped_deadline(time=None)
Expand All @@ -98,7 +98,7 @@ def test_plot_ortho_afid_voxels(
afid_nii=template_t1w,
)
assert isinstance(view, StatMapView)
view.close() # pyright: ignore
del view

@given(afid_positions=af_st.afid_positions())
@af_helpers.allow_function_scoped_deadline(time=None)
Expand All @@ -117,7 +117,7 @@ def test_plot_ortho_afid_position(
afid_nii=template_t1w,
)
assert isinstance(view, StatMapView)
view.close() # pyright: ignore
del view

@given(afid_positions=af_st.afid_positions())
@af_helpers.allow_function_scoped_deadline(time=None)
Expand All @@ -141,7 +141,7 @@ def test_plot_ortho_afid_positions(
afid_nii=template_t1w,
)
assert isinstance(view, StatMapView)
view.close() # pyright: ignore
del view


class TestPlotConnectome:
Expand Down

0 comments on commit 7c8cc94

Please sign in to comment.