Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 3
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)
Exemplo n.º 4
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)
Exemplo n.º 5
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)
Exemplo n.º 6
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)
Exemplo n.º 7
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)
Exemplo n.º 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, nans_replacement=ma.masked)
     expected = np.mean(data, axis=collapse_axes)
     self.assertArrayAllClose(result, expected)
Exemplo n.º 9
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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 12
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)
Exemplo n.º 13
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)
Exemplo n.º 14
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)
Exemplo n.º 15
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)
Exemplo n.º 16
0
 def test(self):
     shape = ()
     kwargs = dict()
     self.assertTupleEqual(MEAN.aggregate_shape(**kwargs), shape)
     kwargs = dict(one=1, two=2)
     self.assertTupleEqual(MEAN.aggregate_shape(**kwargs), shape)
Exemplo n.º 17
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)
Exemplo n.º 18
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)
Exemplo n.º 19
0
 def test(self):
     self.assertEqual(MEAN.name(), "mean")
Exemplo n.º 20
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)
Exemplo n.º 21
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)
Exemplo n.º 22
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)
Exemplo n.º 23
0
 def test(self):
     shape = ()
     kwargs = dict()
     self.assertTupleEqual(MEAN.aggregate_shape(**kwargs), shape)
     kwargs = dict(one=1, two=2)
     self.assertTupleEqual(MEAN.aggregate_shape(**kwargs), shape)
Exemplo n.º 24
0
 def test(self):
     self.assertEqual(MEAN.name(), 'mean')
Exemplo n.º 25
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)
Exemplo n.º 26
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)