示例#1
0
 def __call__(self, data):
     """
     Transforms `data` using this scale.
     
     Careful!  May return `NaN` if the scale domain doesn't match the data 
     (ie, applying a log10 scale to negative numbers.)
     """
     
     try:
         logicle_min = self._logicle.inverse(0.0)
         logicle_max = self._logicle.inverse(1.0 - sys.float_info.epsilon)
         if isinstance(data, pd.Series):            
             data = data.clip(logicle_min, logicle_max)
             return data.apply(self._logicle.scale)
         elif isinstance(data, np.ndarray):
             data = np.clip(data, logicle_min, logicle_max)
             scale = np.vectorize(self._logicle.scale)
             return scale(data)
         elif isinstance(data, float):
             data = max(min(data, logicle_max), logicle_min)
             return self._logicle.scale(data)
         else:
             try:
                 return map(self._logicle.scale, data)
             except TypeError:
                 raise CytoflowError("Unknown data type in LogicleScale.__call__")
     except ValueError as e:
         raise CytoflowError(e.strerror)
示例#2
0
        def transform_non_affine(self, values):

            try:
                logicle_min = self.logicle.inverse(0.0)
                logicle_max = self.logicle.inverse(1.0 -
                                                   sys.float_info.epsilon)
                if isinstance(values, pd.Series):
                    values = values.clip(logicle_min, logicle_max)
                    return values.apply(self.logicle.scale)
                elif isinstance(values, np.ndarray):
                    values = np.clip(values, logicle_min, logicle_max)
                    scale = np.vectorize(self.logicle.scale)
                    return scale(values)
                elif isinstance(values, float):
                    data = max(min(values, logicle_max), logicle_min)
                    return self.logicle.scale(data)
                elif isinstance(values, int):
                    data = float(data)
                    data = max(min(values, logicle_max), logicle_min)
                    return self.logicle.scale(data)
                else:
                    raise CytoflowError(
                        "Unknown data type in MatplotlibLogicleScale.transform_non_affine"
                    )

            except ValueError as e:
                raise CytoflowError("Bad transform") from e
示例#3
0
 def transform_non_affine(self, values):
     
     logicle_min = self.logicle.inverse(0.0)
     logicle_max = self.logicle.inverse(1.0 - sys.float_info.epsilon)
     if isinstance(values, pd.Series):            
         values = values.clip(logicle_min, logicle_max)
         return values.apply(self.logicle.scale)
     elif isinstance(values, np.ndarray):
         values = np.clip(values, logicle_min, logicle_max)
         scale = np.vectorize(self.logicle.scale)
         return scale(values)
     elif isinstance(values, float):
         data = max(min(values, logicle_max), logicle_min)
         return self.logicle.scale(data)
     else:
         raise CytoflowError("Unknown data type in MatplotlibLogicleScale.transform_non_affine")
示例#4
0
 def __call__(self, data):
     """
     Transforms `data` using this scale.
     
     Careful!  May return `NaN` if the scale domain doesn't match the data 
     (ie, applying a log10 scale to negative numbers.)
     """
     
     logicle_min = self.logicle.inverse(0.0)
     logicle_max = self.logicle.inverse(1.0 - sys.float_info.epsilon)
     if isinstance(data, pd.Series):            
         data = data.clip(logicle_min, logicle_max)
         return data.apply(self.logicle.scale)
     elif isinstance(data, np.ndarray):
         data = np.clip(data, logicle_min, logicle_max)
         scale = np.vectorize(self.logicle.scale)
         return scale(data)
     elif isinstance(data, float):
         data = max(min(data, logicle_max), logicle_min)
         return self.logicle.scale(data)
     else:
         raise CytoflowError("Unknown data type in LogicleScale.__call__")
示例#5
0
 def transform_non_affine(self, values):
     scale = np.vectorize(self.logicle.scale)
     return scale(values)
示例#6
0
 def transform_non_affine(self, values):
     scale = np.vectorize(self.logicle.scale)
     return scale(values)