limiter_method and cumulator_method must be inverses
 i.e. :- and :+, or :/ and :*
358048
def limit_results(partial_results, limiter_method, cumulator_method)
      return [] if partial_results.empty? # guard clause
      results_allowed = results_allowed_from(partial_results, limiter_method)
      cumulate_total(results_allowed.length, cumulator_method)
      results_allowed
    end
703662
function(and1, and2) {
			var union1 = set.union(and1, and2.values[0]);
			var union2 = set.union(and1, and2.values[1]);

			if (isAndOrOr(union1) || isAndOrOr(union2)) {
				// try the other direction
				union1 = set.union(and2, and1.values[0]);
				union2 = set.union(and2, and1.values[1]);
			}
			if (isAndOrOr(union1) || isAndOrOr(union2)) {
				return new is.Or([and1, and2]);
			} else {
				return set.intersection(union1, union2);
			}

			/*
			var combo1 = [
					set.union(and1.values[0], and2.values[0]),
					set.union(and1.values[1], and2.values[1])
				],
				combo2 = [
					set.union(and1.values[0], and2.values[1]),
					set.union(and1.values[1], and2.values[0])
				];
			if(combo1.every(isUniversal)) {
				return set.intersection.apply(set, combo2);
			}
			if(combo2.every(isUniversal)) {
				return set.intersection.apply(set, combo1);
			}
			return new is.Or([and1, and2]);*/
		}
237014
def _append_base_arguments(self):
        
        if self.exc and self.only:
            raise PackerException('Cannot provide both "except" and "only"')
        elif self.exc:
            self._add_opt('-except={0}'.format(self._join_comma(self.exc)))
        elif self.only:
            self._add_opt('-only={0}'.format(self._join_comma(self.only)))
        for var, value in self.vars.items():
            self._add_opt("-var")
            self._add_opt("{0}={1}".format(var, value))
        if self.var_file:
            self._add_opt('-var-file={0}'.format(self.var_file))
1149227
function nelderMead(f, x0, parameters) {
        parameters = parameters || {};

        var maxIterations = parameters.maxIterations || x0.length * 200,
            nonZeroDelta = parameters.nonZeroDelta || 1.05,
            zeroDelta = parameters.zeroDelta || 0.001,
            minErrorDelta = parameters.minErrorDelta || 1e-6,
            minTolerance = parameters.minErrorDelta || 1e-5,
            rho = parameters.rho !== undefined ? parameters.rho : 1,
            chi = parameters.chi !== undefined ? parameters.chi : 2,
            psi = parameters.psi !== undefined ? parameters.psi : -0.5,
            sigma = parameters.sigma !== undefined ? parameters.sigma : 0.5,
            maxDiff;

        // initialize simplex.
        var N = x0.length,
            simplex = new Array(N + 1);
        simplex[0] = x0;
        simplex[0].fx = f(x0);
        simplex[0].id = 0;
        for (var i = 0; i < N; ++i) {
            var point = x0.slice();
            point[i] = point[i] ? point[i] * nonZeroDelta : zeroDelta;
            simplex[i + 1] = point;
            simplex[i + 1].fx = f(point);
            simplex[i + 1].id = i + 1;
        }

        function updateSimplex(value) {
            for (var i = 0; i < value.length; i++) {
                simplex[N][i] = value[i];
            }
            simplex[N].fx = value.fx;
        }

        var sortOrder = function sortOrder(a, b) {
            return a.fx - b.fx;
        };

        var centroid = x0.slice(),
            reflected = x0.slice(),
            contracted = x0.slice(),
            expanded = x0.slice();

        for (var iteration = 0; iteration < maxIterations; ++iteration) {
            simplex.sort(sortOrder);

            if (parameters.history) {
                // copy the simplex (since later iterations will mutate) and
                // sort it to have a consistent order between iterations
                var sortedSimplex = simplex.map(function (x) {
                    var state = x.slice();
                    state.fx = x.fx;
                    state.id = x.id;
                    return state;
                });
                sortedSimplex.sort(function (a, b) {
                    return a.id - b.id;
                });

                parameters.history.push({ x: simplex[0].slice(),
                    fx: simplex[0].fx,
                    simplex: sortedSimplex });
            }

            maxDiff = 0;
            for (i = 0; i < N; ++i) {
                maxDiff = Math.max(maxDiff, Math.abs(simplex[0][i] - simplex[1][i]));
            }

            if (Math.abs(simplex[0].fx - simplex[N].fx) < minErrorDelta && maxDiff < minTolerance) {
                break;
            }

            // compute the centroid of all but the worst point in the simplex
            for (i = 0; i < N; ++i) {
                centroid[i] = 0;
                for (var j = 0; j < N; ++j) {
                    centroid[i] += simplex[j][i];
                }
                centroid[i] /= N;
            }

            // reflect the worst point past the centroid  and compute loss at reflected
            // point
            var worst = simplex[N];
            weightedSum(reflected, 1 + rho, centroid, -rho, worst);
            reflected.fx = f(reflected);

            // if the reflected point is the best seen, then possibly expand
            if (reflected.fx < simplex[0].fx) {
                weightedSum(expanded, 1 + chi, centroid, -chi, worst);
                expanded.fx = f(expanded);
                if (expanded.fx < reflected.fx) {
                    updateSimplex(expanded);
                } else {
                    updateSimplex(reflected);
                }
            }

            // if the reflected point is worse than the second worst, we need to
            // contract
            else if (reflected.fx >= simplex[N - 1].fx) {
                    var shouldReduce = false;

                    if (reflected.fx > worst.fx) {
                        // do an inside contraction
                        weightedSum(contracted, 1 + psi, centroid, -psi, worst);
                        contracted.fx = f(contracted);
                        if (contracted.fx < worst.fx) {
                            updateSimplex(contracted);
                        } else {
                            shouldReduce = true;
                        }
                    } else {
                        // do an outside contraction
                        weightedSum(contracted, 1 - psi * rho, centroid, psi * rho, worst);
                        contracted.fx = f(contracted);
                        if (contracted.fx < reflected.fx) {
                            updateSimplex(contracted);
                        } else {
                            shouldReduce = true;
                        }
                    }

                    if (shouldReduce) {
                        // if we don't contract here, we're done
                        if (sigma >= 1) break;

                        // do a reduction
                        for (i = 1; i < simplex.length; ++i) {
                            weightedSum(simplex[i], 1 - sigma, simplex[0], sigma, simplex[i]);
                            simplex[i].fx = f(simplex[i]);
                        }
                    }
                } else {
                    updateSimplex(reflected);
                }
        }

        simplex.sort(sortOrder);
        return { fx: simplex[0].fx,
            x: simplex[0] };
    }
