def _simulate_with_coords(self, names, values, dimensions): header = mock.MagicMock() column_headings = {'Species': [1, 2, 3], 'Quantity': [4, 5, 6], "Unit": ['m', 'm', 'm'], 'Z': [1, 2, 3]} coords = [NAMECoord(name, dim, vals) for name, vals, dim in zip(names, values, dimensions)] data_arrays = [mock.Mock()] self.patch('iris.fileformats.name_loaders._cf_height_from_name') self.patch('iris.cube.Cube') cubes = list(_generate_cubes(header, column_headings, coords, data_arrays)) return cubes
def _simulate_with_coords(self, names, values, dimensions): header = mock.MagicMock() column_headings = {'Species': [1, 2, 3], 'Quantity': [4, 5, 6], "Units": ['m', 'm', 'm'], 'Z': [1, 2, 3]} coords = [NAMECoord(name, dim, vals) for name, vals, dim in zip(names, values, dimensions)] data_arrays = [mock.Mock()] self.patch('iris.fileformats.name_loaders._cf_height_from_name') self.patch('iris.cube.Cube') cubes = list(_generate_cubes(header, column_headings, coords, data_arrays)) return cubes
def test_cell_methods(self): header = mock.MagicMock() column_headings = {'Species': [1, 2, 3], 'Quantity': [4, 5, 6], "Unit": ['m', 'm', 'm'], 'Z': [1, 2, 3]} coords = mock.MagicMock() data_arrays = [mock.Mock(), mock.Mock()] cell_methods = ["cell_method_1", "cell_method_2"] self.patch('iris.fileformats.name_loaders._cf_height_from_name') self.patch('iris.cube.Cube') cubes = list(_generate_cubes(header, column_headings, coords, data_arrays, cell_methods)) cubes[0].assert_has_calls([mock.call.add_cell_method('cell_method_1')]) cubes[1].assert_has_calls([mock.call.add_cell_method('cell_method_2')])
def test_cell_methods(self): header = mock.MagicMock() column_headings = {'Species': [1, 2, 3], 'Quantity': [4, 5, 6], "Unit": ['m', 'm', 'm'], 'Z': [1, 2, 3]} coords = mock.MagicMock() data_arrays = [mock.Mock(), mock.Mock()] cell_methods = ["cell_method_1", "cell_method_2"] with mock.patch('iris.fileformats.name_loaders._cf_height_from_name'): with mock.patch('iris.cube.Cube'): cubes = list(_generate_cubes(header, column_headings, coords, data_arrays, cell_methods)) cubes[0].assert_has_call(mock.call.add_cell_method('cell_method_1')) cubes[1].assert_has_call(mock.call.add_cell_method('cell_method_2'))
def _simulate_with_coords(self, names, values, dimensions): header = mock.MagicMock() column_headings = { "Species": [1, 2, 3], "Quantity": [4, 5, 6], "Units": ["m", "m", "m"], "Av or Int period": [timedelta(hours=24)], } coords = [ NAMECoord(name, dim, np.array(vals)) for name, vals, dim in zip(names, values, dimensions) ] data_arrays = [mock.Mock()] self.patch("iris.fileformats.name_loaders._cf_height_from_name") self.patch("iris.cube.Cube") cubes = list( _generate_cubes(header, column_headings, coords, data_arrays)) return cubes
def test_cell_methods(self): header = mock.MagicMock() column_headings = { "Species": [1, 2, 3], "Quantity": [4, 5, 6], "Units": ["m", "m", "m"], "Z": [1, 2, 3], } coords = mock.MagicMock() data_arrays = [mock.Mock(), mock.Mock()] cell_methods = ["cell_method_1", "cell_method_2"] self.patch("iris.fileformats.name_loaders._cf_height_from_name") self.patch("iris.cube.Cube") cubes = list( _generate_cubes(header, column_headings, coords, data_arrays, cell_methods)) cubes[0].assert_has_calls([mock.call.add_cell_method("cell_method_1")]) cubes[1].assert_has_calls([mock.call.add_cell_method("cell_method_2")])