Skip to content

Commit 0b484bd

Browse files
committed
Use step
1 parent 1e98a41 commit 0b484bd

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

pandas/_libs/lib.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def is_range_indexer(
231231
left: np.ndarray,
232232
n: int, # np.ndarray[np.int64, ndim=1]
233233
) -> bool: ...
234-
def is_range(
234+
def is_sequence_range(
235235
sequence: np.ndarray,
236-
diff: int, # np.ndarray[np.int64, ndim=1]
236+
step: int, # np.ndarray[np.int64, ndim=1]
237237
) -> bool: ...

pandas/_libs/lib.pyx

+4-4
Original file line numberDiff line numberDiff line change
@@ -680,19 +680,19 @@ def is_range_indexer(ndarray[int6432_t, ndim=1] left, Py_ssize_t n) -> bool:
680680

681681
@cython.wraparound(False)
682682
@cython.boundscheck(False)
683-
def is_range(ndarray[int6432_t, ndim=1] sequence, int64_t diff) -> bool:
683+
def is_sequence_range(ndarray[intp_t, ndim=1] sequence, int64_t step) -> bool:
684684
"""
685-
Check if sequence is equivalent to a range with the specified diff.
685+
Check if sequence is equivalent to a range with the specified step.
686686
"""
687687
cdef:
688688
Py_ssize_t i, n = len(sequence)
689689

690-
if diff == 0:
690+
if step == 0:
691691
return False
692692

693693
for i in range(n):
694694

695-
if sequence[i] != sequence[0] + i * diff:
695+
if sequence[i] != sequence[0] + i * step:
696696
return False
697697

698698
return True

pandas/core/indexes/range.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ def _shallow_copy(self, values, name: Hashable = no_default):
482482
new_range = range(start, start + self.step, self.step)
483483
return type(self)._simple_new(new_range, name=name)
484484
diff = values[1] - values[0]
485-
if not missing.isna(diff) and lib.is_range(values, diff):
485+
if not missing.isna(diff) and lib.is_sequence_range(values, diff):
486486
new_range = range(values[0], values[-1] + diff, diff)
487487
return type(self)._simple_new(new_range, name=name)
488488
return self._constructor._simple_new(values, name=name)

0 commit comments

Comments
 (0)