示例#1
0
 def test_mdtol_intermediate(self):
     # mdtol=0.5 --> masked columns = [0, 0, 1, 1]
     agg = MEAN.lazy_aggregate(self.array, axis=self.axis, mdtol=0.5)
     masked_result = as_concrete_data(agg)
     expected_masked = self.expected_masked
     expected_masked.mask = [False, False, True, True]
     self.assertMaskedArrayAlmostEqual(masked_result, expected_masked)
示例#2
0
 def test_mdtol_aboveall(self):
     # mdtol=0.75 --> masked columns = [0, 0, 0, 1]
     # In this case, effectively the same as mdtol=None.
     agg = MEAN.lazy_aggregate(self.array, axis=self.axis, mdtol=0.75)
     masked_result = as_concrete_data(agg)
     self.assertMaskedArrayAlmostEqual(masked_result,
                                       self.expected_masked)
示例#3
0
 def test_mdtol_default(self):
     # Default operation is "mdtol=1" --> unmasked if *any* valid points.
     # --> output column masks = [0, 0, 0, 1]
     agg = MEAN.lazy_aggregate(self.array, axis=self.axis)
     masked_result = as_concrete_data(agg)
     self.assertMaskedArrayAlmostEqual(masked_result,
                                       self.expected_masked)
示例#4
0
 def test_mdtol_default(self):
     # Default operation is "mdtol=1" --> unmasked if *any* valid points.
     # --> output column masks = [0, 0, 0, 1]
     agg = MEAN.lazy_aggregate(self.array, axis=self.axis)
     masked_result = as_concrete_data(agg)
     self.assertMaskedArrayAlmostEqual(masked_result,
                                       self.expected_masked)
示例#5
0
 def test_mdtol_aboveall(self):
     # mdtol=0.75 --> masked columns = [0, 0, 0, 1]
     # In this case, effectively the same as mdtol=None.
     agg = MEAN.lazy_aggregate(self.array, axis=self.axis, mdtol=0.75)
     masked_result = as_concrete_data(agg)
     self.assertMaskedArrayAlmostEqual(masked_result,
                                       self.expected_masked)
示例#6
0
文件: test_MEAN.py 项目: cpelley/iris
 def test_mdtol_below(self):
     agg = MEAN.lazy_aggregate(self.array, axis=self.axis, mdtol=0.3)
     masked_result = as_concrete_data(agg, nans_replacement=ma.masked)
     expected_masked = self.expected_masked
     expected_masked.mask = [False, True, True, True]
     self.assertMaskedArrayAlmostEqual(masked_result,
                                       expected_masked)
示例#7
0
 def test_mdtol_intermediate(self):
     # mdtol=0.5 --> masked columns = [0, 0, 1, 1]
     agg = MEAN.lazy_aggregate(self.array, axis=self.axis, mdtol=0.5)
     masked_result = as_concrete_data(agg)
     expected_masked = self.expected_masked
     expected_masked.mask = [False, False, True, True]
     self.assertMaskedArrayAlmostEqual(masked_result, expected_masked)
示例#8
0
 def test_multi_axis(self):
     data = np.arange(24.0).reshape((2, 3, 4))
     collapse_axes = (0, 2)
     lazy_data = as_lazy_data(data)
     agg = MEAN.lazy_aggregate(lazy_data, axis=collapse_axes)
     result = as_concrete_data(agg)
     expected = np.mean(data, axis=collapse_axes)
     self.assertArrayAllClose(result, expected)
示例#9
0
文件: test_MEAN.py 项目: cpelley/iris
 def test_multi_axis(self):
     data = np.arange(24.0).reshape((2, 3, 4))
     collapse_axes = (0, 2)
     lazy_data = as_lazy_data(data)
     agg = MEAN.lazy_aggregate(lazy_data, axis=collapse_axes)
     result = as_concrete_data(agg, nans_replacement=ma.masked)
     expected = np.mean(data, axis=collapse_axes)
     self.assertArrayAllClose(result, expected)
示例#10
0
 def test_last_axis(self):
     # From setUp:
     # self.data.mask = [[0, 0, 0, 1],
     #                   [0, 0, 1, 1],
     #                   [0, 1, 1, 1]]
     # --> fractions of masked-points in ROWS = [1/4, 1/2, 3/4]
     axis = -1
     agg = MEAN.lazy_aggregate(self.array, axis=axis, mdtol=0.51)
     expected_masked = ma.mean(self.data, axis=-1)
     expected_masked = np.ma.masked_array(expected_masked, [0, 0, 1])
     masked_result = as_concrete_data(agg)
     self.assertMaskedArrayAlmostEqual(masked_result, expected_masked)