899857
def ignore_nan_inf(kde_method):
    
    def new_kde_method(events_x, events_y, xout=None, yout=None,
                       *args, **kwargs):
        bad_in = get_bad_vals(events_x, events_y)
        if xout is None:
            density = np.zeros_like(events_x, dtype=float)
            bad_out = bad_in
            xo = yo = None
        else:
            density = np.zeros_like(xout, dtype=float)
            bad_out = get_bad_vals(xout, yout)
            xo = xout[~bad_out]
            yo = yout[~bad_out]
        # Filter events
        ev_x = events_x[~bad_in]
        ev_y = events_y[~bad_in]
        density[~bad_out] = kde_method(ev_x, ev_y,
                                       xo, yo,
                                       *args, **kwargs)
        density[bad_out] = np.nan
        return density

    doc_add = "\n    Notes\n" +\
              "    -----\n" +\
              "    This is a wrapped version that ignores nan and inf values."
    new_kde_method.__doc__ = kde_method.__doc__ + doc_add

    return new_kde_method
1300659
function adjustOnComma(iLen, keepExpr, joinable) {
    // joinable for: ? [ ( OP
    if (iLen >= 3) {
      var tok4,
          tok5,
          tok1 = bPending[iLen - 1],
          tok2 = bPending[iLen - 2],
          tok3 = bPending[iLen - 3];
      var tp4,
          tp5,
          tp1 = tok1[0],
          tp2 = tok2[0],
          tp3 = tok3[0];
      if (iLen >= 5) {
        // expr ? expr : expr  --> expr_5
        tok4 = bPending[iLen - 4];tp4 = tok4[0];
        tok5 = bPending[iLen - 5];tp5 = tok5[0];
        if (!joinable && tp5 >= 31 && tp5 <= 43 && tp4 == 5 && tp3 >= 31 && tp3 <= 43 && tp2 == 6 && tp1 >= 31 && tp1 <= 43) {
          bPending.splice(iLen - 5, 5, [35, [tok5, tok4, tok3, tok2, tok1], tok5[2]]);
          return true;
        }
      }

      // expr OP expr  --> expr_4
      if (tp3 >= 31 && tp3 <= 43 && tp2 == 14 && tp1 >= 31 && tp1 <= 43) {
        bPending.splice(iLen - 3, 3);
        pushOpExpr(tok3, tok2, tok1, tok2[3]);
        return true;
      }

      // expr_list_2 : expr_list , expr
      if (!joinable && tp3 >= 51 && tp3 <= 52 && tp2 == 7 && tp1 >= 31 && tp1 <= 43) {
        bPending.splice(iLen - 3, 3, [52, [tok3, tok2, tok1], tok3[2]]);
        return true;
      }

      if (!joinable && tp3 >= 31 && tp3 <= 43 && tp2 == 6 && tp1 >= 31 && tp1 <= 43) {
        if (iLen >= 5 && tp5 >= 61 && tp5 <= 62 && tp4 == 7) {
          // expr_items_2 : expr_item , expr : expr
          bPending.splice(iLen - 5, 5, [62, [tok5, tok4, tok3, tok2, tok1], tok5[2]]);
        } else {
          // expr_items_1 : expr : expr
          bPending.splice(iLen - 3, 3, [61, [tok3, tok2, tok1], tok3[2]]);
        }
        return true;
      }
    }

    if (iLen >= 1 && !keepExpr) {
      // can not translate to expr_list if before ':'
      var tok1 = bPending[iLen - 1],
          tp1 = tok1[0];
      if (tp1 >= 31 && tp1 <= 43) {
        // expr  --> expr_list_1
        bPending.splice(iLen - 1, 1, [51, [tok1], tok1[2]]);
        return true;
      }
    }

    return false;
  }
