示例#1
0
 def apply(self, experiment):
     if not self.statistic_name:
         raise util.CytoflowOpError("Summary function isn't set")
     
     self.function = summary_functions[self.statistic_name]
     
     return ChannelStatisticOp.apply(self, experiment) 
示例#2
0
 def get_notebook_code(self, idx):
     op = ChannelStatisticOp()
     op.copy_traits(self, op.copyable_trait_names())
     
     fn_import = {"Mean" : "from numpy import mean",
               "Geom.Mean" : None,
               "Count" : None,
               "Std.Dev" : "from numpy import std",
               "Geom.SD" : None,
               "SEM" : "from scipy.stats import sem",
               "Geom.SEM" : None,
               "Mean 95% CI" : "from numpy import mean\nmean_ci = lambda x: ci(x, mean, boots = 100)",
               "Geom.Mean 95% CI" : "geom_mean_ci = lambda x: ci(x, geom_mean, boots = 100)"
               }
     
     fn_name = {"Mean" : "mean",
                "Geom.Mean" : "geom_mean",
                "Count" : "len",
                "Std.Dev" : "std",
                "Geom.SD" : "geom_sd_range",
                "SEM" : "sem",
                "Geom.SEM" : "geom_sem_range",
                "Mean 95% CI" : "mean_ci",
                "Geom.Mean 95% CI" : "geom_mean_ci"
                }
     
     op.function = summary_functions[self.statistic_name]
     
     try:
         # this doesn't work for builtins like "len"
         op.function.__name__ = fn_name[self.statistic_name]
     except:
         pass
     
     return dedent("""
     {import_statement}
     op_{idx} = {repr}
             
     ex_{idx} = op_{idx}.apply(ex_{prev_idx})
     """
     .format(import_statement = (fn_import[self.statistic_name] + "\n" 
                                 if fn_import[self.statistic_name] is not None
                                 else ""),
             repr = repr(op),
             idx = idx,
             prev_idx = idx - 1))