Asserts that the parameters are log-normalized within some delta.
504245
public static void assertLogNormalized(double[] logProps, double delta) {
        double logPropSum = DoubleArrays.logSum(logProps);
        assert(Primitives.equals(0.0, logPropSum, delta));
    }
468358
def normalize(self):
        
        maximum = self.max()
        if maximum:
            self.values = [value / maximum for value in self.values]
138937
def normalize(v):
    ''''''
    if 0 == np.linalg.norm(v):
        return v
    return v / np.linalg.norm(v)
573962
private void init() {
        if (x == null) {
            x = new double[z[0].length];
            for (int i = 0; i < x.length; i++) {
                x[i] = i + 0.5;
            }

        }

        if (y == null) {
            y = new double[z.length];
            for (int i = 0; i < y.length; i++) {
                y[i] = i + 0.5;
            }

            double[][] zz = new double[z.length][];
            for (int i = 0; i < z.length; i++) {
                zz[i] = z[z.length - i - 1];
            }
            z = zz;
        }

        zMin = Math.min(z);
        zMax = Math.max(z);

        contours = new ArrayList<>(numLevels);

        if (logScale && zMin <= 0.0) {
            throw new IllegalArgumentException("Log scale is not support for non-positive data");
        }

        if (levels == null) {
            if (logScale) {
                double lowerBound = Math.ceil(Math.log10(zMin));
                double upperBound = Math.floor(Math.log10(zMax));

                int n = (int) Math.round(upperBound - lowerBound);
                if (n == 0) {
                    logScale = false;
                }

                numLevels = n + 1;
                levels = new double[numLevels];

                for (int i = 0; i < numLevels; i++) {
                    levels[i] = Math.pow(10, lowerBound + i);
                }
            }

            if (levels == null) {
                double digits = Math.log10(Math.abs(zMax - zMin));
                double residual = digits - Math.floor(digits);
                if (residual < 0.4) {
                    // If the range is less than 20 units, we reduce one level.
                    digits -= 1.0;
                }

                double precisionDigits = (int) Math.floor(digits);
                double precisionUnit = Math.pow(10, precisionDigits);

                if (residual >= 0.4 && residual <= 0.7) {
                    // In case of too few grids, we use a half of precision unit.
                    precisionUnit /= 2;
                    precisionDigits -= 1;
                }

                double lowerBound = precisionUnit * (Math.ceil(zMin / precisionUnit));
                double upperBound = precisionUnit * (Math.floor(zMax / precisionUnit));

                numLevels = (int) Math.round((upperBound - lowerBound) / precisionUnit) + 1;
                levels = new double[numLevels];

                for (int i = 0; i < numLevels; i++) {
                    levels[i] = lowerBound + i * precisionUnit;
                }
            }
        }

        double[] xx = new double[4];
        double[] yy = new double[4];
        int[] ij = new int[2];

        int nx = x.length;
        int ny = y.length;
        Segment[][] segments = new Segment[ny][nx];
        double atom = 1E-7 * (zMax - zMin);

        for (int c = 0; c < levels.length; c++) {
            double zc = levels[c];
            for (int i = 0; i < nx; i++) {
                for (int j = 0; j < ny; j++) {
                    segments[j][i] = null;
                }
            }

            for (int i = 0; i < nx - 1; i++) {
                double xl = x[i];
                double xh = x[i + 1];
                for (int j = 0; j < ny - 1; j++) {
                    double yl = y[j];
                    double yh = y[j + 1];

                    double zll = z[j][i];
                    double zhl = z[j][i + 1];
                    double zlh = z[j + 1][i];
                    double zhh = z[j + 1][i + 1];

                    // If the value at a corner is exactly equal to a contour level,
                    // change that value by a tiny amount
                    if (zll == zc) {
                        zll += atom;
                    }

                    if (zhl == zc) {
                        zhl += atom;
                    }

                    if (zlh == zc) {
                        zlh += atom;
                    }

                    if (zhh == zc) {
                        zhh += atom;
                    }

                    // Check for intersections with sides
                    int nacode = 0;
                    if (!Double.isInfinite(zll)) {
                        nacode += 1;
                    }
                    if (!Double.isInfinite(zhl)) {
                        nacode += 2;
                    }
                    if (!Double.isInfinite(zlh)) {
                        nacode += 4;
                    }
                    if (!Double.isInfinite(zhh)) {
                        nacode += 8;
                    }

                    int k = 0;
                    switch (nacode) {
                        case 15:
                            if (isIntersect(zll, zhl, zc)) {
                                double f = getIntersectRatio(zll, zhl, zc);
                                xx[k] = xl + f * (xh - xl);
                                yy[k] = yl;
                                k++;
                            }

                            if (isIntersect(zll, zlh, zc)) {
                                double f = getIntersectRatio(zll, zlh, zc);
                                yy[k] = yl + f * (yh - yl);
                                xx[k] = xl;
                                k++;
                            }

                            if (isIntersect(zhl, zhh, zc)) {
                                double f = getIntersectRatio(zhl, zhh, zc);
                                yy[k] = yl + f * (yh - yl);
                                xx[k] = xh;
                                k++;
                            }

                            if (isIntersect(zlh, zhh, zc)) {
                                double f = getIntersectRatio(zlh, zhh, zc);
                                xx[k] = xl + f * (xh - xl);
                                yy[k] = yh;
                                k++;
                            }
                            break;

                        case 14:
                            if (isIntersect(zhl, zhh, zc)) {
                                double f = getIntersectRatio(zhl, zhh, zc);
                                yy[k] = yl + f * (yh - yl);
                                xx[k] = xh;
                                k++;
                            }
                            if (isIntersect(zlh, zhh, zc)) {
                                double f = getIntersectRatio(zlh, zhh, zc);
                                xx[k] = xl + f * (xh - xl);
                                yy[k] = yh;
                                k++;
                            }
                            if (isIntersect(zlh, zhl, zc)) {
                                double f = getIntersectRatio(zlh, zhl, zc);
                                xx[k] = xl + f * (xh - xl);
                                yy[k] = yh + f * (yl - yh);
                                k++;
                            }
                            break;

                        case 13:
                            if (isIntersect(zll, zlh, zc)) {
                                double f = getIntersectRatio(zll, zlh, zc);
                                yy[k] = yl + f * (yh - yl);
                                xx[k] = xl;
                                k++;
                            }
                            if (isIntersect(zlh, zhh, zc)) {
                                double f = getIntersectRatio(zlh, zhh, zc);
                                xx[k] = xl + f * (xh - xl);
                                yy[k] = yh;
                                k++;
                            }
                            if (isIntersect(zll, zhh, zc)) {
                                double f = getIntersectRatio(zll, zhh, zc);
                                xx[k] = xl + f * (xh - xl);
                                yy[k] = yl + f * (yh - yl);
                                k++;
                            }
                            break;

                        case 11:
                            if (isIntersect(zhl, zhh, zc)) {
                                double f = getIntersectRatio(zhl, zhh, zc);
                                yy[k] = yl + f * (yh - yl);
                                xx[k] = xh;
                                k++;
                            }
                            if (isIntersect(zll, zhl, zc)) {
                                double f = getIntersectRatio(zll, zhl, zc);
                                xx[k] = xl + f * (xh - xl);
                                yy[k] = yl;
                                k++;
                            }
                            if (isIntersect(zll, zhh, zc)) {
                                double f = getIntersectRatio(zll, zhh, zc);
                                xx[k] = xl + f * (xh - xl);
                                yy[k] = yl + f * (yh - yl);
                                k++;
                            }
                            break;

                        case 7:
                            if (isIntersect(zll, zlh, zc)) {
                                double f = getIntersectRatio(zll, zlh, zc);
                                yy[k] = yl + f * (yh - yl);
                                xx[k] = xl;
                                k++;
                            }
                            if (isIntersect(zll, zhl, zc)) {
                                double f = getIntersectRatio(zll, zhl, zc);
                                xx[k] = xl + f * (xh - xl);
                                yy[k] = yl;
                                k++;
                            }
                            if (isIntersect(zlh, zhl, zc)) {
                                double f = getIntersectRatio(zlh, zhl, zc);
                                xx[k] = xl + f * (xh - xl);
                                yy[k] = yh + f * (yl - yh);
                                k++;
                            }
                            break;
                    }

                    // We now have k(=2,4) endpoints. Decide which to join.
                    Segment seglist = null;
                    if (k > 0) {
                        if (k == 2) {
                            seglist = new Segment(xx[0], yy[0], xx[1], yy[1], seglist);
                        } else if (k == 4) {
                            for (k = 3; k >= 1; k--) {
                                int m = k;
                                xl = xx[k];
                                for (int l = 0; l < k; l++) {
                                    if (xx[l] > xl) {
                                        xl = xx[l];
                                        m = l;
                                    }
                                }

                                if (m != k) {
                                    xl = xx[k];
                                    yl = yy[k];
                                    xx[k] = xx[m];
                                    yy[k] = yy[m];
                                    xx[m] = xl;
                                    yy[m] = yl;
                                }
                            }

                            seglist = new Segment(xx[0], yy[0], xx[1], yy[1], seglist);
                            seglist = new Segment(xx[2], yy[2], xx[3], yy[3], seglist);
                        } else {
                            throw new IllegalStateException("k != 2 or 4");
                        }
                    }

                    segments[j][i] = seglist;
                }
            }

            // Begin following contours.
            // 1. Grab a segment
            // 2. Follow its tail
            // 3. Follow its head
            // 4. Save the contour
            for (int i = 0; i < nx - 1; i++) {
                for (int j = 0; j < ny - 1; j++) {
                    Segment seglist = null;
                    while ((seglist = segments[j][i]) != null) {
                        ij[0] = i;
                        ij[1] = j;

                        Segment start = seglist;
                        Segment end = seglist;
                        segments[j][i] = seglist.next;

                        double xend = seglist.x1;
                        double yend = seglist.y1;

                        int dir = 0;
                        while ((dir = segdir(xend, yend, ij)) != 0) {
                            // tail
                            int ii = ij[0];
                            int jj = ij[1];
                            Segment[] seg = {segments[jj][ii], null};
                            segments[jj][ii] = segupdate(xend, yend, dir, true, seg);
                            if (seg[1] == null) {
                                break;
                            }
                            end.next = seg[1];
                            end = seg[1];
                            xend = end.x1;
                            yend = end.y1;
                        }

                        end.next = null;
                        ij[0] = i;
                        ij[1] = j;
                        xend = seglist.x0;
                        yend = seglist.y0;
                        dir = 0;
                        while ((dir = segdir(xend, yend, ij)) != 0) {
                            // head
                            int ii = ij[0];
                            int jj = ij[1];
                            Segment[] seg = {segments[jj][ii], null};
                            segments[jj][ii] = segupdate(xend, yend, dir, false, seg);
                            if (seg[1] == null) {
                                break;
                            }
                            seg[1].next = start;
                            start = seg[1];
                            xend = start.x0;
                            yend = start.y0;
                        }

                        // Save the contour locations into the list of contours
                        Isoline contour = new Isoline(zc);
                        if (colors != null) {
                            contour.color = colors[c];
                        }

                        Segment s = start;
                        contour.add(s.x0, s.y0);
                        while (s.next != null) {
                            s = s.next;
                            contour.add(s.x0, s.y0);
                        }
                        contour.add(s.x1, s.y1);
                        
                        if (!contour.points.isEmpty()) {
                            contours.add(contour);
                        }
                    }
                }
            }
        }
    }