示例#11
0
 def test_last_axis(self):
     # From setUp:
     # self.data.mask = [[0, 0, 0, 1],
     #                   [0, 0, 1, 1],
     #                   [0, 1, 1, 1]]
     # --> fractions of masked-points in ROWS = [1/4, 1/2, 3/4]
     axis = -1
     agg = MEAN.lazy_aggregate(self.array, axis=axis, mdtol=0.51)
     expected_masked = ma.mean(self.data, axis=-1)
     expected_masked = np.ma.masked_array(expected_masked, [0, 0, 1])
     masked_result = as_concrete_data(agg)
     self.assertMaskedArrayAlmostEqual(masked_result,
                                       expected_masked)
示例#12
0
 def test_mdtol_above(self):
     agg = MEAN.lazy_aggregate(self.array, axis=self.axis, mdtol=0.4)
     masked_result = as_concrete_data(agg, nans_replacement=ma.masked)
     self.assertMaskedArrayAlmostEqual(masked_result, self.expected_masked)
示例#13
0
 def test_mdtol_below(self):
     agg = MEAN.lazy_aggregate(self.array, axis=self.axis, mdtol=0.3)
     masked_result = as_concrete_data(agg, nans_replacement=ma.masked)
     expected_masked = self.expected_masked
     expected_masked.mask = [False, True, True, True]
     self.assertMaskedArrayAlmostEqual(masked_result, expected_masked)
示例#14
0
 def test_mdtol_above(self):
     agg = MEAN.lazy_aggregate(self.array, axis=self.axis, mdtol=0.4)
     result = agg.masked_array()
     expected = ma.mean(self.data, axis=self.axis)
     self.assertMaskedArrayAlmostEqual(result, expected)
示例#15
0
 def test_all_axes_abovetol(self):
     agg = MEAN.lazy_aggregate(self.array, axis=None, mdtol=0.45)
     expected_masked = ma.masked_less([0.0], 1)
     masked_result = as_concrete_data(agg)
     self.assertMaskedArrayAlmostEqual(masked_result,
                                       expected_masked)
示例#16
0
 def test_mdtol_below(self):
     agg = MEAN.lazy_aggregate(self.array, axis=self.axis, mdtol=0.3)
     result = agg.masked_array()
     expected = ma.mean(self.data, axis=self.axis)
     expected.mask = [False, True, True, True]
     self.assertMaskedArrayAlmostEqual(result, expected)
示例#17
0
 def test_all_axes_belowtol(self):
     agg = MEAN.lazy_aggregate(self.array, axis=None, mdtol=0.75)
     expected_masked = ma.mean(self.data)
     masked_result = as_concrete_data(agg)
     self.assertMaskedArrayAlmostEqual(masked_result, expected_masked)
示例#18
0
文件: test_MEAN.py 项目: cpelley/iris
 def test_mdtol_above(self):
     agg = MEAN.lazy_aggregate(self.array, axis=self.axis, mdtol=0.4)
     masked_result = as_concrete_data(agg, nans_replacement=ma.masked)
     self.assertMaskedArrayAlmostEqual(masked_result,
                                       self.expected_masked)
示例#19
0
 def test_all_axes_abovetol(self):
     agg = MEAN.lazy_aggregate(self.array, axis=None, mdtol=0.45)
     expected_masked = ma.masked_less([0.0], 1)
     masked_result = as_concrete_data(agg)
     self.assertMaskedArrayAlmostEqual(masked_result, expected_masked)
示例#20
0
 def test_mdtol_below(self):
     agg = MEAN.lazy_aggregate(self.array, axis=self.axis, mdtol=0.3)
     result = agg.masked_array()
     expected = ma.mean(self.data, axis=self.axis)
     expected.mask = [False, True, True, True]
     self.assertMaskedArrayAlmostEqual(result, expected)
示例#21
0
 def test_mdtol_above(self):
     agg = MEAN.lazy_aggregate(self.array, axis=self.axis, mdtol=0.4)
     result = agg.masked_array()
     expected = ma.mean(self.data, axis=self.axis)
     self.assertMaskedArrayAlmostEqual(result, expected)
示例#22
0
 def test_all_axes_belowtol(self):
     agg = MEAN.lazy_aggregate(self.array, axis=None, mdtol=0.75)
     expected_masked = ma.mean(self.data)
     masked_result = as_concrete_data(agg)
     self.assertMaskedArrayAlmostEqual(masked_result,
                                       expected_masked)