Perform a calculation for all regions.
433834
def region_calcs(self, arr, func):
        """"""
        # Get pressure values for data output on hybrid vertical coordinates.
        bool_pfull = (self.def_vert and self.dtype_in_vert ==
                      internal_names.ETA_STR and self.dtype_out_vert is False)
        if bool_pfull:
            pfull_data = self._get_input_data(_P_VARS[self.dtype_in_vert],
                                              self.start_date,
                                              self.end_date)
            pfull = self._full_to_yearly_ts(
                pfull_data, arr[internal_names.TIME_WEIGHTS_STR]
            ).rename('pressure')
        # Loop over the regions, performing the calculation.
        reg_dat = {}
        for reg in self.region:
            # Just pass along the data if averaged already.
            if 'av' in self.dtype_in_time:
                data_out = reg.ts(arr)
            # Otherwise perform the calculation.
            else:
                method = getattr(reg, func)
                data_out = method(arr)
                if bool_pfull:
                    # Don't apply e.g. standard deviation to coordinates.
                    if func not in ['av', 'ts']:
                        method = reg.ts
                    # Convert Pa to hPa
                    coord = method(pfull) * 1e-2
                    data_out = data_out.assign_coords(
                        **{reg.name + '_pressure': coord}
                    )
            reg_dat.update(**{reg.name: data_out})
        return xr.Dataset(reg_dat)
25405
def _xxrange(self, start, end, step_count):
        """"""
        _step = (end - start) / float(step_count)
        return (start + (i * _step) for i in xrange(int(step_count)))
799510
def _compute(self):
        """"""
        delta = 2 * pi / self._len if self._len else 0
        self._x_pos = [.5 * pi + i * delta for i in range(self._len + 1)]
        for serie in self.all_series:
            serie.points = [(v, self._x_pos[i])
                            for i, v in enumerate(serie.values)]
            if self.interpolate:
                extended_x_pos = ([.5 * pi - delta] + self._x_pos)
                extended_vals = (serie.values[-1:] + serie.values)
                serie.interpolated = list(
                    map(
                        tuple,
                        map(
                            reversed,
                            self._interpolate(extended_x_pos, extended_vals)
                        )
                    )
                )

        # x labels space
        self._box.margin *= 2
        self._rmin = self.zero
        self._rmax = self._max or 1
        self._box.set_polar_box(self._rmin, self._rmax)
        self._self_close = True
125293
def _ep_for_region(self, region):
        
        rgn = region.upper()
        try:
            rgn_ep = [ep for ep in list(self.endpoints.values())
                    if ep.region.upper() == rgn][0]
        except IndexError:
            # See if there is an 'ALL' region.
            try:
                rgn_ep = [ep for ep in list(self.endpoints.values())
                        if ep.region.upper() == "ALL"][0]
            except IndexError:
                rgn_ep = None
        return rgn_ep
852039
def calculate_columns(self):
        """"""

        self.cols = int(math.ceil(len(self.elements) / float(self.rows)))
5491
def _call(self, x):
        """"""
        return sum(fi(xi) for xi, fi in zip(x, self.functionals))
1120104
def _region_to_coords(region):
    
    chrom, coords = region.split(":")
    start, end = coords.split("-")
    return (chrom, int(start), int(end))
1165128
def validate_regions_schema(self, data):
        
        region_schema = RegionSchema()
        supplied_regions = data.get('regions', {})
        for region in supplied_regions.keys():
            result = region_schema.validate(supplied_regions[region])
            if len(result.keys()) > 0:
                raise ValidationError(result)
892234
def _call(self, x):
        """"""
        result = 0
        for i in range(0, self.domain.size - 1):
            result += (self.scale * (x[i + 1] - x[i] ** 2) ** 2 +
                       (x[i] - 1) ** 2)

        return result
241492
def _combine_regional_coverage(in_bams, samplenames, chrom, start, end, work_dir, data):
    
    dfs = [_calc_regional_coverage(bam, chrom, start, end, sample, work_dir, data) for bam, sample
           in zip(in_bams, samplenames)]
    return rbind(dfs)
729450
def calculateRange(self, values):
        
        self.reset()
        self._values = list(set(values))
        self._values.sort(key=lambda x: values.index(x))
841936
protected function calculateItemRanges()
	{
		$this->from = $this->total ? ($this->currentPage - 1) * $this->perPage + 1 : 0;

		$this->to = min($this->total, $this->currentPage * $this->perPage);
	}
505371
private void calcHiLoValues(double y, int index) {
        if (y < lo) {
            lo = y;
            loIndex = index;
        }

        if (y > hi) {
            hi = y;
            hiIndex = index;
        }
    }
1100552
def compute_total(self, precision=None):
        '''
        
        '''
        return quantize(sum([group.compute_total(precision) for group
                             in self.__groups]), places=precision) or ZERO
