def test_prod_float(self): X = numpy.asarray([1.0, float("NaN"), 2.0, 4.0]) aggregator = Aggregator(function="prod") X = X.reshape((-1, 4)) self.assertEquals(8.0, aggregator.transform(X)) X = X.reshape((2, 2)) self.assertEquals([1.0, 8.0], aggregator.transform(X).tolist())
def test_min_int(self): X = numpy.asarray([1, 0, 2, 3]) aggregator = Aggregator(function="min") X = X.reshape((-1, 4)) self.assertEquals(0, aggregator.transform(X)) X = X.reshape((2, 2)) self.assertEquals([0, 2], aggregator.transform(X).tolist()) X = X.reshape((4, -1)) self.assertEquals([1, 0, 2, 3], aggregator.transform(X).tolist())
def test_min(self): X = numpy.asarray([1, 0.5, 2, 3.0, 0, 1.0]) min = Aggregator(function="min") X = X.reshape((1, 6)) self.assertEqual(0, min.transform(X)) X = X.reshape((3, 2)) self.assertEqual([0.5, 2, 0], min.transform(X).tolist()) X = X.reshape((2, 3)) self.assertEqual([0.5, 0], min.transform(X).tolist()) X = X.reshape((6, 1)) self.assertEqual([1, 0.5, 2, 3.0, 0, 1.0], min.transform(X).tolist())
def test_min_float(self): X = numpy.asarray([1.0, 0.5, 2.0, 3.0, float("NaN"), 1.5]) aggregator = Aggregator(function = "min") X = X.reshape((-1, 6)) self.assertEqual(0.5, aggregator.transform(X)) X = X.reshape((3, 2)) self.assertEqual([0.5, 2.0, 1.5], aggregator.transform(X).tolist()) X = X.reshape((2, 3)) self.assertEqual([0.5, 1.5], aggregator.transform(X).tolist()) X = X.reshape((6, -1)) self.assertTrue(nan_eq([1.0, 0.5, 2.0, 3.0, float("NaN"), 1.5], aggregator.transform(X).tolist()))
def test_mean_float(self): X = numpy.asarray([1.0, float("NaN"), 2.0]) aggregator = Aggregator(function="mean") X = X.reshape((-1, 3)) self.assertEquals(1.5, aggregator.transform(X))