def test_crop_data_removes_edge_data(self):
        go_data = GoData()
        array = np.arange(324.0).reshape((1, 18, 18))

        cropped_array = go_data.crop_data(array)

        assert np.array_equal(cropped_array, array[:, 8:10, 8:10])
Beispiel #2
0
    def test_crop_data_removes_edge_data(self):
        go_data = GoData()
        array = np.arange(324.0).reshape((1, 18, 18))

        cropped_array = go_data.crop_data(array)

        assert np.array_equal(cropped_array, array[:, 8:10, 8:10])
    def test_convert_mat_file_to_numpy_file_writes_extracted_numpys_to_files(self, mock_numpy_save, h5py_file_mock):
        go_data = GoData()
        go_data.convert_mat_data_to_numpy_array = Mock(side_effect=[1, 2])
        go_data.crop_data = lambda x: x

        go_data.convert_mat_file_to_numpy_file('')

        assert mock_numpy_save.call_args_list[0] == ((os.path.join('images_') + '.npy', 1),)
        assert mock_numpy_save.call_args_list[1] == ((os.path.join('depths_') + '.npy', 2),)
    def test_convert_mat_file_to_numpy_file_reads_the_mat_file(self, h5py_file_mock, mock_numpy_save):
        mat_file_name = 'fake name'
        go_data = GoData()
        go_data.crop_data = Mock()
        go_data.convert_mat_data_to_numpy_array = Mock()

        go_data.convert_mat_file_to_numpy_file(mat_file_name)

        assert h5py_file_mock.call_args == ((mat_file_name, 'r'),)
Beispiel #5
0
    def test_convert_mat_file_to_numpy_file_writes_extracted_numpys_to_files(self, mock_numpy_save, h5py_file_mock):
        go_data = GoData()
        go_data.convert_mat_data_to_numpy_array = Mock(side_effect=[1, 2])
        go_data.crop_data = lambda x: x

        go_data.convert_mat_file_to_numpy_file('')

        assert mock_numpy_save.call_args_list[0] == ((os.path.join('images_') + '.npy', 1),)
        assert mock_numpy_save.call_args_list[1] == ((os.path.join('depths_') + '.npy', 2),)
Beispiel #6
0
    def test_convert_mat_file_to_numpy_file_reads_the_mat_file(self, h5py_file_mock, mock_numpy_save):
        mat_file_name = 'fake name'
        go_data = GoData()
        go_data.crop_data = Mock()
        go_data.convert_mat_data_to_numpy_array = Mock()

        go_data.convert_mat_file_to_numpy_file(mat_file_name)

        assert h5py_file_mock.call_args == ((mat_file_name, 'r'),)
    def test_convert_mat_file_to_numpy_file_passes_can_be_called_on_a_specific_number_of_images(
            self, mock_numpy_save, h5py_file_mock):
        go_data = GoData()
        mock_convert = Mock()
        go_data.convert_mat_data_to_numpy_array = mock_convert
        go_data.crop_data = Mock()

        go_data.convert_mat_file_to_numpy_file('', number_of_samples=2)

        assert mock_convert.call_args[1]['number_of_samples'] == 2
    def test_convert_mat_file_to_numpy_file_passes_can_be_called_on_a_specific_number_of_images(self,
                                                                                                mock_numpy_save,
                                                                                                h5py_file_mock):
        go_data = GoData()
        mock_convert = Mock()
        go_data.convert_mat_data_to_numpy_array = mock_convert
        go_data.crop_data = Mock()

        go_data.convert_mat_file_to_numpy_file('', number_of_samples=2)

        assert mock_convert.call_args[1]['number_of_samples'] == 2
    def test_convert_mat_file_to_numpy_file_calls_extract_mat_data_to_numpy_array(self, h5py_file_mock,
                                                                                  mock_numpy_save):
        h5py_file_mock.return_value = 'fake mat data'
        go_data = GoData()
        go_data.convert_mat_data_to_numpy_array = Mock()
        go_data.crop_data = Mock()

        go_data.convert_mat_file_to_numpy_file('')

        assert go_data.convert_mat_data_to_numpy_array.call_args_list[1][0] == ('fake mat data', 'depths')
        assert go_data.convert_mat_data_to_numpy_array.call_args_list[0][0] == ('fake mat data', 'images')
Beispiel #10
0
    def test_convert_mat_file_to_numpy_file_calls_extract_mat_data_to_numpy_array(self, h5py_file_mock,
                                                                                  mock_numpy_save):
        h5py_file_mock.return_value = 'fake mat data'
        go_data = GoData()
        go_data.convert_mat_data_to_numpy_array = Mock()
        go_data.crop_data = Mock()

        go_data.convert_mat_file_to_numpy_file('')

        assert go_data.convert_mat_data_to_numpy_array.call_args_list[1][0] == ('fake mat data', 'depths')
        assert go_data.convert_mat_data_to_numpy_array.call_args_list[0][0] == ('fake mat data', 'images')