347014
protected void computeScoreFive( int top[] , int middle[] , int bottom[] , int score[] , int width ) {

		// disparity as the outer loop to maximize common elements in inner loops, reducing redundant calculations
		for( int d = minDisparity; d < maxDisparity; d++ ) {

			// take in account the different in image border between the sub-regions and the effective region
			int indexSrc = (d-minDisparity)*width + (d-minDisparity) + radiusX;
			int indexDst = (d-minDisparity)*width + (d-minDisparity);
			int end = indexSrc + (width-d-4*radiusX);
			while( indexSrc < end ) {
				int s = 0;

				// sample four outer regions at the corners around the center region
				int val0 = top[indexSrc-radiusX];
				int val1 = top[indexSrc+radiusX];
				int val2 = bottom[indexSrc-radiusX];
				int val3 = bottom[indexSrc+radiusX];

				// select the two best scores from outer for regions
				if( val1 < val0 ) {
					int temp = val0;
					val0 = val1;
					val1 = temp;
				}

				if( val3 < val2 ) {
					int temp = val2;
					val2 = val3;
					val3 = temp;
				}

				if( val3 < val0 ) {
					s += val2;
					s += val3;
				} else if( val2 < val1 ) {
					s += val2;
					s += val0;
				} else {
					s += val0;
					s += val1;
				}

				score[indexDst++] = s + middle[indexSrc++];
			}
		}
	}
