Raises informative exception for an invalid decomposition
505649
def _raise_decomposition_errors(uvw, antenna1, antenna2,
                                chunks, ant_uvw, max_err):
    

    start = 0

    problem_str = []

    for ci, chunk in enumerate(chunks):
        end = start + chunk

        ant1 = antenna1[start:end]
        ant2 = antenna2[start:end]
        cuvw = uvw[start:end]

        ant1_uvw = ant_uvw[ci, ant1, :]
        ant2_uvw = ant_uvw[ci, ant2, :]
        ruvw = ant2_uvw - ant1_uvw

        # Identifty rows where any of the UVW components differed
        close = np.isclose(ruvw, cuvw)
        problems = np.nonzero(np.logical_or.reduce(np.invert(close), axis=1))

        for row in problems[0]:
            problem_str.append("[row %d [%d, %d] (chunk %d)]: "
                               "original %s recovered %s "
                               "ant1 %s ant2 %s" % (
                                    start+row, ant1[row], ant2[row], ci,
                                    cuvw[row], ruvw[row],
                                    ant1_uvw[row], ant2_uvw[row]))

            # Exit inner loop early
            if len(problem_str) >= max_err:
                break

        # Exit outer loop early
        if len(problem_str) >= max_err:
            break

        start = end

    # Return early if nothing was wrong
    if len(problem_str) == 0:
        return

    # Add a preamble and raise exception
    problem_str = ["Antenna UVW Decomposition Failed",
                   "The following differences were found "
                   "(first 100):"] + problem_str
    raise AntennaUVWDecompositionError('\n'.join(problem_str))
578105
function invalidValue(
    env,            // :: Array Type
    typeInfo,       // :: TypeInfo
    index,          // :: Integer
    propPath,       // :: PropPath
    value           // :: Any
  ) {
    var t = resolvePropPath (typeInfo.types[index], propPath);

    var underlinedTypeVars =
    underline (typeInfo,
               K (K (_)),
               formatType6 (Z.concat ([index], propPath)));

    return new TypeError (trimTrailingSpaces (
      t.type === VARIABLE &&
      isEmpty (determineActualTypesLoose (env, [value])) ?
        'Unrecognized value\n\n' +
        underlinedTypeVars + '\n' +
        showValuesAndTypes (env, typeInfo, [value], 1) + '\n\n' +
        toMarkdownList (
          'The environment is empty! ' +
          'Polymorphic functions require a non-empty environment.\n',
          'The value at position 1 is not a member of any type in ' +
          'the environment.\n\n' +
          'The environment contains the following types:\n\n',
          showTypeWith (typeInfo.types),
          env
        ) :
      // else
        'Invalid value\n\n' +
        underlinedTypeVars + '\n' +
        showValuesAndTypes (env, typeInfo, [value], 1) + '\n\n' +
        'The value at position 1 is not a member of ' +
        q (show (t)) + '.\n' +
        see (arityGte (1) (t) ? 'type constructor' : 'type', t)
    ));
  }
395126
def make_exception(method, e):
    """"""
    x = e.details()
    name = x[:x.find(':')].split('.')[-1]
    if name in globals():
        cls = globals()[name]
    else:
        cls = UnknownRpcException  # noqa

    return cls(method, e.code(), e.details())
798233
def unpack(self, value):
        
        # Wrap errors in FailReplies with information identifying the parameter
        try:
            return self._kattype.unpack(value, self.major)
        except ValueError, message:
            raise FailReply("Error in parameter %s (%s): %s" %
                            (self.position, self.name, message))
706395
def p_Exception(p):
  
  p[0] = model.Exception(name=p[2], parent=p[3], members=p[5])
202688
def raise_exception(self, node, exc=None, msg='', expr=None,
                        lineno=None):
        """"""
        if self.error is None:
            self.error = []
        if expr is None:
            expr = self.expr
        if len(self.error) > 0 and not isinstance(node, ast.Module):
            msg = '%s' % msg
        err = ExceptionHolder(node, exc=exc, msg=msg, expr=expr, lineno=lineno)
        self._interrupt = ast.Break()
        self.error.append(err)
        if self.error_msg is None:
            self.error_msg = "at expr='%s'" % (self.expr)
        elif len(msg) > 0:
            self.error_msg = msg
        if exc is None:
            try:
                exc = self.error[0].exc
            except:
                exc = RuntimeError
        raise exc(self.error_msg)
