Apply cut levels on the image view.

        Parameters
        ----------
        loval, hival : float
            Low and high values of the cut levels, respectively.

        no_reset : bool
            Do not reset ``autocuts`` setting.
481588
def cut_levels(self, loval, hival, no_reset=False):
        
        self.t_.set(cuts=(loval, hival))

        # If user specified "override" or "once" for auto levels,
        # then turn off auto levels now that they have set the levels
        # manually
        if (not no_reset) and (self.t_['autocuts'] in ('once', 'override')):
            self.t_.set(autocuts='off')
1092190
function _enableMasking(ctx, data, params) {
	if (params.mask) {
		// If jCanvas autosave is enabled
		if (params.autosave) {
			// Automatically save transformation state by default
			_saveCanvas(ctx, data);
		}
		// Clip the current path
		ctx.clip();
		// Keep track of current masks
		data.transforms.masks.push(params._args);
	}
}
254610
def interpolation_change_cb(self, setting, value):
        """"""
        canvas_img = self.get_canvas_image()
        canvas_img.interpolation = value
        canvas_img.reset_optimize()
        self.redraw(whence=0)
95024
def _linear_selection(self, non_empty_slices, num_slices):
        """"""

        num_non_empty = len(non_empty_slices)

        # # trying to skip 5% slices at the tails (bottom clipping at 0)
        # skip_count = max(0, np.around(num_non_empty * 0.05).astype('int16'))
        # # only when possible
        # if skip_count > 0 and (num_non_empty - 2 * skip_count > num_slices):
        #     non_empty_slices = non_empty_slices[skip_count: -skip_count]
        #     num_non_empty = len(non_empty_slices)

        sampled_indices = np.linspace(0, num_non_empty, num=min(num_non_empty, num_slices),
                                      endpoint=False)
        slices_in_dim = non_empty_slices[np.around(sampled_indices).astype('int64')]

        return slices_in_dim
979579
def _maybe_mask_result(self, result, mask, other, op_name):
        

        # may need to fill infs
        # and mask wraparound
        if is_float_dtype(result):
            mask |= (result == np.inf) | (result == -np.inf)

        # if we have a float operand we are by-definition
        # a float result
        # or our op is a divide
        if ((is_float_dtype(other) or is_float(other)) or
                (op_name in ['rtruediv', 'truediv', 'rdiv', 'div'])):
            result[mask] = np.nan
            return result

        return type(self)(result, mask, copy=False)
173625
def cut_setting(self, cut):
        '''
        '''
        
        cut_settings = {'full' : 0b00000001,
                        'half' : 0b00000010,
                        'chain': 0b00000100,
                        'special': 0b00001000
                        }
        if cut in cut_settings:
            self.send(chr(27)+'iC'+chr(cut_settings[cut]))
        else:
            raise RuntimeError('Invalid cut type.')
1252798
def set_regression_mask(self, v):
        """"""
        base = self._base
        index = np.arange(v.size())
        np.random.shuffle(index)
        ones = np.ones(v.size())
        ones[index[int(base._tr_fraction * v.size()):]] = 0
        base._mask = SparseArray.fromlist(ones)
773967
def sc_cuts_alg(self, viewer, event, msg=True):
        
        if self.cancut:
            direction = self.get_direction(event.direction)
            self._cycle_cuts_alg(viewer, msg, direction=direction)
        return True
713462
def set_xlabels(self, label=None, **kwargs):
        """"""
        if label is None:
            label = label_from_attrs(self.data[self._x_var])
        for ax in self._bottom_axes:
            ax.set_xlabel(label, **kwargs)
        return self
1070405
def _onShortcutCutLine(self):
        
        lines = self.lines[self._selectedLinesSlice()]

        self._onShortcutCopyLine()
        self._onShortcutDeleteLine()
961228
def ms_cutlo(self, viewer, event, data_x, data_y):
        
        if not self.cancut:
            return True

        x, y = self.get_win_xy(viewer)

        if event.state == 'move':
            self._cutlow_xy(viewer, x, y)

        elif event.state == 'down':
            self._start_x, self._start_y = x, y
            self._loval, self._hival = viewer.get_cut_levels()

        else:
            viewer.onscreen_message(None)
        return True
