Exemple #1
0
 def test_masked_1d_single(self):
     data = ma.arange(11)
     data[3:7] = ma.masked
     actual = PERCENTILE.aggregate(data, axis=0, percent=50)
     expected = 7
     self.assertTupleEqual(actual.shape, ())
     self.assertEqual(actual, expected)
Exemple #2
0
 def test_2d_single(self):
     shape = (2, 11)
     data = np.arange(np.prod(shape)).reshape(shape)
     actual = PERCENTILE.aggregate(data, axis=0, percent=50)
     self.assertTupleEqual(actual.shape, shape[-1:])
     expected = np.arange(shape[-1]) + 5.5
     self.assertArrayEqual(actual, expected)
Exemple #3
0
 def test_1d_multi(self):
     data = np.arange(11)
     percent = np.array([20, 50, 90])
     actual = PERCENTILE.aggregate(data, axis=0, percent=percent)
     expected = [2, 5, 9]
     self.assertTupleEqual(actual.shape, percent.shape)
     self.assertArrayEqual(actual, expected)
Exemple #4
0
 def test_masked_1d_single(self):
     data = ma.arange(11)
     data[3:7] = ma.masked
     actual = PERCENTILE.aggregate(data, axis=0, percent=50)
     expected = 7
     self.assertTupleEqual(actual.shape, ())
     self.assertEqual(actual, expected)
Exemple #5
0
 def test_1d_multi(self):
     data = np.arange(11)
     percent = np.array([20, 50, 90])
     actual = PERCENTILE.aggregate(data, axis=0, percent=percent)
     expected = [2, 5, 9]
     self.assertTupleEqual(actual.shape, percent.shape)
     self.assertArrayEqual(actual, expected)
Exemple #6
0
 def test_2d_single(self):
     shape = (2, 11)
     data = np.arange(np.prod(shape)).reshape(shape)
     actual = PERCENTILE.aggregate(data, axis=0, percent=50)
     self.assertTupleEqual(actual.shape, shape[-1:])
     expected = np.arange(shape[-1]) + 5.5
     self.assertArrayEqual(actual, expected)
Exemple #7
0
 def test_masked_1d_multi(self):
     data = ma.arange(11)
     data[3:9] = ma.masked
     percent = np.array([25, 50, 75])
     actual = PERCENTILE.aggregate(data, axis=0, percent=percent)
     expected = [1, 2, 9]
     self.assertTupleEqual(actual.shape, percent.shape)
     self.assertArrayEqual(actual, expected)
Exemple #8
0
 def test_masked_1d_multi(self):
     data = ma.arange(11)
     data[3:9] = ma.masked
     percent = np.array([25, 50, 75])
     actual = PERCENTILE.aggregate(data, axis=0, percent=percent)
     expected = [1, 2, 9]
     self.assertTupleEqual(actual.shape, percent.shape)
     self.assertArrayEqual(actual, expected)
Exemple #9
0
 def test_2d_multi(self):
     shape = (2, 10)
     data = np.arange(np.prod(shape)).reshape(shape)
     percent = np.array([10, 50, 90, 100])
     actual = PERCENTILE.aggregate(data, axis=0, percent=percent)
     self.assertTupleEqual(actual.shape, (shape[-1], percent.size))
     expected = np.tile(np.arange(shape[-1]), percent.size)
     expected = expected.reshape(percent.size, shape[-1]).T + 1
     expected = expected + (percent / 10 - 1)
     self.assertArrayAlmostEqual(actual, expected)
Exemple #10
0
 def test_2d_multi(self):
     shape = (2, 10)
     data = np.arange(np.prod(shape)).reshape(shape)
     percent = np.array([10, 50, 90, 100])
     actual = PERCENTILE.aggregate(data, axis=0, percent=percent)
     self.assertTupleEqual(actual.shape, (shape[-1], percent.size))
     expected = np.tile(np.arange(shape[-1]), percent.size)
     expected = expected.reshape(percent.size, shape[-1]).T + 1
     expected = expected + (percent / 10 - 1)
     self.assertArrayAlmostEqual(actual, expected)
Exemple #11
0
 def test_masked_2d_single(self):
     shape = (2, 11)
     data = ma.arange(np.prod(shape)).reshape(shape)
     data[0, ::2] = ma.masked
     data[1, 1::2] = ma.masked
     actual = PERCENTILE.aggregate(data, axis=0, percent=50)
     self.assertTupleEqual(actual.shape, shape[-1:])
     expected = np.empty(shape[-1:])
     expected[1::2] = data[0, 1::2]
     expected[::2] = data[1, ::2]
     self.assertArrayEqual(actual, expected)
Exemple #12
0
 def test_masked_2d_multi(self):
     shape = (3, 10)
     data = ma.arange(np.prod(shape)).reshape(shape)
     data[1] = ma.masked
     percent = np.array([10, 50, 70, 80])
     actual = PERCENTILE.aggregate(data, axis=0, percent=percent)
     self.assertTupleEqual(actual.shape, (shape[-1], percent.size))
     expected = np.tile(np.arange(shape[-1]), percent.size)
     expected = expected.reshape(percent.size, shape[-1]).T
     expected = expected + (percent / 10 * 2)
     self.assertArrayAlmostEqual(actual, expected)
