Returns the window size with the minimum Interleaved test-train error, using bisection (without recalculation using an incremental approximation).
513167
private int getMinErrorRateWindowSizeIncremental() {
		int numSamples = this.stm.numInstances();
		if (numSamples < 2 * this.minSTMSizeOption.getValue()) {
			return numSamples;
		} else {
			List<Integer> numSamplesRange = new ArrayList<>();
			numSamplesRange.add(numSamples);
			while (numSamplesRange.get(numSamplesRange.size() - 1) >= 2 * this.minSTMSizeOption.getValue())
				numSamplesRange.add(numSamplesRange.get(numSamplesRange.size() - 1) / 2);
			List<Double> errorRates = new ArrayList<>();
			for (Integer numSamplesIt : numSamplesRange) {
				int idx = numSamples - numSamplesIt;
				List<Integer> predHistory;
				if (this.predictionHistories.containsKey(idx)) {
					predHistory = this.getIncrementalTestTrainPredHistory(this.stm, idx, this.predictionHistories.get(idx));
				} else if (this.predictionHistories.containsKey(idx-1)){
					predHistory = this.predictionHistories.remove(idx-1);
					predHistory.remove(0);
					predHistory = this.getIncrementalTestTrainPredHistory(this.stm, idx, predHistory);
					this.predictionHistories.put(idx, predHistory);
				} else {
					predHistory = this.getTestTrainPredHistory(this.stm, idx);
					this.predictionHistories.put(idx, predHistory);
				}
				errorRates.add(this.getHistoryErrorRate(predHistory));
			}
			int minErrorRateIdx = errorRates.indexOf(Collections.min(errorRates));
			if (minErrorRateIdx > 0) {
				for (int i = 1; i < errorRates.size(); i++){
					if (errorRates.get(i) < errorRates.get(0)){
						int idx = numSamples - numSamplesRange.get(i);
						List<Integer> predHistory = this.getTestTrainPredHistory(this.stm, idx);
						errorRates.set(i, this.getHistoryErrorRate(predHistory));
						this.predictionHistories.remove(idx);
						this.predictionHistories.put(idx, predHistory);
					}
				}
				minErrorRateIdx = errorRates.indexOf(Collections.min(errorRates));
			}
			int windowSize = numSamplesRange.get(minErrorRateIdx);
			if (windowSize < numSamples) {
				this.adaptHistories(minErrorRateIdx);
			}
			return windowSize;
		}
	}
1143549
def min(self):
        
        return int(self._min) if not np.isinf(self._min) else self._min
192856
private int getPartitioningFanOutNoEstimates() {
		return Math.max(11, findSmallerPrime((int) Math.min(buildRowCount * avgRecordLen / (10 * segmentSize),
				MAX_NUM_PARTITIONS)));
	}
1298323
def size_from_win_api(verbose: nil)
      require 'fiddle'

      kernel32 = Fiddle::Handle.new('kernel32')
      get_std_handle = Fiddle::Function.new(kernel32['GetStdHandle'],
                        [-Fiddle::TYPE_INT], Fiddle::TYPE_INT)
      get_console_buffer_info = Fiddle::Function.new(
        kernel32['GetConsoleScreenBufferInfo'],
        [Fiddle::TYPE_LONG, Fiddle::TYPE_VOIDP], Fiddle::TYPE_INT)

      format        = 'SSSSSssssSS'
      buffer        = ([0] * format.size).pack(format)
      stdout_handle = get_std_handle.(STDOUT_HANDLE)

      get_console_buffer_info.(stdout_handle, buffer)
      _, _, _, _, _, left, top, right, bottom, = buffer.unpack(format)
      size = [bottom - top + 1, right - left + 1]
      return size if nonzero_column?(size[1] - 1)
    rescue LoadError
      warn 'no native fiddle module found' if verbose
    rescue Fiddle::DLError
      # non windows platform or no kernel32 lib
    end
870970
def get_minimum_size(self, data):
        """"""

        # Gat a list of elements with their sizes, so we don't have to
        # recalculate that each time.
        sized_elements = [
            (col, row, cols, rows, element, element.get_minimum_size(data))
            for col, row, cols, rows, element in self.elements
            ]

        # Create the heights and widths for each cell.
        self.col_widths = [0] * self.cols
        self.row_heights = [0] * self.rows
        self._compile_dimension_size(0, self.col_widths, 'x', sized_elements)
        self._compile_dimension_size(1, self.row_heights, 'y', sized_elements)

        # The final size is the total width and height
        om = 2*self.outside_margin
        return datatypes.Point(
            sum(self.col_widths) + (self.cols-1)*self.margin + om,
            sum(self.row_heights) + (self.rows-1)*self.margin + om
            )
601591
private void minimisationWithBinaryResolution(final LNGIntVector outLearnt) {
    long lbd = computeLBD(outLearnt, -1);
    int p = not(outLearnt.get(0));
    if (lbd <= lbLBDMinimizingClause) {
      myflag++;
      for (int i = 1; i < outLearnt.size(); i++)
        permDiff.set(var(outLearnt.get(i)), myflag);
      int nb = 0;
      for (final MSWatcher wbin : watchesBin.get(p)) {
        int imp = wbin.blocker();
        if (permDiff.get(var(imp)) == myflag && value(imp) == Tristate.TRUE) {
          nb++;
          permDiff.set(var(imp), myflag - 1);
        }
      }
      int l = outLearnt.size() - 1;
      if (nb > 0) {
        for (int i = 1; i < outLearnt.size() - nb; i++) {
          if (permDiff.get(var(outLearnt.get(i))) != myflag) {
            p = outLearnt.get(l);
            outLearnt.set(l, outLearnt.get(i));
            outLearnt.set(i, p);
            l--;
            i--;
          }
        }
        outLearnt.removeElements(nb);
      }
    }
  }
