Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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), ())
Exemplo n.º 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,))
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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,))
Exemplo n.º 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), ())
Exemplo n.º 24
0
 def test(self):
     self.assertEqual(PERCENTILE.name(), "percentile")
Exemplo n.º 25
0
 def test(self):
     self.assertEqual(PERCENTILE.name(), 'percentile')
Exemplo n.º 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)