Helper method that removes anomalies which don't meet
        a minimum separation from next anomaly.
777196
def prune_anomalies(e_seq, smoothed_errors, max_error_below_e, anomaly_indices):
    
    # min accepted perc decrease btwn max errors in anomalous sequences
    MIN_PERCENT_DECREASE = 0.05
    e_seq_max, smoothed_errors_max = [], []

    for error_seq in e_seq:
        if len(smoothed_errors[error_seq[0]:error_seq[1]]) > 0:
            sliced_errors = smoothed_errors[error_seq[0]:error_seq[1]]
            e_seq_max.append(max(sliced_errors))
            smoothed_errors_max.append(max(sliced_errors))

    smoothed_errors_max.sort(reverse=True)

    if max_error_below_e > 0:
        smoothed_errors_max.append(max_error_below_e)
    indices_remove = []

    for i in range(len(smoothed_errors_max)):
        if i < len(smoothed_errors_max) - 1:
            delta = smoothed_errors_max[i] - smoothed_errors_max[i + 1]
            perc_change = delta / smoothed_errors_max[i]
            if perc_change < MIN_PERCENT_DECREASE:
                indices_remove.append(e_seq_max.index(smoothed_errors_max[i]))

    for index in sorted(indices_remove, reverse=True):
        del e_seq[index]

    pruned_indices = []

    for i in anomaly_indices:
        for error_seq in e_seq:
            if i >= error_seq[0] and i <= error_seq[1]:
                pruned_indices.append(i)

    return pruned_indices
882709
def remove_max_dipole_sep(self, maxsep=10):
        
        sep = np.abs(self.configs[:, 1] - self.configs[:, 2])
        self.configs = self.configs[sep <= maxsep]
1304291
public static void unsetTraversalParameters(Configuration conf) {
		conf.unset(BOUNDED_TRAVERSAL_PROPERTY);
		conf.unset(INTERVALS_PROPERTY);
		conf.unset(TRAVERSE_UNPLACED_UNMAPPED_PROPERTY);
	}
598589
private void removeSporadic() {
		//System.out.println("REMOVE SPORADIC CALLED");
		// 1. For each grid g in grid_list
		//    a. If g is sporadic
		//       i. If currTime - tg > gap, delete g from grid_list
		//       ii. Else if (S1 && S2), mark as sporadic
		//       iii. Else, mark as normal
		//    b. Else
		//       i. If (S1 && S2), mark as sporadic
		
		// For each grid g in grid_list
		Iterator<Map.Entry<DensityGrid, CharacteristicVector>> glIter = this.grid_list.entrySet().iterator();
		HashMap<DensityGrid, CharacteristicVector> newGL = new HashMap<DensityGrid, CharacteristicVector>();
		ArrayList<DensityGrid> remGL = new ArrayList<DensityGrid>();
				
		while(glIter.hasNext())
		{
			Map.Entry<DensityGrid, CharacteristicVector> grid = glIter.next();
			DensityGrid dg = grid.getKey();
			CharacteristicVector cv = grid.getValue();
			
			// If g is sporadic
			if (cv.isSporadic())
			{
				// If currTime - tg > gap, delete g from grid_list
				if ((this.getCurrTime() - cv.getUpdateTime()) >= gap)
				{
					int dgClass = cv.getLabel();
					
					if (dgClass != -1)
						this.cluster_list.get(dgClass).removeGrid(dg);
					
					remGL.add(dg);
					//System.out.println("Removed "+dg.toString()+" from cluster "+dgClass);
				}
				// Else if (S1 && S2), mark as sporadic - Else mark as normal
				else
				{
					cv.setSporadic(checkIfSporadic(cv));
					//System.out.println("within gap" + dg.toString() + " sporadicity assessed "+cv.isSporadic());
					newGL.put(dg, cv);
				}
				
			}
			// Else if (S1 && S2), mark as sporadic
			else
			{
				cv.setSporadic(checkIfSporadic(cv));
				//System.out.println(dg.toString() + " sporadicity assessed "+cv.isSporadic());
				newGL.put(dg, cv);
			}
		}
		
		this.grid_list.putAll(newGL);
		
		//System.out.println(" - Removed "+remGL.size()+" grids from grid_list.");
		Iterator<DensityGrid> remIter = remGL.iterator();
		
		while(remIter.hasNext())
		{
			DensityGrid sporadicDG = remIter.next();
			//System.out.println("Removing sporadic grid "+sporadicDG.toString()+" at time "+this.getCurrTime()+".");
			this.deleted_grids.put(sporadicDG, new Integer(this.getCurrTime()));
			this.grid_list.remove(sporadicDG);
		}
		
	}
271597
def dmol_neg_log_perplexity(predictions,
                            labels,
                            weights_fn=None):
  """"""
  del weights_fn  # Unused
  num, den = common_layers.dml_loss(
      predictions, labels, reduce_sum=False)
  return (-num, den)
712906
def filter_missing_X_and_y(X, y):
    """"""
    y_nans = np.isnan(y)
    x_nans = np.isnan(X).any(axis=1)
    unioned_nans = np.logical_or(x_nans, y_nans)

    return X[~unioned_nans], y[~unioned_nans]
