Get lower bound and upper bound for `self` in signed arithmetic.

        :return: a list of (lower_bound, upper_bound) tuples
505485
def _signed_bounds(self):
        

        nsplit = self._nsplit()
        if len(nsplit) == 1:
            lb = nsplit[0].lower_bound
            ub = nsplit[0].upper_bound

            lb = self._unsigned_to_signed(lb, self.bits)
            ub = self._unsigned_to_signed(ub, self.bits)

            return [(lb, ub)]

        elif len(nsplit) == 2:
            # nsplit[0] is on the left hemisphere, and nsplit[1] is on the right hemisphere

            # The left one
            lb_1 = nsplit[0].lower_bound
            ub_1 = nsplit[0].upper_bound

            # The right one
            lb_2 = nsplit[1].lower_bound
            ub_2 = nsplit[1].upper_bound
            # Then convert them to negative numbers
            lb_2 = self._unsigned_to_signed(lb_2, self.bits)
            ub_2 = self._unsigned_to_signed(ub_2, self.bits)

            return [ (lb_1, ub_1), (lb_2, ub_2) ]
        else:
            raise Exception('WTF')
794088
def get_f_ty_callback(self):
        
        cb = self._callback_factory(self.exprs)
        lb = self.lower_bounds
        ub = self.upper_bounds
        if lb is not None or ub is not None:
            def _bounds_wrapper(t, y, p=(), be=None):
                if lb is not None:
                    if np.any(y < lb - 10*self._current_integration_kwargs['atol']):
                        raise RecoverableError
                    y = np.array(y)
                    y[y < lb] = lb[y < lb]
                if ub is not None:
                    if np.any(y > ub + 10*self._current_integration_kwargs['atol']):
                        raise RecoverableError
                    y = np.array(y)
                    y[y > ub] = ub[y > ub]
                return cb(t, y, p, be)
            return _bounds_wrapper
        else:
            return cb
169525
def bounds(self):
        
        # return bounds including ONLY referenced vertices
        in_mesh = self.vertices[self.referenced_vertices]
        # get mesh bounds with min and max
        mesh_bounds = np.array([in_mesh.min(axis=0),
                                in_mesh.max(axis=0)])
        # should not be mutable
        mesh_bounds.flags.writeable = False
        return mesh_bounds
1185128
def get_min_max_bounds(self):
        
        bound = Bound(999999.0, 0.0)
        for bp in Breakpoint:
            bound.extend(self.get_bound(bp))
        return {'min': bound.min, 'max': bound.max}
14512
def bounds(self):
        
        the_bounds = [np.inf, -np.inf, np.inf, -np.inf, np.inf, -np.inf]

        def _update_bounds(bounds):
            def update_axis(ax):
                if bounds[ax*2] < the_bounds[ax*2]:
                    the_bounds[ax*2] = bounds[ax*2]
                if bounds[ax*2+1] > the_bounds[ax*2+1]:
                    the_bounds[ax*2+1] = bounds[ax*2+1]
            for ax in range(3):
                update_axis(ax)
            return

        for actor in self._actors.values():
            if isinstance(actor, vtk.vtkCubeAxesActor):
                continue
            if ( hasattr(actor, 'GetBounds') and actor.GetBounds() is not None
                 and id(actor) != id(self.bounding_box_actor)):
                _update_bounds(actor.GetBounds())

        return the_bounds
1368683
def _std_tuple_of(var=None, std=None, interval=None):
    

    if std is not None:
        if np.isscalar(std):
            std = (std,)
        return std


    if interval is not None:
        if np.isscalar(interval):
            interval = (interval,)

        return norm.interval(interval)[1]

    if var is None:
        raise ValueError("no inputs were provided")

    if np.isscalar(var):
        var = (var,)
    return np.sqrt(var)
382513
def bounding_cylinder(self):
        
        from . import primitives, bounds
        kwargs = bounds.minimum_cylinder(self)
        mincyl = primitives.Cylinder(mutable=False, **kwargs)
        return mincyl
324022
def _extract_lower_bound(self, name: str, expr: Expression) -> Optional[Expression]:
        ''''''
        etype = expr.etype
        args = expr.args
        if etype[1] in ['<=', '<']:
            if args[1].is_pvariable_expression() and args[1].name == name:
                return args[0]
        elif etype[1] in ['>=', '>']:
            if args[0].is_pvariable_expression() and args[0].name == name:
                return args[1]
        return None
