コード例 #1
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")]
     )
コード例 #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))
コード例 #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')])
コード例 #4
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)
コード例 #5
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))
コード例 #6
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)
コード例 #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))
コード例 #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)
コード例 #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)
コード例 #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"),
         ],
     )
コード例 #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)
コード例 #12
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)
コード例 #13
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)
コード例 #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)
コード例 #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')
コード例 #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)
コード例 #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')])
コード例 #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')])
コード例 #19
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")])
コード例 #20
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")])
コード例 #21
0
 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)
コード例 #22
0
 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)
コード例 #23
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))
コード例 #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')
コード例 #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")])
コード例 #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")])