Skip to content

Commit 31d4ab5

Browse files
committed
Fix test skip condition for scikit-learn-extra tests
Problem: - Tests in test_intensity_label_filter.py were failing on macOS CI - The skip condition checked if import succeeded, but not if sklearn-extra was actually available - Functions imported successfully but raised ImportError when called Root Cause: - Test was checking: 'try: import functions; HAS_KMEDOIDS = True' - But functions exist even when sklearn-extra is missing - Functions check _HAS_KMEDOIDS internally and raise ImportError at runtime - Result: tests run when they should be skipped Solution: - Import _HAS_KMEDOIDS flag directly from the module - Use this flag for @pytest.mark.skipif decorator - Now tests properly skip when sklearn-extra is unavailable Testing: - All 171 tests still pass locally (with sklearn-extra installed) - Tests will now properly skip on CI if sklearn-extra is missing - Eliminates spurious failures on macOS GitHub Actions
1 parent a3c0f93 commit 31d4ab5

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

src/napari_tmidas/_tests/test_intensity_label_filter.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@
44
import numpy as np
55
import pytest
66

7-
# Try importing the functions - they may not be available if sklearn-extra is not installed
8-
try:
9-
from napari_tmidas.processing_functions.intensity_label_filter import (
10-
_calculate_label_mean_intensities,
11-
_cluster_intensities,
12-
_filter_labels_by_threshold,
13-
)
14-
15-
HAS_KMEDOIDS = True
16-
except ImportError:
17-
HAS_KMEDOIDS = False
7+
# Import the module and check if k-medoids is available
8+
from napari_tmidas.processing_functions.intensity_label_filter import (
9+
_HAS_KMEDOIDS,
10+
_calculate_label_mean_intensities,
11+
_cluster_intensities,
12+
_filter_labels_by_threshold,
13+
)
14+
15+
HAS_KMEDOIDS = _HAS_KMEDOIDS
1816

1917

2018
@pytest.mark.skipif(

0 commit comments

Comments
 (0)