416354
def sanitize_config_loglevel(level):
    '''
    
    '''
    if sys.version_info[:2] != (2, 6) or isinstance(level, (int, long)):
        return level
    lvl = None
    if isinstance(level, basestring):
        lvl = logging._levelNames.get(level)
    if not lvl:
        raise ValueError('Invalid log level, %s' % level)
    return lvl
1085155
def log_normalize(data):
    
    if sp.issparse(data):
        data = data.copy()
        data.data = np.log2(data.data + 1)
        return data

    return np.log2(data.astype(np.float64) + 1)
694104
def assert_in_with_tolerance(obj, seq, tolerance, message=None, extra=None):
    """"""
    for i in seq:
        try:
            assert_eq(obj, i, tolerance=tolerance, message=message, extra=extra)
            return
        except AssertionError:
            pass
    assert False, _assert_fail_message(message, obj, seq, "is not in", extra)
501133
private void checkNormalization(Node externs, Node root) {
    // Verify nothing has inappropriately denormalize the AST.
    CodeChangeHandler handler = new ForbiddenChange();
    compiler.addChangeHandler(handler);

    // TODO(johnlenz): Change these normalization checks Preconditions and
    // Exceptions into Errors so that it is easier to find the root cause
    // when there are cascading issues.
    new PrepareAst(compiler, true).process(null, root);
    if (compiler.getLifeCycleStage().isNormalized()) {
      (new Normalize(compiler, true)).process(externs, root);

      if (compiler.getLifeCycleStage().isNormalizedUnobfuscated()) {
        boolean checkUserDeclarations = true;
        CompilerPass pass = new Normalize.VerifyConstants(compiler, checkUserDeclarations);
        pass.process(externs, root);
      }
    }

    compiler.removeChangeHandler(handler);
  }
