Enforce the bounds on x if only infinitesimal violations occurs
971813
def _enforce_bounds(self, x):
        """""""
        assert len(x) == len(self.bounds)
        x_enforced = []
        for x_i, (lb, ub) in zip(x, self.bounds):
            if x_i < lb:
                if x_i > lb - (ub-lb)/1e10:
                    x_enforced.append(lb)
                else:
                    x_enforced.append(x_i)
            elif x_i > ub:
                if x_i < ub + (ub-lb)/1e10:
                    x_enforced.append(ub)
                else:
                    x_enforced.append(x_i)
            else:
                x_enforced.append(x_i)
        return np.array(x_enforced)
1061261
function expandYBounds(bounds, value) {
  if (bounds[MIN_Y] > value) bounds[MIN_Y] = value;else if (bounds[MAX_Y] < value) bounds[MAX_Y] = value;
}
175935
def block_offset_bounds(self, namespace):
        """"""
        cursor = self.cursor
        cursor.execute('SELECT MIN("offset"), MAX("offset") '
                       'FROM gauged_statistics WHERE namespace = %s',
                       (namespace,))
        return cursor.fetchone()
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)
704527
def _set_bounds(self, bounds):
        """"""

        # Use the properties so that the checks and the handling of units are made automatically

        min_value, max_value = bounds

        # Remove old boundaries to avoid problems with the new one, if the current value was within the old boundaries
        # but is not within the new ones (it will then be adjusted automatically later)
        self.min_value = None
        self.max_value = None

        self.min_value = min_value

        self.max_value = max_value
624070
def set_x(idx, val)
      check_bounds(idx)
      FFIGeos.GEOSCoordSeq_setX_r(Geos.current_handle_pointer, ptr, idx, val.to_f)
    end
700875
def xorc_constraint(v=0, sense="maximize"):
    
    assert v in [0,1], "v must be 0 or 1 instead of %s" % v.__repr__()
    model, x, y, z = _init()
    r = model.addVar("r", "B")
    n = model.addVar("n", "I") # auxiliary
    model.addCons(r+quicksum([x,y,z]) == 2*n)
    model.addCons(x==v)
    model.setObjective(r, sense=sense)
    _optimize("Custom XOR (as variable)", model)
4443
function constrain(value, max, size) {
          if (value < 0) {
            return 0;
          }

          if (value + size > max) {
            value = max - size;
            return value < 0 ? 0 : value;
          }

          return value;
        }
1292008
def one_over_x_like(x):
    
    if np.any(x < 0):
        return -np.Inf
    else:
        return -np.sum(np.log(x))
686751
function growBounding(bounding, x, y) {
        if (x < bounding[0]) {
            bounding[0] = x;
        } else if (x > bounding[2]) {
            bounding[2] = x;
        }

        if (y < bounding[1]) {
            bounding[1] = y;
        } else if (y > bounding[3]) {
            bounding[3] = y;
        }
    }
1018428
private void checkHorizontalLimit(double extrp, double vx)
    {
        // Inside interval
        if (mover.getX() >= limitLeft
            && mover.getX() <= limitRight
            && limitLeft != Integer.MIN_VALUE
            && limitRight != Integer.MAX_VALUE)
        {
            offset.moveLocation(extrp, vx, 0);

            // Block offset on its limits
            if (offset.getX() < -intervalHorizontal)
            {
                offset.teleportX(-intervalHorizontal);
            }
            else if (offset.getX() > intervalHorizontal)
            {
                offset.teleportX(intervalHorizontal);
            }
        }
        // Outside interval
        if ((int) offset.getX() == -intervalHorizontal || (int) offset.getX() == intervalHorizontal)
        {
            mover.moveLocationX(extrp, vx);
        }
        applyHorizontalLimit();
    }
1337863
function rangeFromIndexAndOffsets(i, before, after, length) {
  return {
    // Guard against the negative upper bound for lines included in the output.
    from: i - before > 0 ? i - before : 0,
    to: i + after > length ? length : i + after
  };
}
954166
def check_bounds(args, lowerLimit, upperLimit):
        
        penalty = 0
        bound_hit = False
        for i in range(0, len(args)):
            if args[i] < lowerLimit[i] or args[i] > upperLimit[i]:
                penalty = 10**15
                bound_hit = True
        return penalty, bound_hit
1027683
function(current) {
        var bounds,
            constrainedBounds;

        bounds = this.getBounds(current);

        constrainedBounds = this._applyBoundaryConstraints(bounds);

        return constrainedBounds;
    }
667478
def _in_bounds(prop, instance, value):
    """"""
    if (
            (prop.min is not None and value < prop.min) or
            (prop.max is not None and value > prop.max)
    ):
        prop.error(instance, value, extra='Not within allowed range.')
981321
def repair(self, x, copy_if_changed=True, copy_always=False):
        
        copy = copy_if_changed
        if copy_always:
            x = array(x, copy=True)
            copy = False
        if self.bounds is None or (self.bounds[0] is None and
                                   self.bounds[1] is None):
            return x
        return self.bounds_tf(x, copy)
1144996
def xors_constraint(v=1):
    
    assert v in [0,1], "v must be 0 or 1 instead of %s" % v.__repr__()
    model, x, y, z = _init()
    r = True
    model.addConsXor([x,y,z], r)
    model.addCons(x==v)
    _optimize("Standard XOR (as boolean)", model)