Exemple #1
0
    def setUp(self):
        self.source = Mock(spec=astrom.Source)
        self.source.num_readings.return_value = 2

        self.grid = CutoutGrid(self.source)

        self.cutout00 = Mock(spec=SourceCutout)
        self.cutout01 = Mock(spec=SourceCutout)
        self.cutout10 = Mock(spec=SourceCutout)
        self.cutout11 = Mock(spec=SourceCutout)

        self.grid.add_cutout(self.cutout00, 0, 0)
        self.grid.add_cutout(self.cutout01, 0, 1)
        self.grid.add_cutout(self.cutout10, 1, 0)
        self.grid.add_cutout(self.cutout11, 1, 1)
Exemple #2
0
class CutoutGridPrefilledTest(unittest.TestCase):
    def setUp(self):
        self.source = Mock(spec=astrom.Source)
        self.source.num_readings.return_value = 2

        self.grid = CutoutGrid(self.source)

        self.cutout00 = Mock(spec=SourceCutout)
        self.cutout01 = Mock(spec=SourceCutout)
        self.cutout10 = Mock(spec=SourceCutout)
        self.cutout11 = Mock(spec=SourceCutout)

        self.grid.add_cutout(self.cutout00, 0, 0)
        self.grid.add_cutout(self.cutout01, 0, 1)
        self.grid.add_cutout(self.cutout10, 1, 0)
        self.grid.add_cutout(self.cutout11, 1, 1)

    def test_added_cutouts_in_correct_location(self):
        assert_that(self.grid.get_cutout(0, 0), equal_to(self.cutout00))
        assert_that(self.grid.get_cutout(0, 1), equal_to(self.cutout01))
        assert_that(self.grid.get_cutout(1, 0), equal_to(self.cutout10))
        assert_that(self.grid.get_cutout(1, 1), equal_to(self.cutout11))

    def test_apply_function(self):
        function = Mock()

        self.grid.apply(function)

        assert_that(function.call_args_list, contains(
            call(self.cutout00, 0, 0),
            call(self.cutout01, 0, 1),
            call(self.cutout10, 1, 0),
            call(self.cutout11, 1, 1)))

    def test_reset_source_location(self):
        self.grid.reset_source_location()

        self.cutout00.reset_source_location.called_once_with()
        self.cutout01.reset_source_location.called_once_with()
        self.cutout10.reset_source_location.called_once_with()
        self.cutout11.reset_source_location.called_once_with()
Exemple #3
0
class CutoutGridPrefilledTest(unittest.TestCase):
    def setUp(self):
        self.source = Mock(spec=astrom.Source)
        self.source.num_readings.return_value = 2

        self.grid = CutoutGrid(self.source)

        self.cutout00 = Mock(spec=SourceCutout)
        self.cutout01 = Mock(spec=SourceCutout)
        self.cutout10 = Mock(spec=SourceCutout)
        self.cutout11 = Mock(spec=SourceCutout)

        self.grid.add_cutout(self.cutout00, 0, 0)
        self.grid.add_cutout(self.cutout01, 0, 1)
        self.grid.add_cutout(self.cutout10, 1, 0)
        self.grid.add_cutout(self.cutout11, 1, 1)

    def test_added_cutouts_in_correct_location(self):
        assert_that(self.grid.get_cutout(0, 0), equal_to(self.cutout00))
        assert_that(self.grid.get_cutout(0, 1), equal_to(self.cutout01))
        assert_that(self.grid.get_cutout(1, 0), equal_to(self.cutout10))
        assert_that(self.grid.get_cutout(1, 1), equal_to(self.cutout11))

    def test_apply_function(self):
        function = Mock()

        self.grid.apply(function)

        assert_that(
            function.call_args_list,
            contains(call(self.cutout00, 0, 0), call(self.cutout01, 0, 1),
                     call(self.cutout10, 1, 0), call(self.cutout11, 1, 1)))

    def test_reset_source_location(self):
        self.grid.reset_source_location()

        self.cutout00.reset_source_location.called_once_with()
        self.cutout01.reset_source_location.called_once_with()
        self.cutout10.reset_source_location.called_once_with()
        self.cutout11.reset_source_location.called_once_with()
Exemple #4
0
    def setUp(self):
        self.source = Mock(spec=astrom.Source)
        self.source.num_readings.return_value = 2

        self.grid = CutoutGrid(self.source)

        self.cutout00 = Mock(spec=SourceCutout)
        self.cutout01 = Mock(spec=SourceCutout)
        self.cutout10 = Mock(spec=SourceCutout)
        self.cutout11 = Mock(spec=SourceCutout)

        self.grid.add_cutout(self.cutout00, 0, 0)
        self.grid.add_cutout(self.cutout01, 0, 1)
        self.grid.add_cutout(self.cutout10, 1, 0)
        self.grid.add_cutout(self.cutout11, 1, 1)
