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")]
     )
Beispiel #2
0
 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))
Beispiel #3
0
 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)
Beispiel #7
0
 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))
Beispiel #8
0
 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)
Beispiel #9
0
 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)
Beispiel #10
0
 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"),
         ],
     )
Beispiel #11
0
 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)
Beispiel #14
0
 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)
Beispiel #15
0
 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')
Beispiel #16
0
 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)
Beispiel #17
0
 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')])
Beispiel #18
0
 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))
Beispiel #24
0
 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')
Beispiel #25
0
 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")])
Beispiel #26
0
 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")])