Пример #1
0
 def test_intervals(self):
     self.section['timeIncrement'] = 3
     self.section['indicatorOfUnitForTimeIncrement'] = 1
     cell_method = statistical_cell_method(self.section)
     self.assertEqual(cell_method.method, 'mean')
     self.assertEqual(cell_method.coord_names, ('time',))
     self.assertEqual(cell_method.intervals, ('3 hours',))
 def test_intervals(self):
     self.section['timeIncrement'] = 3
     self.section['indicatorOfUnitForTimeIncrement'] = 1
     cell_method = statistical_cell_method(self.section)
     self.assertEqual(cell_method.method, 'mean')
     self.assertEqual(cell_method.coord_names, ('time', ))
     self.assertEqual(cell_method.intervals, ('3 hours', ))
Пример #3
0
 def test_pdt_15(self):
     # Encoded slightly differently to PDT 4.8.
     self.section['productDefinitionTemplateNumber'] = 15
     test_code = self.section['typeOfStatisticalProcessing']
     del self.section['typeOfStatisticalProcessing']
     self.section['statisticalProcess'] = test_code
     cell_method = statistical_cell_method(self.section)
     self.assertEqual(cell_method, self.expected_cell_method())
Пример #4
0
 def test_fail_multiple_ranges(self):
     self.section['numberOfTimeRange'] = 2
     with self.assertRaisesRegexp(TranslationError,
                                  'multiple time ranges \[2\]'):
         statistical_cell_method(self.section)
Пример #5
0
 def test_fail_bad_ranges(self):
     self.section['numberOfTimeRange'] = 0
     with self.assertRaisesRegexp(TranslationError,
                                  'aggregation over "0 time ranges"'):
         statistical_cell_method(self.section)
Пример #6
0
 def test_basic(self):
     cell_method = statistical_cell_method(self.section)
     self.assertEqual(cell_method.method, 'mean')
     self.assertEqual(cell_method.coord_names, ('time',))
     self.assertEqual(cell_method.intervals, ())
 def test_fail_bad_increment_type(self):
     self.section['typeOfTimeIncrement'] = 7
     with self.assertRaisesRegexp(
             TranslationError,
             'time-increment type \[7\] is not supported'):
         statistical_cell_method(self.section)
 def test_fail_unknown_statistic(self):
     self.section['typeOfStatisticalProcessing'] = 17
     with self.assertRaisesRegexp(
             TranslationError,
             'statistical process type \[17\] is not supported'):
         statistical_cell_method(self.section)
Пример #9
0
 def test_fail_unsupported_pdt(self):
     # Rejects PDTs other than the ones tested above.
     self.section['productDefinitionTemplateNumber'] = 101
     msg = "can't get statistical method for unsupported pdt : 4.101"
     with self.assertRaisesRegexp(ValueError, msg):
         statistical_cell_method(self.section)
 def test_fail_bad_ranges(self):
     self.section['numberOfTimeRange'] = 0
     with self.assertRaisesRegexp(TranslationError,
                                  'aggregation over "0 time ranges"'):
         statistical_cell_method(self.section)
 def test_basic(self):
     cell_method = statistical_cell_method(self.section)
     self.assertEqual(cell_method.method, 'mean')
     self.assertEqual(cell_method.coord_names, ('time', ))
     self.assertEqual(cell_method.intervals, ())
Пример #12
0
 def test_pdt_10(self):
     # Should behave the same as PDT 4.8.
     self.section['productDefinitionTemplateNumber'] = 10
     cell_method = statistical_cell_method(self.section)
     self.assertEqual(cell_method, self.expected_cell_method())
Пример #13
0
 def test_different_statistic(self):
     self.section['typeOfStatisticalProcessing'] = 6
     cell_method = statistical_cell_method(self.section)
     self.assertEqual(
         cell_method,
         self.expected_cell_method(method='standard_deviation'))
Пример #14
0
 def test_intervals(self):
     self.section['timeIncrement'] = 3
     self.section['indicatorOfUnitForTimeIncrement'] = 1
     cell_method = statistical_cell_method(self.section)
     self.assertEqual(cell_method,
                      self.expected_cell_method(intervals=('3 hours',)))
Пример #15
0
 def test_basic(self):
     cell_method = statistical_cell_method(self.section)
     self.assertEqual(cell_method, self.expected_cell_method())
Пример #16
0
 def test_fail_unknown_statistic(self):
     self.section['typeOfStatisticalProcessing'] = 17
     with self.assertRaisesRegexp(
             TranslationError,
             'statistical process type \[17\] is not supported'):
         statistical_cell_method(self.section)
Пример #17
0
 def test_fail_bad_increment_type(self):
     self.section['typeOfTimeIncrement'] = 7
     with self.assertRaisesRegexp(
             TranslationError,
             'time-increment type \[7\] is not supported'):
         statistical_cell_method(self.section)
 def test_fail_multiple_ranges(self):
     self.section['numberOfTimeRange'] = 2
     with self.assertRaisesRegexp(TranslationError,
                                  'multiple time ranges \[2\]'):
         statistical_cell_method(self.section)