From b41e9c358e9b9e55cdad44ca8e097c027a6742f7 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Tue, 23 Jul 2024 17:20:04 +0100 Subject: [PATCH] update tests --- .../brainmapper/transform_widget.py | 3 ++- .../test_brainmapper/test_transform_widget.py | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/brainglobe_utils/brainmapper/transform_widget.py b/brainglobe_utils/brainmapper/transform_widget.py index 350d39d..09d071c 100644 --- a/brainglobe_utils/brainmapper/transform_widget.py +++ b/brainglobe_utils/brainmapper/transform_widget.py @@ -352,7 +352,8 @@ def run_transform_downsampled_points_to_atlas_space(self): display_info( self, "Points outside atlas", - f"{len(points_out_of_bounds)} fell outside the atlas space", + f"{len(points_out_of_bounds)} " + f"points fell outside the atlas space", ) def get_downsampled_space(self): diff --git a/tests/tests/test_brainmapper/test_transform_widget.py b/tests/tests/test_brainmapper/test_transform_widget.py index dd57506..5ef87d1 100644 --- a/tests/tests/test_brainmapper/test_transform_widget.py +++ b/tests/tests/test_brainmapper/test_transform_widget.py @@ -43,6 +43,14 @@ ] ) +points_outside_brain = np.array( + [ + [10000, 10000, 10000], + [100001, 100001, 100001], + ] +) + + points_in_downsampled_space = np.array( [ [10.0, 68.0, 105.0], @@ -264,6 +272,22 @@ def test_transform_points_to_atlas_space( ) +def test_transformation_raises_info_points_out_of_bounds( + transformation_widget_with_data, mock_display_info +): + points_layer = transformation_widget_with_data.viewer.add_points( + points_outside_brain + ) + transformation_widget_with_data.points_layer = points_layer + transformation_widget_with_data.run_transform_points_to_downsampled_space() + transformation_widget_with_data.run_transform_downsampled_points_to_atlas_space() + mock_display_info.assert_called_once_with( + transformation_widget_with_data, + "Points outside atlas", + "2 points fell outside the atlas space", + ) + + def test_check_layers(transformation_widget_with_data): assert transformation_widget_with_data.check_layers()