443445
function getSuffix( $where, $orderBy = array(), $limitCount = null, $limitOffset = null ) {

        $suffix = "";

        if ( !empty( $where ) ) {

            $suffix .= " WHERE " . implode( " AND ", $where );

        }

        if ( !empty( $orderBy ) ) {

            $suffix .= " ORDER BY " . implode( ", ", $orderBy );

        }

        if ( isset( $limitCount ) ) {

            $suffix .= " LIMIT " . intval( $limitCount );

            if ( isset( $limitOffset ) ) {

                $suffix .= " OFFSET " . intval( $limitOffset );

            }

        }

        return $suffix;

    }
134313
def posargs_limiter(func, *args):
    
    posargs = inspect.getargspec(func)[0]
    length = len(posargs)
    if inspect.ismethod(func):
        length -= 1
    if length == 0:
        return func()
    return func(*args[0:length])
7688
def inverse(self):
        
        if self.is_any():
            return None
        else:
            bounds = self._inverse(self.bounds)
            range = VersionRange(None)
            range.bounds = bounds
            return range
1081592
def method_missing(sym, *args, &block)
      if (data && data[sym])
        data[sym]
      else
        super(sym, *args, &block)
      end
    end
895522
def method_missing(meth, *args, &block)
      if args.size == 1 and meth =~ /^(.+)=$/
        self[$1.to_sym] = args[0]
      else
        super meth, *args, &block
      end
    end
144922
def _arith_method_SERIES(cls, op, special):
    
    str_rep = _get_opstr(op, cls)
    op_name = _get_op_name(op, special)
    eval_kwargs = _gen_eval_kwargs(op_name)
    fill_zeros = _gen_fill_zeros(op_name)
    construct_result = (_construct_divmod_result
                        if op in [divmod, rdivmod] else _construct_result)

    def na_op(x, y):
        import pandas.core.computation.expressions as expressions
        try:
            result = expressions.evaluate(op, str_rep, x, y, **eval_kwargs)
        except TypeError:
            result = masked_arith_op(x, y, op)

        result = missing.fill_zeros(result, x, y, op_name, fill_zeros)
        return result

    def safe_na_op(lvalues, rvalues):
        """
        return the result of evaluating na_op on the passed in values

        try coercion to object type if the native types are not compatible

        Parameters
        ----------
        lvalues : array-like
        rvalues : array-like

        Raises
        ------
        TypeError: invalid operation
        """
        try:
            with np.errstate(all='ignore'):
                return na_op(lvalues, rvalues)
        except Exception:
            if is_object_dtype(lvalues):
                return libalgos.arrmap_object(lvalues,
                                              lambda x: op(x, rvalues))
            raise

    def wrapper(left, right):
        if isinstance(right, ABCDataFrame):
            return NotImplemented

        left, right = _align_method_SERIES(left, right)
        res_name = get_op_result_name(left, right)
        right = maybe_upcast_for_op(right)

        if is_categorical_dtype(left):
            raise TypeError("{typ} cannot perform the operation "
                            "{op}".format(typ=type(left).__name__, op=str_rep))

        elif is_datetime64_dtype(left) or is_datetime64tz_dtype(left):
            # Give dispatch_to_index_op a chance for tests like
            # test_dt64_series_add_intlike, which the index dispatching handles
            # specifically.
            result = dispatch_to_index_op(op, left, right, pd.DatetimeIndex)
            return construct_result(left, result,
                                    index=left.index, name=res_name,
                                    dtype=result.dtype)

        elif (is_extension_array_dtype(left) or
                (is_extension_array_dtype(right) and not is_scalar(right))):
            # GH#22378 disallow scalar to exclude e.g. "category", "Int64"
            return dispatch_to_extension_op(op, left, right)

        elif is_timedelta64_dtype(left):
            result = dispatch_to_index_op(op, left, right, pd.TimedeltaIndex)
            return construct_result(left, result,
                                    index=left.index, name=res_name)

        elif is_timedelta64_dtype(right):
            # We should only get here with non-scalar or timedelta64('NaT')
            #  values for right
            # Note: we cannot use dispatch_to_index_op because
            #  that may incorrectly raise TypeError when we
            #  should get NullFrequencyError
            result = op(pd.Index(left), right)
            return construct_result(left, result,
                                    index=left.index, name=res_name,
                                    dtype=result.dtype)

        lvalues = left.values
        rvalues = right
        if isinstance(rvalues, ABCSeries):
            rvalues = rvalues.values

        result = safe_na_op(lvalues, rvalues)
        return construct_result(left, result,
                                index=left.index, name=res_name, dtype=None)

    wrapper.__name__ = op_name
    return wrapper
