@@ -1103,7 +1103,13 @@ def interval_range(
1103
1103
if is_number (endpoint ):
1104
1104
if com .all_not_none (start , end , freq ):
1105
1105
# 0.1 ensures we capture end
1106
- breaks = np .arange (start , end + (freq * 0.1 ), freq )
1106
+ if isinstance (start , float | np .float16 ) or isinstance (
1107
+ end , float | np .float16
1108
+ ):
1109
+ dtype = np .dtype ("float64" )
1110
+ else :
1111
+ dtype = start .dtype if start .dtype == end .dtype else np .dtype ("float64" )
1112
+ breaks = np .arange (start , end + (freq * 0.1 ), freq , dtype = dtype )
1107
1113
else :
1108
1114
# compute the period/start/end if unspecified (at most one)
1109
1115
if periods is None :
@@ -1128,17 +1134,16 @@ def interval_range(
1128
1134
breaks , # type: ignore[arg-type]
1129
1135
dtype ,
1130
1136
)
1131
- return IntervalIndex .from_breaks (
1132
- breaks ,
1133
- name = name ,
1134
- closed = closed ,
1135
- dtype = IntervalDtype (subtype = breaks .dtype , closed = closed ),
1136
- )
1137
1137
else :
1138
1138
# delegate to the appropriate range function
1139
1139
if isinstance (endpoint , Timestamp ):
1140
1140
breaks = date_range (start = start , end = end , periods = periods , freq = freq )
1141
1141
else :
1142
1142
breaks = timedelta_range (start = start , end = end , periods = periods , freq = freq )
1143
1143
1144
- return IntervalIndex .from_breaks (breaks , name = name , closed = closed )
1144
+ return IntervalIndex .from_breaks (
1145
+ breaks ,
1146
+ name = name ,
1147
+ closed = closed ,
1148
+ dtype = IntervalDtype (subtype = breaks .dtype , closed = closed ),
1149
+ )
0 commit comments