def testBadFunction(self): op = flow.TransformStatisticOp(name = "ByDox", by = ['Dox'], statistic = ("ByDox", "len"), function = lambda x: len(x) / 0.0) with self.assertRaises(util.CytoflowOpError): op.apply(self.ex)
def testSeries(self): op = flow.TransformStatisticOp(name = "ByDox", by = ['Dox'], statistic = ("ByDox", "len"), function = lambda x: x / x.sum(), statistic_name = "prop") ex2 = op.apply(self.ex) stat = ex2.statistics[("ByDox", "prop")] self.assertIsInstance(stat, pd.Series) self.assertIsNot(type(stat.iloc[0]), pd.Series)
def testApply(self): ex = flow.TransformStatisticOp(name = "ByDox", statistic = ("ByDox", "len"), by = ['Dox'], statistic_name = "sum", function = lambda x: x.sum()).apply(self.ex) self.assertIn(("ByDox","sum"), ex.statistics) stat = ex.statistics[("ByDox", "sum")] self.assertIn("Dox", stat.index.names) self.assertNotIn("T", stat.index.names)