Exemple #13
0
 def test_masked_2d_multi(self):
     shape = (3, 10)
     data = ma.arange(np.prod(shape)).reshape(shape)
     data[1] = ma.masked
     percent = np.array([10, 50, 70, 80])
     actual = PERCENTILE.aggregate(data, axis=0, percent=percent)
     self.assertTupleEqual(actual.shape, (shape[-1], percent.size))
     expected = np.tile(np.arange(shape[-1]), percent.size)
     expected = expected.reshape(percent.size, shape[-1]).T
     expected = expected + (percent / 10 * 2)
     self.assertArrayAlmostEqual(actual, expected)
Exemple #14
0
 def test_masked_2d_single(self):
     shape = (2, 11)
     data = ma.arange(np.prod(shape)).reshape(shape)
     data[0, ::2] = ma.masked
     data[1, 1::2] = ma.masked
     actual = PERCENTILE.aggregate(data, axis=0, percent=50)
     self.assertTupleEqual(actual.shape, shape[-1:])
     expected = np.empty(shape[-1:])
     expected[1::2] = data[0, 1::2]
     expected[::2] = data[1, ::2]
     self.assertArrayEqual(actual, expected)
Exemple #15
0
 def test_missing_mandatory_kwarg(self):
     emsg = "percentile aggregator requires .* keyword argument 'percent'"
     with self.assertRaisesRegexp(ValueError, emsg):
         PERCENTILE.aggregate_shape()
     with self.assertRaisesRegexp(ValueError, emsg):
         kwargs = dict()
         PERCENTILE.aggregate_shape(**kwargs)
     with self.assertRaisesRegexp(ValueError, emsg):
         kwargs = dict(point=10)
         PERCENTILE.aggregate_shape(**kwargs)
Exemple #16
0
 def test_missing_mandatory_kwarg(self):
     emsg = "percentile aggregator requires .* keyword argument 'percent'"
     with self.assertRaisesRegexp(ValueError, emsg):
         PERCENTILE.aggregate_shape()
     with self.assertRaisesRegexp(ValueError, emsg):
         kwargs = dict()
         PERCENTILE.aggregate_shape(**kwargs)
     with self.assertRaisesRegexp(ValueError, emsg):
         kwargs = dict(point=10)
         PERCENTILE.aggregate_shape(**kwargs)
Exemple #17
0
 def test_mandatory_kwarg_no_shape(self):
     kwargs = dict(percent=50)
     self.assertTupleEqual(PERCENTILE.aggregate_shape(**kwargs), ())
     kwargs = dict(percent=[50])
     self.assertTupleEqual(PERCENTILE.aggregate_shape(**kwargs), ())
Exemple #18
0
 def test_mandatory_kwarg_shape(self):
     kwargs = dict(percent=(10, 20))
     self.assertTupleEqual(PERCENTILE.aggregate_shape(**kwargs), (2,))
     kwargs = dict(percent=list(range(13)))
     self.assertTupleEqual(PERCENTILE.aggregate_shape(**kwargs), (13,))
Exemple #19
0
 def test_missing_mandatory_kwarg(self):
     emsg = "percentile aggregator requires .* keyword argument 'percent'"
     with self.assertRaisesRegexp(ValueError, emsg):
         PERCENTILE.aggregate('dummy', axis=0)
Exemple #20
0
 def test_1d_single(self):
     data = np.arange(11)
     actual = PERCENTILE.aggregate(data, axis=0, percent=50)
     expected = 5
     self.assertTupleEqual(actual.shape, ())
     self.assertEqual(actual, expected)
Exemple #21
0
 def test_missing_mandatory_kwarg(self):
     emsg = "percentile aggregator requires .* keyword argument 'percent'"
     with self.assertRaisesRegexp(ValueError, emsg):
         PERCENTILE.aggregate("dummy", axis=0)
Exemple #22
0
 def test_mandatory_kwarg_shape(self):
     kwargs = dict(percent=(10, 20))
     self.assertTupleEqual(PERCENTILE.aggregate_shape(**kwargs), (2,))
     kwargs = dict(percent=list(range(13)))
     self.assertTupleEqual(PERCENTILE.aggregate_shape(**kwargs), (13,))
Exemple #23
0
 def test_mandatory_kwarg_no_shape(self):
     kwargs = dict(percent=50)
     self.assertTupleEqual(PERCENTILE.aggregate_shape(**kwargs), ())
     kwargs = dict(percent=[50])
     self.assertTupleEqual(PERCENTILE.aggregate_shape(**kwargs), ())
Exemple #24
0
 def test(self):
     self.assertEqual(PERCENTILE.name(), "percentile")
Exemple #25
0
 def test(self):
     self.assertEqual(PERCENTILE.name(), 'percentile')
Exemple #26
0
 def test_1d_single(self):
     data = np.arange(11)
     actual = PERCENTILE.aggregate(data, axis=0, percent=50)
     expected = 5
     self.assertTupleEqual(actual.shape, ())
     self.assertEqual(actual, expected)