def _get_plottable(self): # If log scale is set, only pos data will be returned x, y = self._x, self._y try: logx = self._transform.get_funcx().get_type()==LOG10 except RuntimeError: logx = False # non-separable try: logy = self._transform.get_funcy().get_type()==LOG10 except RuntimeError: logy = False # non-separable if not logx and not logy: return x, y if self._logcache is not None: waslogx, waslogy, xcache, ycache = self._logcache if logx==waslogx and waslogy==logy: return xcache, ycache Nx = len(x) Ny = len(y) if logx: indx = greater(x, 0) else: indx = ones(len(x)) if logy: indy = greater(y, 0) else: indy = ones(len(y)) ind = nonzero(logical_and(indx, indy)) x = take(x, ind) y = take(y, ind) self._logcache = logx, logy, x, y return x, y
def _get_numeric_clipped_data_in_range(self): # if the x or y clip is set, only plot the points in the # clipping region. If log scale is set, only pos data will be # returned try: self._xc, self._yc except AttributeError: x, y = self._x, self._y else: x, y = self._xc, self._yc try: logx = self._transform.get_funcx().get_type() == LOG10 except RuntimeError: logx = False # non-separable try: logy = self._transform.get_funcy().get_type() == LOG10 except RuntimeError: logy = False # non-separable if not logx and not logy: return x, y if self._logcache is not None: waslogx, waslogy, xcache, ycache = self._logcache if logx == waslogx and waslogy == logy: return xcache, ycache Nx = len(x) Ny = len(y) if logx: indx = greater(x, 0) else: indx = ones(len(x)) if logy: indy = greater(y, 0) else: indy = ones(len(y)) ind = nonzero(logical_and(indx, indy)) x = take(x, ind) y = take(y, ind) self._logcache = logx, logy, x, y return x, y
def hard(data, value, substitute=0): mvalue = -value cond = numerix.less(data, value) cond &= numerix.greater(data, mvalue) return numerix.where(cond, substitute, data)
def soft(data, value, substitute=0): mvalue = -value cond_less = numerix.less(data, value) cond_greater = numerix.greater(data, mvalue) data = numerix.where(cond_less & cond_greater, substitute, data) data = numerix.where(cond_less, data + value, data) data = numerix.where(cond_greater, data - value, data) return data
def less(data, value, substitute=0): return numerix.where(numerix.greater(data, value), substitute, data)