544569
def verify_log(opts):
    '''
    
    '''
    level = LOG_LEVELS.get(str(opts.get('log_level')).lower(), logging.NOTSET)

    if level < logging.INFO:
        log.warning('Insecure logging configuration detected! Sensitive data may be logged.')
1202794
public void assertAtLeastOneDefined(final String param1, final String param2) {
    if (!isPresent(param1) && !isPresent(param2)) {
      throw new ParameterException(
          String.format("At least one of %s and %s must be defined.", param1, param2));
    }
  }
676676
def lognormal(mu, sigma, random_state):
    '''
    
    '''
    return np.exp(normal(mu, sigma, random_state))
185457
def _verify_assumptions(self):
        """"""
        text = self.annotation
        keys = text.keys()

        if '$MODE' not in text or text['$MODE'] != 'L':
            raise ParserFeatureNotImplementedError(u'Mode not implemented')

        if '$P0B' in keys:
            raise ParserFeatureNotImplementedError(u'Not expecting a parameter starting at 0')

        if text['$BYTEORD'] not in ['1,2,3,4', '4,3,2,1', '1,2', '2,1']:
            raise ParserFeatureNotImplementedError(u'$BYTEORD {} '
                                                   u'not implemented'.format(text['$BYTEORD']))
48318
function assertThreshold(value, other, threshold) {
  if (!threshold && value > other) throw new ThresholdError();
  const ratio = 1 - (value / other);
  if (ratio < threshold) throw new ThresholdError();
}
1008582
void normalizeY(double yMax, int normMax) {
		exploded.forEach(y -> {
			int norm = (int) Math.round((y / yMax) * normMax);
			normalized.add(norm);
		});
	}
622926
def interpolate_logscale(start, end, steps):
    
    if start <= 0.0:
        warnings.warn("Start of logscale interpolation must be positive!")
        start = 1e-5

    return np.logspace(np.log10(float(start)), np.log10(float(end)), steps)
478510
final void normalize() {
        if (intLen == 0) {
            offset = 0;
            return;
        }

        int index = offset;
        if (value[index] != 0)
            return;

        int indexBound = index+intLen;
        do {
            index++;
        } while(index < indexBound && value[index] == 0);

        int numZeros = index - offset;
        intLen -= numZeros;
        offset = (intLen == 0 ?  0 : offset+numZeros);
    }
70927
def enforce_bounds(self):
        
        too_big = self.parameter_data.loc[:,"parval1"] > \
            self.parameter_data.loc[:,"parubnd"]
        self.parameter_data.loc[too_big,"parval1"] = \
            self.parameter_data.loc[too_big,"parubnd"]

        too_small = self.parameter_data.loc[:,"parval1"] < \
            self.parameter_data.loc[:,"parlbnd"]
        self.parameter_data.loc[too_small,"parval1"] = \
            self.parameter_data.loc[too_small,"parlbnd"]