def interval_range(start=None, end=None, periods=None, freq=None,<EOL>name=None, closed='<STR_LIT:right>'):
start = com.maybe_box_datetimelike(start)<EOL>end = com.maybe_box_datetimelike(end)<EOL>endpoint = start if start is not None else end<EOL>if freq is None and com._any_none(periods, start, end):<EOL><INDENT>freq = <NUM_LIT:1> if is_number(endpoint) else '<STR_LIT:D>'<EOL><DEDENT>if com.count_not_none(start, end, periods, freq) != <NUM_LIT:3>:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if not _is_valid_endpoint(start):<EOL><INDENT>msg = '<STR_LIT>'<EOL>raise ValueError(msg.format(start=start))<EOL><DEDENT>elif not _is_valid_endpoint(end):<EOL><INDENT>msg = '<STR_LIT>'<EOL>raise ValueError(msg.format(end=end))<EOL><DEDENT>if is_float(periods):<EOL><INDENT>periods = int(periods)<EOL><DEDENT>elif not is_integer(periods) and periods is not None:<EOL><INDENT>msg = '<STR_LIT>'<EOL>raise TypeError(msg.format(periods=periods))<EOL><DEDENT>if freq is not None and not is_number(freq):<EOL><INDENT>try:<EOL><INDENT>freq = to_offset(freq)<EOL><DEDENT>except ValueError:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>'.format(freq=freq))<EOL><DEDENT><DEDENT>if not all([_is_type_compatible(start, end),<EOL>_is_type_compatible(start, freq),<EOL>_is_type_compatible(end, freq)]):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if periods is not None:<EOL><INDENT>periods += <NUM_LIT:1><EOL><DEDENT>if is_number(endpoint):<EOL><INDENT>if com._all_not_none(start, end, freq):<EOL><INDENT>end -= (end - start) % freq<EOL><DEDENT>if periods is None:<EOL><INDENT>periods = int((end - start) // freq) + <NUM_LIT:1><EOL><DEDENT>elif start is None:<EOL><INDENT>start = end - (periods - <NUM_LIT:1>) * freq<EOL><DEDENT>elif end is None:<EOL><INDENT>end = start + (periods - <NUM_LIT:1>) * freq<EOL><DEDENT>breaks = np.linspace(start, end, periods)<EOL>if all(is_integer(x) for x in com._not_none(start, end, freq)):<EOL><INDENT>breaks = maybe_downcast_to_dtype(breaks, '<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if isinstance(endpoint, Timestamp):<EOL><INDENT>range_func = date_range<EOL><DEDENT>else:<EOL><INDENT>range_func = timedelta_range<EOL><DEDENT>breaks = range_func(start=start, end=end, periods=periods, freq=freq)<EOL><DEDENT>return IntervalIndex.from_breaks(breaks, name=name, closed=closed)<EOL>
Return a fixed frequency IntervalIndex

Parameters
----------
start : numeric or datetime-like, default None
    Left bound for generating intervals
end : numeric or datetime-like, default None
    Right bound for generating intervals
periods : integer, default None
    Number of periods to generate
freq : numeric, string, or DateOffset, default None
    The length of each interval. Must be consistent with the type of start
    and end, e.g. 2 for numeric, or '5H' for datetime-like.  Default is 1
    for numeric and 'D' for datetime-like.
name : string, default None
    Name of the resulting IntervalIndex
closed : {'left', 'right', 'both', 'neither'}, default 'right'
    Whether the intervals are closed on the left-side, right-side, both
    or neither.

Returns
-------
rng : IntervalIndex

See Also
--------
IntervalIndex : An Index of intervals that are all closed on the same side.

Notes
-----
Of the four parameters ``start``, ``end``, ``periods``, and ``freq``,
exactly three must be specified. If ``freq`` is omitted, the resulting
``IntervalIndex`` will have ``periods`` linearly spaced elements between
``start`` and ``end``, inclusively.

To learn more about datetime-like frequency strings, please see `this link
<http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__.

Examples
--------
Numeric ``start`` and  ``end`` is supported.

>>> pd.interval_range(start=0, end=5)
IntervalIndex([(0, 1], (1, 2], (2, 3], (3, 4], (4, 5]],
              closed='right', dtype='interval[int64]')

Additionally, datetime-like input is also supported.

>>> pd.interval_range(start=pd.Timestamp('2017-01-01'),
...                   end=pd.Timestamp('2017-01-04'))
IntervalIndex([(2017-01-01, 2017-01-02], (2017-01-02, 2017-01-03],
               (2017-01-03, 2017-01-04]],
              closed='right', dtype='interval[datetime64[ns]]')

The ``freq`` parameter specifies the frequency between the left and right.
endpoints of the individual intervals within the ``IntervalIndex``.  For
numeric ``start`` and ``end``, the frequency must also be numeric.

>>> pd.interval_range(start=0, periods=4, freq=1.5)
IntervalIndex([(0.0, 1.5], (1.5, 3.0], (3.0, 4.5], (4.5, 6.0]],
              closed='right', dtype='interval[float64]')

Similarly, for datetime-like ``start`` and ``end``, the frequency must be
convertible to a DateOffset.

>>> pd.interval_range(start=pd.Timestamp('2017-01-01'),
...                   periods=3, freq='MS')
IntervalIndex([(2017-01-01, 2017-02-01], (2017-02-01, 2017-03-01],
               (2017-03-01, 2017-04-01]],
              closed='right', dtype='interval[datetime64[ns]]')

Specify ``start``, ``end``, and ``periods``; the frequency is generated
automatically (linearly spaced).

>>> pd.interval_range(start=0, end=6, periods=4)
IntervalIndex([(0.0, 1.5], (1.5, 3.0], (3.0, 4.5], (4.5, 6.0]],
          closed='right',
          dtype='interval[float64]')

The ``closed`` parameter specifies which endpoints of the individual
intervals within the ``IntervalIndex`` are closed.

>>> pd.interval_range(end=5, periods=4, closed='both')
IntervalIndex([[1, 2], [2, 3], [3, 4], [4, 5]],
              closed='both', dtype='interval[int64]')