def test_nameIII_mixed(self): av_or_int = ["something integrated ob bla", "no averaging", "other averaged"] coord_name = "ensemble" res = _build_cell_methods(av_or_int, coord_name) self.assertEqual( res, [iris.coords.CellMethod("sum", "ensemble"), None, iris.coords.CellMethod("mean", "ensemble")] )
def test_no_averaging(self): av_or_int = [ 'No foo averaging', 'No bar averaging', 'no', '', 'no averaging', 'no anything at all averaging' ] coord_name = 'time' res = _build_cell_methods(av_or_int, coord_name) self.assertEqual(res, [None] * len(av_or_int))
def test_nameIII_mixed(self): av_or_int = ['something integrated ob bla', 'no averaging', 'other averaged'] coord_name = 'ensemble' res = _build_cell_methods(av_or_int, coord_name) self.assertEqual(res, [iris.coords.CellMethod('sum', 'ensemble'), None, iris.coords.CellMethod('mean', 'ensemble')])
def test_unrecognised(self): unrecognised_heading = "bla else" av_or_int = ["something average", unrecognised_heading, "something integral"] coord_name = "foo" with mock.patch("warnings.warn") as warn: res = _build_cell_methods(av_or_int, coord_name) expected_msg = "Unknown {} statistic: {!r}. Unable to " "create cell method.".format( coord_name, unrecognised_heading ) warn.assert_called_with(expected_msg)
def test_no_averaging(self): av_or_int = ['No foo averaging', 'No bar averaging', 'no', '', 'no averaging', 'no anything at all averaging'] coord_name = 'time' res = _build_cell_methods(av_or_int, coord_name) self.assertEqual(res, [None] * len(av_or_int))
def test_unrecognised(self): unrecognised_heading = 'bla else' av_or_int = ['something average', unrecognised_heading, 'something integral'] coord_name = 'foo' with mock.patch('warnings.warn') as warn: res = _build_cell_methods(av_or_int, coord_name) expected_msg = 'Unknown {} statistic: {!r}. Unable to ' \ 'create cell method.'.format(coord_name, unrecognised_heading) warn.assert_called_with(expected_msg)
def test_no_averaging(self): av_or_int = [ "No foo averaging", "No bar averaging", "no", "", "no averaging", "no anything at all averaging", ] coord_name = "time" res = _build_cell_methods(av_or_int, coord_name) self.assertEqual(res, [None] * len(av_or_int))
def test_unrecognised(self): unrecognised_heading = "bla else" av_or_int = [ "something average", unrecognised_heading, "something integral", ] coord_name = "foo" with mock.patch("warnings.warn") as warn: _ = _build_cell_methods(av_or_int, coord_name) expected_msg = ("Unknown {} statistic: {!r}. Unable to " "create cell method.".format(coord_name, unrecognised_heading)) warn.assert_called_with(expected_msg)
def test_nameIII_mixed(self): av_or_int = [ "something integrated ob bla", "no averaging", "other averaged", ] coord_name = "ensemble" res = _build_cell_methods(av_or_int, coord_name) self.assertEqual( res, [ iris.coords.CellMethod("sum", "ensemble"), None, iris.coords.CellMethod("mean", "ensemble"), ], )
def test_unrecognised_similar_to_no_averaging(self): unrecognised_headings = [ 'not averaging', 'this is not a valid no', 'nope', 'no daveraging', 'no averagingg', 'no something', 'noaveraging' ] for unrecognised_heading in unrecognised_headings: av_or_int = [ 'something average', unrecognised_heading, 'something integral' ] coord_name = 'foo' with mock.patch('warnings.warn') as warn: res = _build_cell_methods(av_or_int, coord_name) expected_msg = 'Unknown {} statistic: {!r}. Unable to ' \ 'create cell method.'.format(coord_name, unrecognised_heading) warn.assert_called_with(expected_msg)
def test_unrecognised_similar_to_no_averaging(self): unrecognised_headings = ['not averaging', 'this is not a valid no', 'nope', 'no daveraging', 'no averagingg', 'no something', 'noaveraging'] for unrecognised_heading in unrecognised_headings: av_or_int = ['something average', unrecognised_heading, 'something integral'] coord_name = 'foo' with mock.patch('warnings.warn') as warn: res = _build_cell_methods(av_or_int, coord_name) expected_msg = 'Unknown {} statistic: {!r}. Unable to ' \ 'create cell method.'.format(coord_name, unrecognised_heading) warn.assert_called_with(expected_msg)
def test_unrecognised_similar_to_no_averaging(self): unrecognised_headings = [ "not averaging", "this is not a valid no", "nope", "no daveraging", "no averagingg", "no something", "noaveraging", ] for unrecognised_heading in unrecognised_headings: av_or_int = ["something average", unrecognised_heading, "something integral"] coord_name = "foo" with mock.patch("warnings.warn") as warn: res = _build_cell_methods(av_or_int, coord_name) expected_msg = "Unknown {} statistic: {!r}. Unable to " "create cell method.".format( coord_name, unrecognised_heading ) warn.assert_called_with(expected_msg)
def test_unrecognised_similar_to_no_averaging(self): unrecognised_headings = [ "not averaging", "this is not a valid no", "nope", "no daveraging", "no averagingg", "no something", "noaveraging", ] for unrecognised_heading in unrecognised_headings: av_or_int = [ "something average", unrecognised_heading, "something integral", ] coord_name = "foo" with mock.patch("warnings.warn") as warn: _ = _build_cell_methods(av_or_int, coord_name) expected_msg = ("Unknown {} statistic: {!r}. Unable to " "create cell method.".format( coord_name, unrecognised_heading)) warn.assert_called_with(expected_msg)
def test_nameII_average(self): av_or_int = ['something average ob bla'] * 3 res = _build_cell_methods(av_or_int) iris.coords.CellMethod.assert_called('average', 'time')
def test_unrecognised(self): av_or_int = ['something average', 'something integral', 'bla else'] with self.assertRaises(iris.exceptions.TranslationError): res = _build_cell_methods(av_or_int)
def test_nameIII_integrated(self): av_or_int = ['something integrated ob bla'] coord_name = 'time' res = _build_cell_methods(av_or_int, coord_name) self.assertEqual(res, [iris.coords.CellMethod('sum', 'time')])
def test_nameIII_averaged(self): av_or_int = ['something averaged ob bla'] coord_name = 'bar' res = _build_cell_methods(av_or_int, coord_name) self.assertEqual(res, [iris.coords.CellMethod('mean', 'bar')])
def test_nameIII_averaged(self): av_or_int = ["something averaged ob bla"] coord_name = "bar" res = _build_cell_methods(av_or_int, coord_name) self.assertEqual(res, [iris.coords.CellMethod("mean", "bar")])
def test_nameIII_integrated(self): av_or_int = ["something integrated ob bla"] coord_name = "time" res = _build_cell_methods(av_or_int, coord_name) self.assertEqual(res, [iris.coords.CellMethod("sum", "time")])
def test_nameIII_integrated(self): av_or_int = ['something integrated ob bla'] * 3 coord_name = 'time' res = _build_cell_methods(av_or_int, coord_name) self.mock_CellMethod.assert_called('sum', coord_name)
def test_nameIII_averaged(self): av_or_int = ['something averaged ob bla'] * 3 coord_name = 'bar' res = _build_cell_methods(av_or_int, coord_name) self.mock_CellMethod.assert_called('average', coord_name)
def test_no_averaging(self): av_or_int = ["No foo averaging", "No bar averaging", "no", "", "no averaging", "no anything at all averaging"] coord_name = "time" res = _build_cell_methods(av_or_int, coord_name) self.assertEqual(res, [None] * len(av_or_int))
def test_nameIII_integrated(self): av_or_int = ['something integrated ob bla'] * 3 res = _build_cell_methods(av_or_int) iris.coords.CellMethod.assert_called('sum', 'time')