Skip to content

Commit ea5b666

Browse files
authored
Make sure to pass through range indexes (#225)
1 parent cbd52ef commit ea5b666

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

flox/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1508,7 +1508,7 @@ def _convert_expected_groups_to_index(
15081508
) -> tuple[pd.Index | None, ...]:
15091509
out: list[pd.Index | None] = []
15101510
for ex, isbin_ in zip(expected_groups, isbin):
1511-
if isinstance(ex, pd.IntervalIndex) or (isinstance(ex, pd.Index) and not isbin):
1511+
if isinstance(ex, pd.IntervalIndex) or (isinstance(ex, pd.Index) and not isbin_):
15121512
if sort:
15131513
ex = ex.sort_values()
15141514
out.append(ex)

tests/test_core.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,3 +1316,12 @@ def test_negative_index_factorize_race_condition():
13161316
for f in func
13171317
]
13181318
[dask.compute(out, scheduler="threads") for _ in range(5)]
1319+
1320+
1321+
@pytest.mark.parametrize("sort", [True, False])
1322+
def test_expected_index_conversion_passthrough_range_index(sort):
1323+
index = pd.RangeIndex(100)
1324+
actual = _convert_expected_groups_to_index(
1325+
expected_groups=(index,), isbin=(False,), sort=(sort,)
1326+
)
1327+
assert actual[0] is index

0 commit comments

Comments
 (0)