Get the zero plane either based on zero or on the min or max value.
Used in bar and area plots
183294
function getThreshold(threshold) {
			if (min > threshold) {
				threshold = min;
			} else if (max < threshold) {
				threshold = max;
			}

			return translate(threshold, 0, 1);
		}
946441
def clean_with_zeros(self,x):
        
        x[~np.any(np.isnan(x) | np.isinf(x),axis=1)] = 0
        return x
1334755
def getSobel(x, y)
      if !defined?(@sobels)
        @sobel_x ||= [[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]]
        @sobel_y ||= [[-1, -2, -1], [0, 0, 0], [1, 2, 1]]
        return 0 if x.zero? || (x == (@width - 1)) || y.zero? || (y == (@height - 1))
        t1 = @grey[y - 1][x - 1]
        t2 = @grey[y - 1][x]
        t3 = @grey[y - 1][x + 1]
        t4 = @grey[y][x - 1]
        t5 = @grey[y][x]
        t6 = @grey[y][x + 1]
        t7 = @grey[y + 1][x - 1]
        t8 = @grey[y + 1][x]
        t9 = @grey[y + 1][x + 1]
        pixel_x = (@sobel_x[0][0] * t1) + (@sobel_x[0][1] * t2) + (@sobel_x[0][2] * t3) + (@sobel_x[1][0] * t4) + (@sobel_x[1][1] * t5) + (@sobel_x[1][2] * t6) + (@sobel_x[2][0] * t7) + (@sobel_x[2][1] * t8) + (@sobel_x[2][2] * t9)
        pixel_y = (@sobel_y[0][0] * t1) + (@sobel_y[0][1] * t2) + (@sobel_y[0][2] * t3) + (@sobel_y[1][0] * t4) + (@sobel_y[1][1] * t5) + (@sobel_y[1][2] * t6) + (@sobel_y[2][0] * t7) + (@sobel_y[2][1] * t8) + (@sobel_y[2][2] * t9)
        Math.sqrt(pixel_x * pixel_x + pixel_y * pixel_y).ceil
      else
        @sobels[y * @width + x]
      end
    end
335223
def __find_a_zero(self):
        """"""
        row = -1
        col = -1
        i = 0
        n = self.n
        done = False

        while not done:
            j = 0
            while True:
                if (self.C[i][j] == 0) and \
                        (not self.row_covered[i]) and \
                        (not self.col_covered[j]):
                    row = i
                    col = j
                    done = True
                j += 1
                if j >= n:
                    break
            i += 1
            if i >= n:
                done = True

        return (row, col)
1365264
def zero2d(self):
        
        return type(self)(x=np.atleast_2d(np.zeros((self.shape[0],self.shape[1]))),
                   row_names=self.row_names,
                   col_names=self.col_names,
                   isdiagonal=False)
391633
def findMax(arr):
    
    out = np.zeros(shape=arr.shape, dtype=bool)
    _calcMax(arr, out)
    return out
1146221
def scale_to_zero_one(x):
    
    xscaled = x - np.min(x)
    xscaled /= np.max(xscaled)
    return xscaled
797754
def argmax(self, axis=None, skipna=True, *args, **kwargs):
        
        nv.validate_argmax(args, kwargs)
        nv.validate_minmax_axis(axis)

        i8 = self.asi8
        if self.hasnans:
            mask = self._isnan
            if mask.all() or not skipna:
                return -1
            i8 = i8.copy()
            i8[mask] = 0
        return i8.argmax()
986781
def _axis_in_detector(geometry):
    """"""
    du, dv = geometry.det_axes_init
    axis = geometry.axis
    c = np.array([np.vdot(axis, du), np.vdot(axis, dv)])
    cnorm = np.linalg.norm(c)

    # Check for numerical errors
    assert cnorm != 0

    return c / cnorm
36947
def inside(self, x, y):
        
        return 0 <= x < self.width and 0 <= y < self.height
14744
def _min(self):
        """"""
        return (
            self.range[0] if (self.range and self.range[0] is not None) else
            (min(self._values) if self._values else None)
        )
538818
def _min(self):
        """"""
        return (
            self.range[0] if (self.range and self.range[0] is not None) else
            (min(self.yvals) if self.yvals else None)
        )
1193485
protected double getRange(ValueDimension dim) {
		return zeroBased ? diagram.getValues(dim).max().doubleValue() : diagram.getValues(dim).range();
	}
583546
def _derX(self,x,y):
        '''
        
        '''
        if _isscalar(x):
            x_pos = max(min(self.xSearchFunc(self.x_list,x),self.x_n-1),1)
            y_pos = max(min(self.ySearchFunc(self.y_list,y),self.y_n-1),1)
        else:
            x_pos = self.xSearchFunc(self.x_list,x)
            x_pos[x_pos < 1] = 1
            x_pos[x_pos > self.x_n-1] = self.x_n-1
            y_pos = self.ySearchFunc(self.y_list,y)
            y_pos[y_pos < 1] = 1
            y_pos[y_pos > self.y_n-1] = self.y_n-1
        beta = (y - self.y_list[y_pos-1])/(self.y_list[y_pos] - self.y_list[y_pos-1])
        dfdx = (
              ((1-beta)*self.f_values[x_pos,y_pos-1]
            +  beta*self.f_values[x_pos,y_pos]) -
              ((1-beta)*self.f_values[x_pos-1,y_pos-1]
            +  beta*self.f_values[x_pos-1,y_pos]))/(self.x_list[x_pos] - self.x_list[x_pos-1])
        return dfdx
1167356
def _zeros(ftype, *dims):
    """"""
    shape = _dims2shape(*dims)
    objs = [ftype.box(0) for _ in range(_volume(shape))]
    return farray(objs, shape, ftype)
975779
def _der(self,*args):
        '''
        
        '''
        if len(args) > 0:
            if _isscalar(args[0]):
                return 0.0
            else:
                shape = args[0].shape
                return np.zeros(shape)
        else:
            return 0.0
414198
def _get_simpx_plane(self):
        
        on_wulff = [False] * len(self.miller_list)
        surface_area = [0.0] * len(self.miller_list)
        for simpx in self.wulff_cv_simp:
            pts = [self.wulff_pt_list[simpx[i]] for i in range(3)]
            center = np.sum(pts, 0) / 3.0
            # check whether the center of the simplices is on one plane
            for plane in self.facets:
                abs_diff = abs(np.dot(plane.normal, center) - plane.e_surf)
                if abs_diff < 1e-5:
                    on_wulff[plane.index] = True
                    surface_area[plane.index] += get_tri_area(pts)

                    plane.points.append(pts)
                    plane.outer_lines.append([simpx[0], simpx[1]])
                    plane.outer_lines.append([simpx[1], simpx[2]])
                    plane.outer_lines.append([simpx[0], simpx[2]])
                    # already find the plane, move to the next simplices
                    break
        for plane in self.facets:
            plane.outer_lines.sort()
            plane.outer_lines = [line for line in plane.outer_lines
                                 if plane.outer_lines.count(line) != 2]
        return on_wulff, surface_area