Exemple #5
0
    def test_is_filled(self):
        source = Mock(spec=astrom.Source)
        source.num_readings.return_value = 2

        grid = CutoutGrid(source)

        def add_cutout(frame_index, time_index):
            grid.add_cutout(Mock(spec=SourceCutout), frame_index, time_index)

        assert_that(grid.is_filled(), equal_to(False))

        add_cutout(0, 0)
        assert_that(grid.is_filled(), equal_to(False))
        add_cutout(1, 0)
        assert_that(grid.is_filled(), equal_to(False))
        add_cutout(1, 1)
        assert_that(grid.is_filled(), equal_to(False))
        add_cutout(0, 1)
        assert_that(grid.is_filled(), equal_to(True))
Exemple #6
0
    def test_is_filled(self):
        source = Mock(spec=astrom.Source)
        source.num_readings.return_value = 2

        grid = CutoutGrid(source)

        def add_cutout(frame_index, time_index):
            grid.add_cutout(Mock(spec=SourceCutout), frame_index, time_index)

        assert_that(grid.is_filled(), equal_to(False))

        add_cutout(0, 0)
        assert_that(grid.is_filled(), equal_to(False))
        add_cutout(1, 0)
        assert_that(grid.is_filled(), equal_to(False))
        add_cutout(1, 1)
        assert_that(grid.is_filled(), equal_to(False))
        add_cutout(0, 1)
        assert_that(grid.is_filled(), equal_to(True))
Exemple #7
0
    def setUp(self):
        source = Mock(spec=astrom.Source)
        source.num_readings.return_value = 3

        def mock_hdulist():
            return MagicMock(spec=HDUList)

        grid = CutoutGrid(source)
        self.hdulist00 = mock_hdulist()
        self.hdulist01 = mock_hdulist()
        self.hdulist02 = mock_hdulist()
        self.hdulist10 = mock_hdulist()
        self.hdulist11 = mock_hdulist()
        self.hdulist12 = mock_hdulist()
        self.hdulist20 = mock_hdulist()
        self.hdulist21 = mock_hdulist()
        self.hdulist22 = mock_hdulist()

        def mock_cutout(hdulist):
            cutout = Mock(spec=SourceCutout)
            cutout.hdulist = hdulist
            return cutout

        grid.add_cutout(mock_cutout(self.hdulist00), 0, 0)
        grid.add_cutout(mock_cutout(self.hdulist01), 0, 1)
        grid.add_cutout(mock_cutout(self.hdulist02), 0, 2)
        grid.add_cutout(mock_cutout(self.hdulist10), 1, 0)
        grid.add_cutout(mock_cutout(self.hdulist11), 1, 1)
        grid.add_cutout(mock_cutout(self.hdulist12), 1, 2)
        grid.add_cutout(mock_cutout(self.hdulist20), 2, 0)
        grid.add_cutout(mock_cutout(self.hdulist21), 2, 1)
        grid.add_cutout(mock_cutout(self.hdulist22), 2, 2)

        self.grid = grid
Exemple #8
0
    def setUp(self):
        source = Mock(spec=astrom.Source)
        source.num_readings.return_value = 3

        def mock_hdulist():
            return MagicMock(spec=HDUList)

        grid = CutoutGrid(source)
        self.hdulist00 = mock_hdulist()
        self.hdulist01 = mock_hdulist()
        self.hdulist02 = mock_hdulist()
        self.hdulist10 = mock_hdulist()
        self.hdulist11 = mock_hdulist()
        self.hdulist12 = mock_hdulist()
        self.hdulist20 = mock_hdulist()
        self.hdulist21 = mock_hdulist()
        self.hdulist22 = mock_hdulist()

        def mock_cutout(hdulist):
            cutout = Mock(spec=SourceCutout)
            cutout.hdulist = hdulist
            return cutout

        grid.add_cutout(mock_cutout(self.hdulist00), 0, 0)
        grid.add_cutout(mock_cutout(self.hdulist01), 0, 1)
        grid.add_cutout(mock_cutout(self.hdulist02), 0, 2)
        grid.add_cutout(mock_cutout(self.hdulist10), 1, 0)
        grid.add_cutout(mock_cutout(self.hdulist11), 1, 1)
        grid.add_cutout(mock_cutout(self.hdulist12), 1, 2)
        grid.add_cutout(mock_cutout(self.hdulist20), 2, 0)
        grid.add_cutout(mock_cutout(self.hdulist21), 2, 1)
        grid.add_cutout(mock_cutout(self.hdulist22), 2, 2)

        self.grid = grid