683507
function (regexp, limit) {
        var res = maybeCallNative(internalSplit, regexp, this, limit, internalSplit !== nativeSplit);
        if (res.done) return res.value;

        var rx = anObject(regexp);
        var S = String(this);
        var C = speciesConstructor(rx, RegExp);

        var unicodeMatching = rx.unicode;
        var flags = (rx.ignoreCase ? 'i' : '') +
                    (rx.multiline ? 'm' : '') +
                    (rx.unicode ? 'u' : '') +
                    (SUPPORTS_Y ? 'y' : 'g');

        // ^(? + rx + ) is needed, in combination with some S slicing, to
        // simulate the 'y' flag.
        var splitter = new C(SUPPORTS_Y ? rx : '^(?:' + rx.source + ')', flags);
        var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
        if (lim === 0) return [];
        if (S.length === 0) return callRegExpExec(splitter, S) === null ? [S] : [];
        var p = 0;
        var q = 0;
        var A = [];
        while (q < S.length) {
          splitter.lastIndex = SUPPORTS_Y ? q : 0;
          var z = callRegExpExec(splitter, SUPPORTS_Y ? S : S.slice(q));
          var e;
          if (
            z === null ||
            (e = min(toLength(splitter.lastIndex + (SUPPORTS_Y ? 0 : q)), S.length)) === p
          ) {
            q = advanceStringIndex(S, q, unicodeMatching);
          } else {
            A.push(S.slice(p, q));
            if (A.length === lim) return A;
            for (var i = 1; i <= z.length - 1; i++) {
              A.push(z[i]);
              if (A.length === lim) return A;
            }
            q = p = e;
          }
        }
        A.push(S.slice(p));
        return A;
      }
858528
def And(*args: Union[Bool, bool]) -> Bool:
    """"""
    union = []
    args_list = [arg if isinstance(arg, Bool) else Bool(arg) for arg in args]
    for arg in args_list:
        union.append(arg.annotations)
    return Bool(z3.And([a.raw for a in args_list]), union)
223425
def restriction(self, lam, mean_field):
        """"""
        self.update_H(mean_field, lam)
        restric = np.array([self.expected(op) - n for op, n in zip(self.oper['Sz+1/2'], self.param['populations'])])
        return restric
208260
def _op_generic_StoU_saturation(self, value, min_value, max_value): #pylint:disable=no-self-use
        
        return claripy.If(
            claripy.SGT(value, max_value),
            max_value,
            claripy.If(claripy.SLT(value, min_value), min_value, value))
108532
def _arith_method_SPARSE_ARRAY(cls, op, special):
    
    op_name = _get_op_name(op, special)

    def wrapper(self, other):
        from pandas.core.arrays.sparse.array import (
            SparseArray, _sparse_array_op, _wrap_result, _get_fill)
        if isinstance(other, np.ndarray):
            if len(self) != len(other):
                raise AssertionError("length mismatch: {self} vs. {other}"
                                     .format(self=len(self), other=len(other)))
            if not isinstance(other, SparseArray):
                dtype = getattr(other, 'dtype', None)
                other = SparseArray(other, fill_value=self.fill_value,
                                    dtype=dtype)
            return _sparse_array_op(self, other, op, op_name)
        elif is_scalar(other):
            with np.errstate(all='ignore'):
                fill = op(_get_fill(self), np.asarray(other))
                result = op(self.sp_values, other)

            return _wrap_result(op_name, result, self.sp_index, fill)
        else:  # pragma: no cover
            raise TypeError('operation with {other} not supported'
                            .format(other=type(other)))

    wrapper.__name__ = op_name
    return wrapper