716422
@Override
    public Object calculate(int[] coeff, int inPos, int[] quant, int[] out, int outOffset, int width, int height) {
        int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
        int tmp10, tmp11, tmp12, tmp13;
        int z5, z10, z11, z12, z13;

        int[] workspace = new int[64];

        int inptr = 0;
        int wsptr = 0;
        int[] outbuf = (out != null ? out : new int[DCTSIZE2]);
        int outptr = 0;
        short[] rangeLimitMap = sampleRangeLimitTable;
        int rangeLimitOffset = sampleRangeLimitOffset + 128;
        int dcval = 0, DCTSIZE = 8;

        int quantptr = 0;

        for (int ctr = 8; ctr > 0; ctr--) {
            int basis = 0;
            for (int n = 1; n < 8; n++) {
                basis |= coeff[inptr + DCTSIZE * n];
            }

            if (basis == 0) {
                dcval = coeff[inptr + DCTSIZE * 0] * quant[quantptr + DCTSIZE * 0];

                workspace[wsptr + DCTSIZE * 0] = dcval;
                workspace[wsptr + DCTSIZE * 1] = dcval;
                workspace[wsptr + DCTSIZE * 2] = dcval;
                workspace[wsptr + DCTSIZE * 3] = dcval;
                workspace[wsptr + DCTSIZE * 4] = dcval;
                workspace[wsptr + DCTSIZE * 5] = dcval;
                workspace[wsptr + DCTSIZE * 6] = dcval;
                workspace[wsptr + DCTSIZE * 7] = dcval;

                inptr++;
                quantptr++;
                wsptr++;

                continue;
            }

            tmp0 = coeff[inptr + DCTSIZE * 0] * quant[quantptr + DCTSIZE * 0];
            tmp1 = coeff[inptr + DCTSIZE * 2] * quant[quantptr + DCTSIZE * 2];
            tmp2 = coeff[inptr + DCTSIZE * 4] * quant[quantptr + DCTSIZE * 4];
            tmp3 = coeff[inptr + DCTSIZE * 6] * quant[quantptr + DCTSIZE * 6];
            tmp10 = tmp0 + tmp2;
            tmp11 = tmp0 - tmp2;

            tmp13 = tmp1 + tmp3;

            tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13;

            tmp0 = tmp10 + tmp13;
            tmp3 = tmp10 - tmp13;
            tmp1 = tmp11 + tmp12;
            tmp2 = tmp11 - tmp12;

            tmp4 = coeff[inptr + DCTSIZE * 1] * quant[quantptr + DCTSIZE * 1];
            tmp5 = coeff[inptr + DCTSIZE * 3] * quant[quantptr + DCTSIZE * 3];
            tmp6 = coeff[inptr + DCTSIZE * 5] * quant[quantptr + DCTSIZE * 5];
            tmp7 = coeff[inptr + DCTSIZE * 7] * quant[quantptr + DCTSIZE * 7];

            z13 = tmp6 + tmp5;
            z10 = tmp6 - tmp5;
            z11 = tmp4 + tmp7;
            z12 = tmp4 - tmp7;

            tmp7 = z11 + z13;
            tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562);

            z5 = MULTIPLY(z10 + z12, FIX_1_847759065);
            tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5;
            tmp12 = MULTIPLY(z10, -FIX_2_613125930) + z5;

            tmp6 = tmp12 - tmp7;
            tmp5 = tmp11 - tmp6;
            tmp4 = tmp10 + tmp5;

            workspace[wsptr + DCTSIZE * 0] = (tmp0 + tmp7);
            workspace[wsptr + DCTSIZE * 7] = (tmp0 - tmp7);
            workspace[wsptr + DCTSIZE * 1] = (tmp1 + tmp6);
            workspace[wsptr + DCTSIZE * 6] = (tmp1 - tmp6);
            workspace[wsptr + DCTSIZE * 2] = (tmp2 + tmp5);
            workspace[wsptr + DCTSIZE * 5] = (tmp2 - tmp5);
            workspace[wsptr + DCTSIZE * 4] = (tmp3 + tmp4);
            workspace[wsptr + DCTSIZE * 3] = (tmp3 - tmp4);

            inptr++;
            quantptr++;
            wsptr++;
        }

        wsptr = 0;
        for (int ctr = 0; ctr < DCTSIZE; ctr++) {
            outptr = ctr * 8;

            int basis = 0;
            for (int u = wsptr + 1; u < wsptr + 8; u++) {
                basis |= workspace[u];
            }
            if (basis == 0) {
                // AC terms all zero
                dcval = rangeLimitMap[rangeLimitOffset + ((workspace[wsptr] >> 5) & RANGE_MASK)];

                outbuf[outptr + 0] = dcval;
                outbuf[outptr + 1] = dcval;
                outbuf[outptr + 2] = dcval;
                outbuf[outptr + 3] = dcval;
                outbuf[outptr + 4] = dcval;
                outbuf[outptr + 5] = dcval;
                outbuf[outptr + 6] = dcval;
                outbuf[outptr + 7] = dcval;

                wsptr += DCTSIZE;
                continue;
            }

            tmp10 = (workspace[wsptr + 0] + workspace[wsptr + 4]);
            tmp11 = (workspace[wsptr + 0] - workspace[wsptr + 4]);

            tmp13 = (workspace[wsptr + 2] + workspace[wsptr + 6]);
            tmp12 = MULTIPLY(workspace[wsptr + 2] - workspace[wsptr + 6], FIX_1_414213562) - tmp13;

            tmp0 = tmp10 + tmp13;
            tmp3 = tmp10 - tmp13;
            tmp1 = tmp11 + tmp12;
            tmp2 = tmp11 - tmp12;

            z13 = workspace[wsptr + 5] + workspace[wsptr + 3];
            z10 = workspace[wsptr + 5] - workspace[wsptr + 3];
            z11 = workspace[wsptr + 1] + workspace[wsptr + 7];
            z12 = workspace[wsptr + 1] - workspace[wsptr + 7];

            tmp7 = z11 + z13;
            tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562);

            z5 = MULTIPLY(z10 + z12, FIX_1_847759065);
            tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5;
            tmp12 = MULTIPLY(z10, (-FIX_2_613125930)) + z5;

            tmp6 = tmp12 - tmp7;
            tmp5 = tmp11 - tmp6;
            tmp4 = tmp10 + tmp5;

            outbuf[outptr + 0] = rangeLimitMap[rangeLimitOffset + (IDESCALE(tmp0 + tmp7, PASS1_BITS + 3) & RANGE_MASK)];
            outbuf[outptr + 7] = rangeLimitMap[rangeLimitOffset + (IDESCALE(tmp0 - tmp7, PASS1_BITS + 3) & RANGE_MASK)];
            outbuf[outptr + 1] = rangeLimitMap[rangeLimitOffset + (IDESCALE(tmp1 + tmp6, PASS1_BITS + 3) & RANGE_MASK)];
            outbuf[outptr + 6] = rangeLimitMap[rangeLimitOffset + (IDESCALE(tmp1 - tmp6, PASS1_BITS + 3) & RANGE_MASK)];
            outbuf[outptr + 2] = rangeLimitMap[rangeLimitOffset + (IDESCALE(tmp2 + tmp5, PASS1_BITS + 3) & RANGE_MASK)];
            outbuf[outptr + 5] = rangeLimitMap[rangeLimitOffset + (IDESCALE(tmp2 - tmp5, PASS1_BITS + 3) & RANGE_MASK)];
            outbuf[outptr + 4] = rangeLimitMap[rangeLimitOffset + (IDESCALE(tmp3 + tmp4, PASS1_BITS + 3) & RANGE_MASK)];
            outbuf[outptr + 3] = rangeLimitMap[rangeLimitOffset + (IDESCALE(tmp3 - tmp4, PASS1_BITS + 3) & RANGE_MASK)];

            wsptr += DCTSIZE;
        }

        return outbuf;
    }
1318716
def calculate_set_values(self):
        
        for ac in self.asset_classes:
            ac.alloc_value = self.total_amount * ac.allocation / Decimal(100)