713082
def filter_skiplines(code, errors):
    
    if not errors:
        return errors

    enums = set(er.lnum for er in errors)
    removed = set([
        num for num, l in enumerate(code.split('\n'), 1)
        if num in enums and SKIP_PATTERN(l)
    ])

    if removed:
        errors = [er for er in errors if er.lnum not in removed]

    return errors
418773
def prune_existing_features(project, force=False):
    """"""
    if not force and not project.on_master_after_merge():
        raise SkippedValidationTest('Not on master')

    out = project.build()
    X_df, y, features = out['X_df'], out['y'], out['features']
    proposed_feature = get_proposed_feature(project)
    accepted_features = get_accepted_features(features, proposed_feature)
    evaluator = GFSSFPruningEvaluator(
        X_df, y, accepted_features, proposed_feature)
    redundant_features = evaluator.prune()

    # propose removal
    for feature in redundant_features:
        logger.debug(PRUNER_MESSAGE + feature.source)

    return redundant_features
558695
private void pruneOutliers(BundleAdjustment<SceneStructureMetric> bundleAdjustment) {
		// see if it's configured to not prune
		if( pruneFraction == 1.0 )
			return;
		PruneStructureFromSceneMetric pruner = new PruneStructureFromSceneMetric(structure,observations);
		pruner.pruneObservationsByErrorRank(pruneFraction);
		pruner.pruneViews(10);
		pruner.prunePoints(1);
		bundleAdjustment.setParameters(structure,observations);
		bundleAdjustment.optimize(structure);

		if( verbose != null ) {
			verbose.println("\nCamera");
			for (int i = 0; i < structure.cameras.length; i++) {
				verbose.println(structure.cameras[i].getModel().toString());
			}
			verbose.println("\n\nworldToView");
			for (int i = 0; i < structure.views.length; i++) {
				verbose.println(structure.views[i].worldToView.toString());
			}
			verbose.println("Fit Score: " + bundleAdjustment.getFitScore());
		}
	}
1141569
static void pruneIncorrectShape(FastQueue<Grid> grids , int numRows, int numCols ) {
		// prune clusters which can't be a member calibration target
		for (int i = grids.size()-1; i >= 0; i--) {
			Grid g = grids.get(i);
			if ((g.rows != numRows || g.columns != numCols) && (g.rows != numCols || g.columns != numRows)) {
				grids.remove(i);
			}
		}
	}
776212
def clean(self,x):
        """"""
        return x[~np.any(np.isnan(x) | np.isinf(x),axis=1)]
892407
def remove_duplicates(errors):
    
    passed = defaultdict(list)
    for error in errors:
        key = error.linter, error.number
        if key in DUPLICATES:
            if key in passed[error.lnum]:
                continue
            passed[error.lnum] = DUPLICATES[key]
        yield error
1258461
def remove_positive_mask(X, y, model_generator, method_name, num_fcounts=11):
    
    return __run_measure(measures.remove_mask, X, y, model_generator, method_name, 1, num_fcounts, __mean_pred)
677447
public void clear()
    {
        count = 0;
        average = 0;
        max = Double.MIN_VALUE;
        min = Double.MAX_VALUE;
        deviationSquare = 0;
    }
949387
def clearOldCalibrations(self, date=None):
        '''
        
        '''
        self.coeffs['dark current'] = [self.coeffs['dark current'][-1]]
        self.coeffs['noise'] = [self.coeffs['noise'][-1]]

        for light in self.coeffs['flat field']:
            self.coeffs['flat field'][light] = [
                self.coeffs['flat field'][light][-1]]
        for light in self.coeffs['lens']:
            self.coeffs['lens'][light] = [self.coeffs['lens'][light][-1]]
105064
private void gaussNewton( double betas[] ) {

		A_temp.reshape(L_full.numRows, numControl);
		v_temp.reshape(L_full.numRows, 1);
		x.reshape(numControl,1,false);

		// don't check numControl inside in hope that the JVM can optimize the code better
		if( numControl == 4 ) {
			for( int i = 0; i < numIterations; i++ ) {
				UtilLepetitEPnP.jacobian_Control4(L_full,betas, A_temp);
				UtilLepetitEPnP.residuals_Control4(L_full,y,betas,v_temp.data);

				if( !solver.setA(A_temp) )
					return;

				solver.solve(v_temp,x);

				for( int j = 0; j < numControl; j++ ) {
					betas[j] -= x.data[j];
				}
			}
		} else {
			for( int i = 0; i < numIterations; i++ ) {
				UtilLepetitEPnP.jacobian_Control3(L_full,betas, A_temp);
				UtilLepetitEPnP.residuals_Control3(L_full,y,betas,v_temp.data);

				if( !solver.setA(A_temp) )
					return;

				solver.solve(v_temp,x);

				for( int j = 0; j < numControl; j++ ) {
					betas[j] -= x.data[j];
				}
			}
		}
	}
1318046
protected function removeNotImportantRemainingActions()
    {
        // remove remaining 'move' actions
        if (!empty($this->actions[self::GROUP_ADD])) {
            foreach ($this->actions[self::GROUP_ADD] as $index => $action) {
                if ($action[0] === self::MOVE) {
                    unset($this->actions[self::GROUP_ADD][$index]);
                }
            }
        }
        // remove remaining 'remove' actions if there are no any 'add' actions
        if (!empty($this->actions[self::GROUP_REMOVE]) && empty($this->actions[self::GROUP_ADD])) {
            unset($this->actions[self::GROUP_REMOVE]);
        }
    }