Skip to content

Remove duplicate is_lexsorted function #19305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions pandas/_libs/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -896,38 +896,6 @@ def write_csv_rows(list data, ndarray data_index,
# ------------------------------------------------------------------------------
# Groupby-related functions

@cython.wraparound(False)
@cython.boundscheck(False)
def is_lexsorted(list list_of_arrays):
cdef:
int i
Py_ssize_t n, nlevels
int64_t k, cur, pre
ndarray arr

nlevels = len(list_of_arrays)
n = len(list_of_arrays[0])

cdef int64_t **vecs = <int64_t**> malloc(nlevels * sizeof(int64_t*))
for i from 0 <= i < nlevels:
arr = list_of_arrays[i]
vecs[i] = <int64_t *> arr.data

# Assume uniqueness??
for i from 1 <= i < n:
for k from 0 <= k < nlevels:
cur = vecs[k][i]
pre = vecs[k][i - 1]
if cur == pre:
continue
elif cur > pre:
break
else:
return False
free(vecs)
return True


# TODO: could do even better if we know something about the data. eg, index has
# 1-min data, binner has 5-min data, then bins are just strides in index. This
# is a general, O(max(len(values), len(binner))) method.
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from sys import getsizeof

import numpy as np
from pandas._libs import index as libindex, lib, Timestamp
from pandas._libs import algos as libalgos, index as libindex, lib, Timestamp

from pandas.compat import range, zip, lrange, lzip, map
from pandas.compat.numpy import function as nv
Expand Down Expand Up @@ -1137,7 +1137,7 @@ def lexsort_depth(self):

int64_labels = [_ensure_int64(lab) for lab in self.labels]
for k in range(self.nlevels, 0, -1):
if lib.is_lexsorted(int64_labels[:k]):
if libalgos.is_lexsorted(int64_labels[:k]):
return k

return 0
Expand Down