Returns an interval representation
323775
def to_latex(self):
        
        if self.low == self.high:
            if self.low * 10 % 10 == 0:
                return "{0:d}".format(int(self.low))
            else:
                return "{0:0.2f}".format(self.low)
        else:
            t = ""
            if self.low == -np.inf:
                t += r"(-\infty, "
            elif self.low * 10 % 10 == 0:
                t += r"[{0:d}, ".format(int(self.low))
            else:
                t += r"[{0:0.2f}, ".format(self.low)
            if self.high == np.inf:
                t += r"\infty)"
            elif self.high * 10 % 10 == 0:
                t += r"{0:d}]".format(int(self.high))
            else:
                t += r"{0:0.2f}]".format(self.high)
            return t
1203261
def interval(key, start_note, interval):
    
    if not notes.is_valid_note(start_note):
        raise KeyError("The start note '%s' is not a valid note" % start_note)
    notes_in_key = keys.get_notes(key)
    for n in notes_in_key:
        if n[0] == start_note[0]:
            index = notes_in_key.index(n)
    return notes_in_key[(index + interval) % 7]
1314789
function intervalConstructor(from, to) {
  // Construct a Interval object from string representation
  if (typeof from === 'string')
    return Interval.toCoord(from);

  if (typeof to === 'string' && from instanceof Note)
    return Interval.from(from, Interval.toCoord(to));

  if (to instanceof Interval && from instanceof Note)
    return Interval.from(from, to);

  if (to instanceof Note && from instanceof Note)
    return Interval.between(from, to);

  throw new Error('Invalid parameters');
}
1326902
def _binary_search_intervals(cls, intervals, index):
        
        start = 0
        end = len(intervals) - 1
        while start <= end:
            middle_index = start + ((end - start) // 2)
            middle = intervals[middle_index]
            if (middle[0] <= index) and (index < middle[1]):
                return middle
            elif middle[0] > index:
                end = middle_index - 1
            else:
                start = middle_index + 1
        return None
258422
public String interval(Date target) {
		double unit = 1000.0D;
		double dayUnit = DAY / unit;
		double hourUnit = HOUR / unit;
		double minUnit = MINUTE / unit;
		double interval = sinceMillis(target) / unit;
		IntervalDesc desc = theIntervalDesc.get();
		
		if (interval >= 0.0D) {
			if (interval / (12 * 30 * dayUnit) > 1.0D) {
				return asText(target);
			}
			if (interval / (30 * dayUnit) > 1.0D) {
				return String.format("%s%s", (int) (interval / (30 * dayUnit)), desc.getMonthAgo());
			}
			if (interval / (7 * dayUnit) > 1.0D) {
				return String.format("7%s", desc.getDayAgo());
			}
			if ((interval / (7 * dayUnit) <= 1.0D) && (interval / dayUnit >= 1.0D)) {
				return String.format("%s%s", (int) (interval / dayUnit), desc.getDayAgo());
			}
			if ((interval / dayUnit < 1.0D) && (interval / hourUnit >= 1.0D)) {
				return String.format("%s%s", (int) (interval / hourUnit), desc.getHourAgo());
			}
			if ((interval < hourUnit) && (interval >= minUnit)) {
				return String.format("%s%s", (int) (interval / minUnit), desc.getMinuteAgo());
			}
			
			return desc.getJustNow();
		}
		
		return asText(target);
	}
1024172
def gaps(self) -> "IntervalList":
        
        if len(self.intervals) < 2:
            return IntervalList(None)
        gaps = []
        for i in range(len(self.intervals) - 1):
            gap = Interval(
                self.intervals[i].end,
                self.intervals[i + 1].start
            )
            gaps.append(gap)
        return IntervalList(gaps)
252145
def validate_intervals(intervals):
    

    # Validate interval shape
    if intervals.ndim != 2 or intervals.shape[1] != 2:
        raise ValueError('Intervals should be n-by-2 numpy ndarray, '
                         'but shape={}'.format(intervals.shape))

    # Make sure no times are negative
    if (intervals < 0).any():
        raise ValueError('Negative interval times found')

    # Make sure all intervals have strictly positive duration
    if (intervals[:, 1] <= intervals[:, 0]).any():
        raise ValueError('All interval durations must be strictly positive')
634385
def __view_to_intervals(self, data_and_metadata: DataAndMetadata.DataAndMetadata, intervals: typing.List[typing.Tuple[float, float]]) -> None:
        """"""
        left = None
        right = None
        for interval in intervals:
            left = min(left, interval[0]) if left is not None else interval[0]
            right = max(right, interval[1]) if right is not None else interval[1]
        left = left if left is not None else 0.0
        right = right if right is not None else 1.0
        left_channel = int(max(0.0, left) * data_and_metadata.data_shape[-1])
        right_channel = int(min(1.0, right) * data_and_metadata.data_shape[-1])
        data_min = numpy.amin(data_and_metadata.data[..., left_channel:right_channel])
        data_max = numpy.amax(data_and_metadata.data[..., left_channel:right_channel])
        if data_min > 0 and data_max > 0:
            y_min = 0.0
            y_max = data_max * 1.2
        elif data_min < 0 and data_max < 0:
            y_min = data_min * 1.2
            y_max = 0.0
        else:
            y_min = data_min * 1.2
            y_max = data_max * 1.2
        extra = (right - left) * 0.5
        display_left_channel = int(max(0.0, left - extra) * data_and_metadata.data_shape[-1])
        display_right_channel = int(min(1.0, right + extra) * data_and_metadata.data_shape[-1])
        # command = self.delegate.create_change_display_command()
        self.delegate.update_display_properties({"left_channel": display_left_channel, "right_channel": display_right_channel, "y_min": y_min, "y_max": y_max})
733116
function range(begin, end, interval = 1) {
  var a = [];

  for (let i = begin; i < (begin+end); i += interval) {
    a.push(i);
  }

  return a;
}
1309188
def range(*args, interval=0):
    
    agen = from_iterable.raw(builtins.range(*args))
    return time.spaceout.raw(agen, interval) if interval else agen
589085
def nearest_interval(self, interval):
        
        thresh_range = 25  # in cents
        if interval < self.intervals[0] - thresh_range or interval > self.intervals[-1] + thresh_range:
            raise IndexError("The interval given is beyond " + str(thresh_range)
                             + " cents over the range of intervals defined.")

        index = find_nearest_index(self.intervals, interval)
        return self.intervals[index]
1049216
def interval_condition(value, inf, sup, dist):
    
    return (value > inf - dist and value < sup + dist)
62548
def invert(interval):
    
    interval.reverse()
    res = list(interval)
    interval.reverse()
    return res
1226793
def get_formatted_interval(results_range, default=_marker):
    
    if not isinstance(results_range, Mapping):
        if default is not _marker:
            return default
        api.fail("Type not supported")
    results_range = ResultsRangeDict(results_range)
    min_str = results_range.min if api.is_floatable(results_range.min) else None
    max_str = results_range.max if api.is_floatable(results_range.max) else None
    if min_str is None and max_str is None:
        if default is not _marker:
            return default
        api.fail("Min and max values are not floatable or not defined")

    min_operator = results_range.min_operator
    max_operator = results_range.max_operator
    if max_str is None:
        return "{}{}".format(MIN_OPERATORS.getValue(min_operator), min_str)
    if min_str is None:
        return "{}{}".format(MAX_OPERATORS.getValue(max_operator), max_str)

    # Both values set. Return an interval
    min_bracket = min_operator == 'geq' and '[' or '('
    max_bracket = max_operator == 'leq' and ']' or ')'

    return "{}{};{}{}".format(min_bracket, min_str, max_str, max_bracket)
766341
def all_valid_time_intervals():
        '''
        
        '''
        return [PerformanceTimeInterval.DAY,
                PerformanceTimeInterval.WEEK,
                PerformanceTimeInterval.TWO_WEEKS,
                PerformanceTimeInterval.SIXTY_DAYS,
                PerformanceTimeInterval.NINETY_DAYS,
                PerformanceTimeInterval.ONE_YEAR]
392813
def _view_interval(self, queue_type, queue_id):
        """"""
        response = {
            'status': 'failure'
        }
        try:
            request_data = json.loads(request.data)
            interval = request_data['interval']
        except Exception, e:
            response['message'] = e.message
            return jsonify(**response), 400

        request_data = {
            'queue_type': queue_type,
            'queue_id': queue_id,
            'interval': interval
        }

        try:
            response = self.sq.interval(**request_data)
            if response['status'] == 'failure':
                return jsonify(**response), 404
        except Exception, e:
            response['message'] = e.message
            return jsonify(**response), 400

        return jsonify(**response)
31706
def to_atomic(self):
        
        lower = self._intervals[0].lower
        left = self._intervals[0].left
        upper = self._intervals[-1].upper
        right = self._intervals[-1].right

        return AtomicInterval(left, lower, upper, right)