From 1206e9e594852f38f3317ceff9e67160c0768bff Mon Sep 17 00:00:00 2001 From: kienle <kienle@passcal.nmt.edu> Date: Thu, 29 Sep 2022 10:33:42 -0600 Subject: [PATCH] Add tests for chunk_minmax --- tests/test_model/test_handling_data.py | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/test_model/test_handling_data.py b/tests/test_model/test_handling_data.py index 8261d83e4..e387c4fc5 100644 --- a/tests/test_model/test_handling_data.py +++ b/tests/test_model/test_handling_data.py @@ -827,3 +827,30 @@ class TestDownsample(TestCase): # This ensures that we don't do two unneeded copy operations. self.assertIs(times, self.times) self.assertIs(data, self.data) + + +class TestChunkMinmax(TestCase): + def setUp(self): + self.times = np.arange(1000) + self.data = np.arange(1000) + + def test_data_size_is_multiple_of_requested_points(self): + req_points = 100 + times, data = chunk_minmax(self.times, self.data, req_points) + self.assertEqual(times.size, req_points) + self.assertEqual(data.size, req_points) + + @patch('sohstationviewer.model.handling_data.downsample', wraps=downsample) + def test_data_size_is_not_multiple_of_requested_points(self, + mock_downsample): + req_points = 102 + chunk_minmax(self.times, self.data, req_points) + self.assertTrue(mock_downsample.called) + + def test_requested_points_too_small(self): + small_req_points_list = [0, 1] + for req_points in small_req_points_list: + with self.subTest(f'test_requested_points_is_{req_points}'): + times, data = chunk_minmax(self.times, self.data, req_points) + self.assertEqual(times.size, 0) + self.assertEqual(data.size, 0) -- GitLab