912844
def bound_elems(elems):
    
    group_x0 = min(map(lambda l: l.x0, elems))
    group_y0 = min(map(lambda l: l.y0, elems))
    group_x1 = max(map(lambda l: l.x1, elems))
    group_y1 = max(map(lambda l: l.y1, elems))
    return (group_x0, group_y0, group_x1, group_y1)
457489
def enforce_bounds(self, v):
        
        self._enforce_bounds = v
        self.k.enforce_bounds = v
        self.w.enforce_bounds = v
1147415
def compute_gas_limit_bounds(parent: BlockHeader) -> Tuple[int, int]:
    
    boundary_range = parent.gas_limit // GAS_LIMIT_ADJUSTMENT_FACTOR
    upper_bound = parent.gas_limit + boundary_range
    lower_bound = max(GAS_LIMIT_MINIMUM, parent.gas_limit - boundary_range)
    return lower_bound, upper_bound
478492
def _get_internal_delta(self):
        

        if self._transformation is None:

            return self._delta

        else:

            delta_int = None

            for i in range(2):

                # Try using the low bound

                low_bound_ext = self.value - self.delta

                # Make sure we are within the margins

                if low_bound_ext > self.min_value:

                    # Ok, let's use that for the delta
                    low_bound_int = self._transformation.forward(low_bound_ext)

                    delta_int = abs(low_bound_int - self._get_internal_value())

                    break

                else:

                    # Nope, try with the hi bound

                    hi_bound_ext = self.value + self._delta

                    if hi_bound_ext < self.max_value:

                        # Ok, let's use it
                        hi_bound_int = self._transformation.forward(hi_bound_ext)
                        delta_int = abs(hi_bound_int - self._get_internal_value())

                        break

                    else:

                        # Fix delta
                        self.delta = abs(self.value - self.min_value) / 4.0

                        if self.delta == 0:

                            # Parameter at the minimum
                            self.delta = abs(self.value - self.max_value) / 4.0

                        # Try again
                        continue

            assert delta_int is not None, "Bug"

            return delta_int
37975
public static int bound (int low, int value, int high)
    {
        return Math.min(high, Math.max(low, value));
    }
792351
def get_bounds(self):
        
        bounds = self._get_self_bounds()

        for child in self._children.values():
            child_bounds = child.get_bounds()
            bounds = [
                [
                    none_min(bounds[0][0], child_bounds[0][0]),
                    none_min(bounds[0][1], child_bounds[0][1]),
                    ],
                [
                    none_max(bounds[1][0], child_bounds[1][0]),
                    none_max(bounds[1][1], child_bounds[1][1]),
                    ],
                ]
        return bounds
1290142
def check_feasibility(x_bounds, lowerbound, upperbound):
    '''
    
    '''
    # x_bounds should be sorted, so even for "discrete_int" type,
    # the smallest and the largest number should the first and the last element
    x_bounds_lowerbound = sum([x_bound[0] for x_bound in x_bounds])
    x_bounds_upperbound = sum([x_bound[-1] for x_bound in x_bounds])

    # return ((x_bounds_lowerbound <= lowerbound) and (x_bounds_upperbound >= lowerbound)) or \
    #        ((x_bounds_lowerbound <= upperbound) and (x_bounds_upperbound >= upperbound))
    return (x_bounds_lowerbound <= lowerbound <= x_bounds_upperbound) or \
           (x_bounds_lowerbound <= upperbound <= x_bounds_upperbound)
1318396
def bounds(self):
        
        # get the exact bounds of each entity
        # some entities (aka 3- point Arc) have bounds that can't
        # be generated from just bound box of vertices
        points = np.array([e.bounds(self.vertices)
                           for e in self.entities],
                          dtype=np.float64)
        # flatten bound extrema into (n, dimension) array
        points = points.reshape((-1, self.vertices.shape[1]))
        # get the max and min of all bounds
        bounds = np.array([points.min(axis=0),
                           points.max(axis=0)],
                          dtype=np.float64)

        return bounds
1114034
def _upper_bound_on_event_overflow(
    events, slots, X, beta, summation_type=None, **kwargs
):
    
    label = 'Artificial upper bound constraint'
    for row, event in enumerate(events):
        for col, slot in enumerate(slots):
            yield Constraint(
                f'{label} - slot: {col} and event: {row}',
                event.demand * X[row, col] - slot.capacity <= beta)