1088950
def setResult(self, value):
        
        # Always update ResultCapture date when this field is modified
        self.setResultCaptureDate(DateTime())

        # Ensure result integrity regards to None, empty and 0 values
        val = str("" if not value and value != 0 else value).strip()

        # UDL/LDL directly entered in the results field
        if val and val[0] in [LDL, UDL]:
            # Result prefixed with LDL/UDL
            oper = val[0]
            # Strip off LDL/UDL from the result
            val = val.replace(oper, "", 1)
            # Check if the value is indeterminate / non-floatable
            try:
                val = float(val)
            except (ValueError, TypeError):
                val = value

            # We dismiss the operand and the selector visibility unless the user
            # is allowed to manually set the detection limit or the DL selector
            # is visible.
            allow_manual = self.getAllowManualDetectionLimit()
            selector = self.getDetectionLimitSelector()
            if allow_manual or selector:
                # Ensure visibility of the detection limit selector
                self.setDetectionLimitSelector(True)

                # Set the detection limit operand
                self.setDetectionLimitOperand(oper)

                if not allow_manual:
                    # Override value by default DL
                    if oper == LDL:
                        val = self.getLowerDetectionLimit()
                    else:
                        val = self.getUpperDetectionLimit()

        # Set the result field
        self.getField("Result").set(self, val)
220688
def applyHotspot(self, lon, lat):
        
        self.loadRealResults()
        cut_detect_real = (self.data_real['SIG'] >= self.config[self.algorithm]['sig_threshold'])
        lon_real = self.data_real['RA'][cut_detect_real]
        lat_real = self.data_real['DEC'][cut_detect_real]

        cut_hotspot = np.tile(True, len(lon))
        for ii in range(0, len(lon)):
            cut_hotspot[ii] = ~np.any(angsep(lon[ii], lat[ii], lon_real, lat_real) < self.config[self.algorithm]['hotspot_angsep_threshold'])

        return cut_hotspot
1153982
def _opdist_low(av, bv, cv, deriv):
    """"""
    a = Vector3(9, deriv, av, (0, 1, 2))
    b = Vector3(9, deriv, bv, (3, 4, 5))
    c = Vector3(9, deriv, cv, (6, 7, 8))
    n  = cross(a, b)
    n /= n.norm()
    dist = dot(c, n)
    return dist.results()
1281982
def interpolate(self, interpValues):
                
        self.__operations.append(["interpolate", interpValues])          
        
        df = self.sampleDF
        self.interpValues = interpValues
        for interParamName, value  in interpValues.items():
            self.__report += "Interpolation of the parameters for independent variables '" \
                             + interParamName + "' at value " + str(value) + ".\n"   
            for ind, (paramTrace, resType) in enumerate(zip(df["obj_parameter"], df["Result type"])):
                if resType == "numericalTrace" and interParamName in paramTrace.indepNames:
                    val = paramTrace.getInterp1dValues(value, interParamName, statsToReturn=["mean"])
                    if isinstance(val, list):
                        if len(val) == 1:
                            val = val[0]
                        else:
                            raise ValueError("This case has not been implemented yet.")
                    df.loc[ind, "Values"] = float(val)
236926
def apply (self, img):

        
        yup,uup,vup = self.getUpLimit()
        ydwn,udwn,vdwn = self.getDownLimit()

        ''' '''

        yuv = cv2.cvtColor(img, cv2.COLOR_BGR2YUV)
        
        minValues = np.array([ydwn,udwn,vdwn],dtype=np.uint8)
        maxValues = np.array([yup,uup,vup], dtype=np.uint8)

        mask = cv2.inRange(yuv, minValues, maxValues)

        res = cv2.bitwise_and(img,img, mask= mask)


        return res
246119
def imagenet_clamp_batch(batch, low, high):
    
    F.clip(batch[:,0,:,:],low-123.680, high-123.680)
    F.clip(batch[:,1,:,:],low-116.779, high-116.779)
    F.clip(batch[:,2,:,:],low-103.939, high-103.939)