Skip to content

Commit 1bc291f

Browse files
committed
Testing for None since some functions may return this result. 🗻
1 parent 27401e2 commit 1bc291f

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

karabo/test/test_source_detection.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ def test_source_detection_plot(
5151
with tempfile.TemporaryDirectory() as tmpdir:
5252
detection.write_to_file(os.path.join(tmpdir, "detection.zip"))
5353

54-
img = detection.get_source_image()
54+
img: Image | None = detection.get_source_image()
55+
assert img is not None
56+
5557
imaging_npixel = img.header["NAXIS1"]
5658
imaging_cellsize = img.get_cellsize()
5759

@@ -197,6 +199,10 @@ def test_full_source_detection(
197199
detection_result = PyBDSFSourceDetectionResult.detect_sources_in_image(
198200
restored, thresh_isl=15, thresh_pix=20
199201
)
202+
203+
# detect_sources_in_image() may return None
204+
assert detection_result is not None
205+
200206
gtruth = np.array(
201207
[
202208
[981.74904041, 843.23261492],
@@ -219,6 +225,10 @@ def test_full_source_detection(
219225
detection_results = PyBDSFSourceDetectionResultList.detect_sources_in_images(
220226
restored_cuts, thresh_isl=15, thresh_pix=20
221227
)
228+
229+
# detect_sources_in_images() may return None
230+
assert detection_results is not None
231+
222232
detected = detection_results.get_pixel_position_of_sources()
223233
# Sometimes the order of the sources is different, so we need to sort them
224234
detected = detected[np.argsort(detected[:, 0])]
@@ -235,7 +245,7 @@ def test_create_detection_from_ms_cuda():
235245
phase_center + np.array([+5, +5]),
236246
100,
237247
200,
238-
0.4,
248+
1,
239249
)
240250

241251
telescope = Telescope.constructor("MeerKAT")
@@ -274,4 +284,5 @@ def test_create_detection_from_ms_cuda():
274284
residual.write_to_file(os.path.join(tmpdir, "residual.fits"))
275285

276286
result = PyBDSFSourceDetectionResult.detect_sources_in_image(restored)
287+
assert result is not None
277288
result.write_to_file(os.path.join(tmpdir, "sources.zip"))

0 commit comments

Comments
 (0)