1159074
def wrap_invalid_resp_data_error(function):
    """"""

    @functools.wraps(function)
    def decorated_function(*arg, **kwargs):
        try:
            return function(*arg, **kwargs)
        except (ValueError, TypeError, IndexError, AttributeError,
                KeyError) as err:
            msg = ('Invalid smt response data. Error: %s' %
                   six.text_type(err))
            LOG.error(msg)
            raise exception.SDKInternalError(msg=msg)

    return decorated_function
1235639
def update_exc(base_exceptions, *addition_dicts):
    
    exc = dict(base_exceptions)
    for additions in addition_dicts:
        for orth, token_attrs in additions.items():
            if not all(isinstance(attr[ORTH], unicode_) for attr in token_attrs):
                raise ValueError(Errors.E055.format(key=orth, orths=token_attrs))
            described_orth = "".join(attr[ORTH] for attr in token_attrs)
            if orth != described_orth:
                raise ValueError(Errors.E056.format(key=orth, orths=described_orth))
        exc.update(additions)
    exc = expand_exc(exc, "'", "’")
    return exc
713343
def decomprest(f, rows):
    """"""

    row = 0
    while row < rows:
        row, o = deblock(f)
        yield o
41476
def _raise_on_error(data):
    """"""
    if isinstance(data, list):
        data = data[0]

    if isinstance(data, dict) and 'error' in data:
        raise_error(data['error'])
1284947
def assert_or_raise(stmt: bool, exception: Exception,
                    *exception_args, **exception_kwargs) -> None:
  
  if not stmt:
    raise exception(*exception_args, **exception_kwargs)
880242
def _std_err(self):
        
        return np.sqrt(np.sum(np.square(self._resids), axis=1) / self._df_err)
298979
def check_alpha(a):
    

    a = check_1d(a, "alpha")
    if any(map(lambda d: d <= 0, a)):
        raise Exception('Alpha cannot be 0 or negative')

    return a
110388
def parametererror(self):
        """"""
        for parametergroup, parameters in self.parameters: #pylint: disable=unused-variable
            for parameter in parameters:
                if parameter.error:
                    return parameter.error
        return False
1077997
@Execute
    public void process() throws Exception {
        if (!concatOr(outPit == null, doReset)) {
            return;
        }
        checkNull(inElev);
        HashMap<String, Double> regionMap = CoverageUtilities.getRegionParamsFromGridCoverage(inElev);
        nCols = regionMap.get(CoverageUtilities.COLS).intValue();
        nRows = regionMap.get(CoverageUtilities.ROWS).intValue();
        xRes = regionMap.get(CoverageUtilities.XRES);
        yRes = regionMap.get(CoverageUtilities.YRES);

        elevationIter = CoverageUtilities.getRandomIterator(inElev);

        // output raster
        WritableRaster pitRaster = CoverageUtilities.createWritableRaster(nCols, nRows, null, null, null);
        pitIter = CoverageUtilities.getWritableRandomIterator(pitRaster);

        for( int i = 0; i < nRows; i++ ) {
            if (pm.isCanceled()) {
                return;
            }
            for( int j = 0; j < nCols; j++ ) {
                double value = elevationIter.getSampleDouble(j, i, 0);
                if (!isNovalue(value)) {
                    pitIter.setSample(j, i, 0, value);
                } else {
                    pitIter.setSample(j, i, 0, PITNOVALUE);
                }
            }
        }

        flood();
        if (pm.isCanceled()) {
            return;
        }

        for( int i = 0; i < nRows; i++ ) {
            if (pm.isCanceled()) {
                return;
            }
            for( int j = 0; j < nCols; j++ ) {
                if (dir[j][i] == 0) {
                    return;
                }
                double value = pitIter.getSampleDouble(j, i, 0);
                if (value == PITNOVALUE || isNovalue(value)) {
                    pitIter.setSample(j, i, 0, doubleNovalue);
                }
            }
        }
        pitIter.done();

        outPit = CoverageUtilities.buildCoverage("pitfiller", pitRaster, regionMap, inElev.getCoordinateReferenceSystem());
    }
1037795
def exception_set(self, exception=None):
        
        if not exception:
            exception = sys.exc_info()
        self.exception = exception
        self.exception_raise = self._exception_raise
645970
def coerce(cls, arg):
        """"""
        try:
            return cls(arg).value
        except (ValueError, TypeError):
            raise InvalidParameterDatatype("%s coerce error" % (cls.__name__,))