205610
def _cutoff(self, coeffs, vscale):
        
        bnd = self._threshold(vscale)
        inds  = np.nonzero(abs(coeffs) >= bnd)
        if len(inds[0]):
            N = inds[0][-1]
        else:
            N = 0
        return N+1
871981
private int slopSize(Versioned<Slop> slopVersioned) {
        int nBytes = 0;
        Slop slop = slopVersioned.getValue();
        nBytes += slop.getKey().length();
        nBytes += ((VectorClock) slopVersioned.getVersion()).sizeInBytes();
        switch(slop.getOperation()) {
            case PUT: {
                nBytes += slop.getValue().length;
                break;
            }
            case DELETE: {
                break;
            }
            default:
                logger.error("Unknown slop operation: " + slop.getOperation());
        }
        return nBytes;
    }
642486
def fit_freq_min_max(self, training_signal):
        

        window_length = len(self.window)
        window_weight = sum(self.window)
        max_mask = np.zeros(int(window_length / 2) + 1)
        min_mask = np.zeros(int(window_length / 2) + 1)

        for i in range(0, len(training_signal) - window_length - 1):
            rfft = np.fft.rfft(training_signal[i:i + window_length] * self.window)
            temp = np.abs(rfft) / window_weight
            max_mask = np.maximum(max_mask, temp)
            min_mask = np.minimum(min_mask, temp)

        self.mask_top = self.gain * max_mask
        self.mask_bottom = min_mask / self.gain
375635
public static int cudnnGetConvolutionBackwardFilterWorkspaceSize(
        cudnnHandle handle, 
        cudnnTensorDescriptor xDesc, 
        cudnnTensorDescriptor dyDesc, 
        cudnnConvolutionDescriptor convDesc, 
        cudnnFilterDescriptor gradDesc, 
        int algo, 
        long[] sizeInBytes)
    {
        return checkResult(cudnnGetConvolutionBackwardFilterWorkspaceSizeNative(handle, xDesc, dyDesc, convDesc, gradDesc, algo, sizeInBytes));
    }
1024534
def twos_comp_repr(val, bitwidth):
    
    correctbw = abs(val).bit_length() + 1
    if bitwidth < correctbw:
        raise pyrtl.PyrtlError("please choose a larger target bitwidth")
    if val >= 0:
        return val
    else:
        return (~abs(val) & (2**bitwidth-1)) + 1
909998
def _get_bin_width(stdev, count):
    

    w = int(round((3.5 * stdev) / (count ** (1.0 / 3))))
    if w:
        return w
    else:
        return 1
746722
def _get_window_out_shape(self, bands, window, xsize, ysize):
        

        if xsize and ysize is None:
            ratio = window.width / xsize
            ysize = math.ceil(window.height / ratio)
        elif ysize and xsize is None:
            ratio = window.height / ysize
            xsize = math.ceil(window.width / ratio)
        elif xsize is None and ysize is None:
            ysize = math.ceil(window.height)
            xsize = math.ceil(window.width)
        return (len(bands), ysize, xsize)
974861
private Integer getSmallestValidPoolSize(Integer poolSize, Double forecast) {
        Integer smallestPoolSize = threadStats.firstKey();
        Integer nextPoolSize = threadStats.higherKey(smallestPoolSize);
        Integer pruneSize = -1;
        boolean validSmallData = false;
        while (!validSmallData && nextPoolSize != null) {
            ThroughputDistribution smallestPoolSizeStats = getThroughputDistribution(smallestPoolSize, false);;
            // prune data that is too old or outside believable range
            if (pruneData(smallestPoolSizeStats, forecast)) {
                pruneSize = smallestPoolSize;
                smallestPoolSize = nextPoolSize;
                nextPoolSize = threadStats.higherKey(smallestPoolSize);
                if (pruneSize > hangBufferPoolSize && pruneSize > coreThreads) {
                    threadStats.remove(pruneSize);
                }
            } else {
                validSmallData = true;
            }
        }
        return smallestPoolSize;
    }
660251
def min(self):
        

        if len(self.regions) != 1:
            raise ClaripyVSAOperationError("'min()' onlly works on single-region value-sets.")

        return self.get_si(next(iter(self.regions))).min
914453
private final int calcSize () {

        int size = BasicHeaderSegment.BHS_FIXED_SIZE;
        size += basicHeaderSegment.getTotalAHSLength() * AdditionalHeaderSegment.AHS_FACTOR;

        // plus the sizes of the used digests
        size += headerDigest.getSize();
        size += dataDigest.getSize();

        size += AbstractDataSegment.getTotalLength(basicHeaderSegment.getDataSegmentLength());

        return size;
    }
411091
def compute_training_sizes(train_perc, class_sizes, stratified=True):
    

    size_per_class = np.int64(np.around(train_perc * class_sizes))

    if stratified:
        print("Different classes in training set are stratified to match smallest class!")

        # per-class
        size_per_class = np.minimum(np.min(size_per_class), size_per_class)

        # single number
        reduced_sizes = np.unique(size_per_class)
        if len(reduced_sizes) != 1:  # they must all be the same
            raise ValueError("Error in stratification of training set based on "
                             "smallest class!")

    total_test_samples = np.int64(np.sum(class_sizes) - sum(size_per_class))

    return size_per_class, total_test_samples