Skip to content

TST: split up tests/plotting/test_frame.py into subdir & modules #34769 #37538

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

Closed
wants to merge 58 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
7847116
Moving the file test_frame.py to a new directory
Mikhaylov-yv Oct 31, 2020
418551a
Сreated file test_frame_color.py
Mikhaylov-yv Nov 1, 2020
8f6cde0
Transfer tests
Mikhaylov-yv Nov 2, 2020
2cb3fd7
PEP 8 fixes
Mikhaylov-yv Nov 2, 2020
4527f11
Transfer tests
Mikhaylov-yv Nov 2, 2020
d851ca2
Removing unnecessary imports
Mikhaylov-yv Nov 2, 2020
d350978
Merge branch 'master' into #34769_TST_split_up_tests
Mikhaylov-yv Nov 2, 2020
d5ddae2
PEP 8 fixes
Mikhaylov-yv Nov 2, 2020
aeacf6c
Fixed class name
Mikhaylov-yv Nov 4, 2020
d9c8ae9
Transfer tests
Mikhaylov-yv Nov 4, 2020
807bda2
catch FutureWarnings (#37587)
jbrockmendel Nov 2, 2020
330b74a
TST/REF: collect indexing tests by method (#37590)
jbrockmendel Nov 2, 2020
3cd5b65
REF: prelims for single-path setitem_with_indexer (#37588)
jbrockmendel Nov 2, 2020
d2d892a
ENH: __repr__ for 2D DTA/TDA (#37164)
jbrockmendel Nov 2, 2020
aaced3f
CLN: de-duplicate _validate_where_value with _validate_setitem_value …
jbrockmendel Nov 2, 2020
b964dd7
TST/REF: collect tests by method (#37589)
jbrockmendel Nov 2, 2020
d396ecc
REF: Categorical.is_dtype_equal -> categories_match_up_to_permutation…
jbrockmendel Nov 2, 2020
ed49ab3
CLN refactor non-core (#37580)
MarcoGorelli Nov 2, 2020
fdcd74b
refactor core/computation (#37585)
MarcoGorelli Nov 2, 2020
bc1868a
TST/REF: share method tests between DataFrame and Series (#37596)
jbrockmendel Nov 3, 2020
fe4e7f5
BUG: Index.where casting ints to str (#37591)
jbrockmendel Nov 3, 2020
b22f7ad
REF: IntervalArray comparisons (#37124)
jbrockmendel Nov 3, 2020
2f28e80
regression fix for merging DF with datetime index with empty DF (#36897)
PCerles Nov 3, 2020
743b1b1
ERR: fix error message in Period for invalid frequency (#37602)
jorisvandenbossche Nov 3, 2020
ddf2bee
CLN: remove rebox_native (#37608)
jbrockmendel Nov 3, 2020
18767f8
TST/REF: tests.generic (#37618)
jbrockmendel Nov 4, 2020
e17ce57
TST: collect tests by method (#37617)
jbrockmendel Nov 4, 2020
626eca7
TST/REF: share tests across Series/DataFrame (#37616)
jbrockmendel Nov 4, 2020
ef0314e
Gh 36562 typeerror comparison not supported between float and str (#3…
ssche Nov 4, 2020
d893c62
docs: fix punctuation (#37612)
MicaelJarniac Nov 4, 2020
95d3117
REGR: pd.to_hdf(..., dropna=True) not dropping missing rows (#37564)
arw2019 Nov 4, 2020
d270e0b
parametrize set_axis tests (#37619)
jbrockmendel Nov 4, 2020
4aadb07
CLN: clean color selection in _matplotlib/style (#37203)
ivanovmg Nov 4, 2020
6cbbd4f
DEPR: DataFrame/Series.slice_shift (#37601)
erfannariman Nov 4, 2020
6bfbb3f
REF: re-use validate_setitem_value in Categorical.fillna (#37597)
jbrockmendel Nov 4, 2020
4c855e1
PERF: release gil for ewma_time (#37389)
fangchenli Nov 4, 2020
b77ea70
BUG: Groupy dropped nan groups from result when grouping over single …
phofl Nov 4, 2020
042d22f
ENH: implement timeszones support for read_json(orient='table') and a…
attack68 Nov 4, 2020
0a1185f
REF/BUG/TYP: read_csv shouldn't close user-provided file handles (#36…
twoertwein Nov 4, 2020
edfbfe7
more typing checks to pre-commit (#37539)
MarcoGorelli Nov 4, 2020
3724b6b
TST: 32bit dtype compat test_groupby_dropna (#37623)
ivanovmg Nov 4, 2020
49aadaa
BUG: Metadata propagation for groupby iterator (#37461)
Japanuspus Nov 4, 2020
8d79d64
BUG: read-only values in cython funcs (#37613)
jbrockmendel Nov 4, 2020
8462c7e
CLN refactor core/arrays (#37581)
MarcoGorelli Nov 4, 2020
40af4a5
Fixed Metadata Propogation in DataFrame (#37381)
abbywh Nov 4, 2020
53147b4
TYP: add Shape alias to pandas._typing (#37128)
arw2019 Nov 4, 2020
48915e2
DOC: Fix typo (#37630)
MicaelJarniac Nov 4, 2020
07acef8
CLN: parametrize test_nat_comparisons (#37195)
ivanovmg Nov 4, 2020
1731197
dataframe dataclass docstring updated (#37632)
taytzehao Nov 4, 2020
101aa24
refactor core/groupby (#37583)
MarcoGorelli Nov 4, 2020
8507455
BUG: set index of DataFrame.apply(f) when f returns dict (#37544) (#3…
ma3da Nov 4, 2020
bc17319
BUG: to_dict should return a native datetime object for NumPy backed …
arw2019 Nov 4, 2020
4ddaf47
ENH: memory_map for compressed files (#37621)
twoertwein Nov 5, 2020
a29a416
DOC: add example & prose of slicing with labels when index has duplic…
junjunjunk Nov 5, 2020
d8ced32
DOC: Fix typo (#37636)
MicaelJarniac Nov 5, 2020
bcb0988
Transfer tests
Mikhaylov-yv Nov 5, 2020
8526438
Changed class names
Mikhaylov-yv Nov 5, 2020
44345e8
Removed unnecessary imports
Mikhaylov-yv Nov 5, 2020
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
30 changes: 30 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,36 @@ repos:
entry: python scripts/validate_unwanted_patterns.py --validation-type="private_function_across_module"
types: [python]
exclude: ^(asv_bench|pandas/tests|doc)/
- id: FrameOrSeriesUnion
name: Check for use of Union[Series, DataFrame] instead of FrameOrSeriesUnion alias
entry: Union\[.*(Series.*DataFrame|DataFrame.*Series).*\]
language: pygrep
types: [python]
exclude: ^pandas/_typing\.py$
- id: type-not-class
name: Check for use of foo.__class__ instead of type(foo)
entry: \.__class__
language: pygrep
files: \.(py|pyx)$
- id: unwanted-typing
name: Check for use of comment-based annotation syntax and missing error codes
entry: |
(?x)
\#\ type:\ (?!ignore)|
\#\ type:\s?ignore(?!\[)
language: pygrep
types: [python]
- id: no-os-remove
name: Check code for instances of os.remove
entry: os\.remove
language: pygrep
types: [python]
files: ^pandas/tests/
exclude: |
(?x)^
pandas/tests/io/excel/test_writers\.py|
pandas/tests/io/pytables/common\.py|
pandas/tests/io/pytables/test_store\.py$
- repo: https://github.com/asottile/yesqa
rev: v1.2.2
hooks:
Expand Down
23 changes: 0 additions & 23 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,29 +122,6 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then
RET=$(($RET + $?)) ; echo $MSG "DONE"

# -------------------------------------------------------------------------
# Type annotations

MSG='Check for use of comment-based annotation syntax' ; echo $MSG
invgrep -R --include="*.py" -P '# type: (?!ignore)' pandas
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Check for missing error codes with # type: ignore' ; echo $MSG
invgrep -R --include="*.py" -P '# type:\s?ignore(?!\[)' pandas
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Check for use of Union[Series, DataFrame] instead of FrameOrSeriesUnion alias' ; echo $MSG
invgrep -R --include="*.py" --exclude=_typing.py -E 'Union\[.*(Series.*DataFrame|DataFrame.*Series).*\]' pandas
RET=$(($RET + $?)) ; echo $MSG "DONE"

# -------------------------------------------------------------------------
MSG='Check for use of foo.__class__ instead of type(foo)' ; echo $MSG
invgrep -R --include=*.{py,pyx} '\.__class__' pandas
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Check code for instances of os.remove' ; echo $MSG
invgrep -R --include="*.py*" --exclude "common.py" --exclude "test_writers.py" --exclude "test_store.py" -E "os\.remove" pandas/tests/
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Check for inconsistent use of pandas namespace in tests' ; echo $MSG
for class in "Series" "DataFrame" "Index" "MultiIndex" "Timestamp" "Timedelta" "TimedeltaIndex" "DatetimeIndex" "Categorical"; do
check_namespace ${class}
Expand Down
11 changes: 11 additions & 0 deletions doc/source/user_guide/indexing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,17 @@ above example, ``s.loc[1:6]`` would raise ``KeyError``.
For the rationale behind this behavior, see
:ref:`Endpoints are inclusive <advanced.endpoints_are_inclusive>`.

.. ipython:: python

s = pd.Series(list('abcdef'), index=[0, 3, 2, 5, 4, 2])
s.loc[3:5]

Also, if the index has duplicate labels *and* either the start or the stop label is dupulicated,
an error will be raised. For instance, in the above example, ``s.loc[2:5]`` would raise a ``KeyError``.

For more information about duplicate labels, see
:ref:`Duplicate Labels <duplicates>`.

.. _indexing.integer:

Selection by position
Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v1.1.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Fixed regressions

Bug fixes
~~~~~~~~~
-
- Bug in metadata propagation for ``groupby`` iterator (:issue:`37343`)
-

.. ---------------------------------------------------------------------------
Expand Down
21 changes: 18 additions & 3 deletions doc/source/whatsnew/v1.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ Other enhancements
- ``Styler`` now allows direct CSS class name addition to individual data cells (:issue:`36159`)
- :meth:`Rolling.mean()` and :meth:`Rolling.sum()` use Kahan summation to calculate the mean to avoid numerical problems (:issue:`10319`, :issue:`11645`, :issue:`13254`, :issue:`32761`, :issue:`36031`)
- :meth:`DatetimeIndex.searchsorted`, :meth:`TimedeltaIndex.searchsorted`, :meth:`PeriodIndex.searchsorted`, and :meth:`Series.searchsorted` with datetimelike dtypes will now try to cast string arguments (listlike and scalar) to the matching datetimelike type (:issue:`36346`)
-
- Added methods :meth:`IntegerArray.prod`, :meth:`IntegerArray.min`, and :meth:`IntegerArray.max` (:issue:`33790`)
- Where possible :meth:`RangeIndex.difference` and :meth:`RangeIndex.symmetric_difference` will return :class:`RangeIndex` instead of :class:`Int64Index` (:issue:`36564`)
- Added :meth:`Rolling.sem()` and :meth:`Expanding.sem()` to compute the standard error of mean (:issue:`26476`).
Expand All @@ -229,6 +230,7 @@ Other enhancements
- :class:`DatetimeIndex` and :class:`Series` with ``datetime64`` or ``datetime64tz`` dtypes now support ``std`` (:issue:`37436`)
- :class:`Window` now supports all Scipy window types in ``win_type`` with flexible keyword argument support (:issue:`34556`)
- :meth:`testing.assert_index_equal` now has a ``check_order`` parameter that allows indexes to be checked in an order-insensitive manner (:issue:`37478`)
- :func:`read_csv` supports memory-mapping for compressed files (:issue:`37621`)

.. _whatsnew_120.api_breaking.python:

Expand Down Expand Up @@ -340,6 +342,9 @@ Deprecations
- :meth:`Index.ravel` returning a ``np.ndarray`` is deprecated, in the future this will return a view on the same index (:issue:`19956`)
- Deprecate use of strings denoting units with 'M', 'Y' or 'y' in :func:`~pandas.to_timedelta` (:issue:`36666`)
- :class:`Index` methods ``&``, ``|``, and ``^`` behaving as the set operations :meth:`Index.intersection`, :meth:`Index.union`, and :meth:`Index.symmetric_difference`, respectively, are deprecated and in the future will behave as pointwise boolean operations matching :class:`Series` behavior. Use the named set methods instead (:issue:`36758`)
- :meth:`Categorical.is_dtype_equal` and :meth:`CategoricalIndex.is_dtype_equal` are deprecated, will be removed in a future version (:issue:`37545`)
- :meth:`Series.slice_shift` and :meth:`DataFrame.slice_shift` are deprecated, use :meth:`Series.shift` or :meth:`DataFrame.shift` instead (:issue:`37601`)


.. ---------------------------------------------------------------------------

Expand Down Expand Up @@ -390,14 +395,18 @@ Datetimelike
- Bug in :class:`DatetimeIndex.shift` incorrectly raising when shifting empty indexes (:issue:`14811`)
- :class:`Timestamp` and :class:`DatetimeIndex` comparisons between timezone-aware and timezone-naive objects now follow the standard library ``datetime`` behavior, returning ``True``/``False`` for ``!=``/``==`` and raising for inequality comparisons (:issue:`28507`)
- Bug in :meth:`DatetimeIndex.equals` and :meth:`TimedeltaIndex.equals` incorrectly considering ``int64`` indexes as equal (:issue:`36744`)
- :meth:`to_json` and :meth:`read_json` now implements timezones parsing when orient structure is 'table'.
- :meth:`astype` now attempts to convert to 'datetime64[ns, tz]' directly from 'object' with inferred timezone from string (:issue:`35973`).
- Bug in :meth:`TimedeltaIndex.sum` and :meth:`Series.sum` with ``timedelta64`` dtype on an empty index or series returning ``NaT`` instead of ``Timedelta(0)`` (:issue:`31751`)
- Bug in :meth:`DatetimeArray.shift` incorrectly allowing ``fill_value`` with a mismatched timezone (:issue:`37299`)
- Bug in adding a :class:`BusinessDay` with nonzero ``offset`` to a non-scalar other (:issue:`37457`)
- Bug in :func:`to_datetime` with a read-only array incorrectly raising (:issue:`34857`)

Timedelta
^^^^^^^^^
- Bug in :class:`TimedeltaIndex`, :class:`Series`, and :class:`DataFrame` floor-division with ``timedelta64`` dtypes and ``NaT`` in the denominator (:issue:`35529`)
- Bug in parsing of ISO 8601 durations in :class:`Timedelta`, :meth:`pd.to_datetime` (:issue:`37159`, fixes :issue:`29773` and :issue:`36204`)
- Bug in :func:`to_timedelta` with a read-only array incorrectly raising (:issue:`34857`)

Timezones
^^^^^^^^^
Expand Down Expand Up @@ -427,7 +436,7 @@ Numeric
Conversion
^^^^^^^^^^

-
- Bug in :meth:`DataFrame.to_dict` with ``orient='records'`` now returns python native datetime objects for datetimelike columns (:issue:`21256`)
-

Strings
Expand Down Expand Up @@ -455,6 +464,7 @@ Indexing
- Bug in :meth:`Series.loc.__getitem__` with a non-unique :class:`MultiIndex` and an empty-list indexer (:issue:`13691`)
- Bug in indexing on a :class:`Series` or :class:`DataFrame` with a :class:`MultiIndex` with a level named "0" (:issue:`37194`)
- Bug in :meth:`Series.__getitem__` when using an unsigned integer array as an indexer giving incorrect results or segfaulting instead of raising ``KeyError`` (:issue:`37218`)
- Bug in :meth:`Index.where` incorrectly casting numeric values to strings (:issue:`37591`)

Missing
^^^^^^^
Expand All @@ -467,7 +477,7 @@ MultiIndex

- Bug in :meth:`DataFrame.xs` when used with :class:`IndexSlice` raises ``TypeError`` with message ``"Expected label or tuple of labels"`` (:issue:`35301`)
- Bug in :meth:`DataFrame.reset_index` with ``NaT`` values in index raises ``ValueError`` with message ``"cannot convert float NaN to integer"`` (:issue:`36541`)
-
- Bug in :meth:`DataFrame.combine_first` when used with :class:`MultiIndex` containing string and ``NaN`` values raises ``TypeError`` (:issue:`36562`)

I/O
^^^
Expand All @@ -491,6 +501,8 @@ I/O
- Bug in output rendering of complex numbers showing too many trailing zeros (:issue:`36799`)
- Bug in :class:`HDFStore` threw a ``TypeError`` when exporting an empty :class:`DataFrame` with ``datetime64[ns, tz]`` dtypes with a fixed HDF5 store (:issue:`20594`)
- Bug in :class:`HDFStore` was dropping timezone information when exporting :class:`Series` with ``datetime64[ns, tz]`` dtypes with a fixed HDF5 store (:issue:`20594`)
- :func:`read_csv` was closing user-provided binary file handles when ``engine="c"`` and an ``encoding`` was requested (:issue:`36980`)
- Bug in :meth:`DataFrame.to_hdf` was not dropping missing rows with ``dropna=True`` (:issue:`35719`)

Plotting
^^^^^^^^
Expand Down Expand Up @@ -522,6 +534,7 @@ Groupby/resample/rolling
- Using :meth:`Rolling.var()` instead of :meth:`Rolling.std()` avoids numerical issues for :meth:`Rolling.corr()` when :meth:`Rolling.var()` is still within floating point precision while :meth:`Rolling.std()` is not (:issue:`31286`)
- Bug in :meth:`df.groupby(..).quantile() <pandas.core.groupby.DataFrameGroupBy.quantile>` and :meth:`df.resample(..).quantile() <pandas.core.resample.Resampler.quantile>` raised ``TypeError`` when values were of type ``Timedelta`` (:issue:`29485`)
- Bug in :meth:`Rolling.median` and :meth:`Rolling.quantile` returned wrong values for :class:`BaseIndexer` subclasses with non-monotonic starting or ending points for windows (:issue:`37153`)
- Bug in :meth:`DataFrame.groupby` dropped ``nan`` groups from result with ``dropna=False`` when grouping over a single column (:issue:`35646`, :issue:`35542`)

Reshaping
^^^^^^^^^
Expand All @@ -534,6 +547,8 @@ Reshaping
- Bug in :meth:`DataFrame.pivot` did not preserve :class:`MultiIndex` level names for columns when rows and columns both multiindexed (:issue:`36360`)
- Bug in :func:`join` returned a non deterministic level-order for the resulting :class:`MultiIndex` (:issue:`36910`)
- Bug in :meth:`DataFrame.combine_first()` caused wrong alignment with dtype ``string`` and one level of ``MultiIndex`` containing only ``NA`` (:issue:`37591`)
- Fixed regression in :func:`merge` on merging DatetimeIndex with empty DataFrame (:issue:`36895`)
- Bug in :meth:`DataFrame.apply` not setting index of return value when ``func`` return type is ``dict`` (:issue:`37544`)

Sparse
^^^^^^
Expand All @@ -556,7 +571,7 @@ Other
- Bug in :meth:`DataFrame.replace` and :meth:`Series.replace` incorrectly raising ``AssertionError`` instead of ``ValueError`` when invalid parameter combinations are passed (:issue:`36045`)
- Bug in :meth:`DataFrame.replace` and :meth:`Series.replace` with numeric values and string ``to_replace`` (:issue:`34789`)
- Fixed bug in metadata propagation incorrectly copying DataFrame columns as metadata when the column name overlaps with the metadata name (:issue:`37037`)
- Fixed metadata propagation in the :class:`Series.dt` and :class:`Series.str` accessors and :class:`DataFrame.duplicated` and :class:`DataFrame.stack` and :class:`DataFrame.unstack` and :class:`DataFrame.pivot` methods (:issue:`28283`)
- Fixed metadata propagation in the :class:`Series.dt`, :class:`Series.str` accessors, :class:`DataFrame.duplicated`, :class:`DataFrame.stack`, :class:`DataFrame.unstack`, :class:`DataFrame.pivot`, :class:`DataFrame.append`, :class:`DataFrame.diff`, :class:`DataFrame.applymap` and :class:`DataFrame.update` methods (:issue:`28283`) (:issue:`37381`)
- Bug in :meth:`Index.union` behaving differently depending on whether operand is a :class:`Index` or other list-like (:issue:`36384`)
- Passing an array with 2 or more dimensions to the :class:`Series` constructor now raises the more specific ``ValueError``, from a bare ``Exception`` previously (:issue:`35744`)
- Bug in ``accessor.DirNamesMixin``, where ``dir(obj)`` wouldn't show attributes defined on the instance (:issue:`37173`).
Expand Down
4 changes: 2 additions & 2 deletions pandas/_config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ class option_context(ContextDecorator):
"""

def __init__(self, *args):
if not (len(args) % 2 == 0 and len(args) >= 2):
if len(args) % 2 != 0 or len(args) < 2:
raise ValueError(
"Need to invoke as option_context(pat, val, [(pat, val), ...])."
)
Expand Down Expand Up @@ -648,7 +648,7 @@ def _build_option_description(k: str) -> str:
s += f"\n [default: {o.defval}] [currently: {_get_option(k, True)}]"

if d:
rkey = d.rkey if d.rkey else ""
rkey = d.rkey or ""
s += "\n (Deprecated"
s += f", use `{rkey}` instead."
s += ")"
Expand Down
3 changes: 1 addition & 2 deletions pandas/_config/localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ def _valid_locales(locales, normalize):


def _default_locale_getter():
raw_locales = subprocess.check_output(["locale -a"], shell=True)
return raw_locales
return subprocess.check_output(["locale -a"], shell=True)


def get_locales(prefix=None, normalize=True, locale_getter=_default_locale_getter):
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/join.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ ctypedef fused join_t:

@cython.wraparound(False)
@cython.boundscheck(False)
def left_join_indexer_unique(join_t[:] left, join_t[:] right):
def left_join_indexer_unique(ndarray[join_t] left, ndarray[join_t] right):
cdef:
Py_ssize_t i, j, nleft, nright
ndarray[int64_t] indexer
Expand Down
29 changes: 18 additions & 11 deletions pandas/_libs/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -896,21 +896,28 @@ def indices_fast(ndarray index, const int64_t[:] labels, list keys,

if lab != cur:
if lab != -1:
tup = PyTuple_New(k)
for j in range(k):
val = keys[j][sorted_labels[j][i - 1]]
PyTuple_SET_ITEM(tup, j, val)
Py_INCREF(val)

if k == 1:
# When k = 1 we do not want to return a tuple as key
tup = keys[0][sorted_labels[0][i - 1]]
else:
tup = PyTuple_New(k)
for j in range(k):
val = keys[j][sorted_labels[j][i - 1]]
PyTuple_SET_ITEM(tup, j, val)
Py_INCREF(val)
result[tup] = index[start:i]
start = i
cur = lab

tup = PyTuple_New(k)
for j in range(k):
val = keys[j][sorted_labels[j][n - 1]]
PyTuple_SET_ITEM(tup, j, val)
Py_INCREF(val)
if k == 1:
# When k = 1 we do not want to return a tuple as key
tup = keys[0][sorted_labels[0][n - 1]]
else:
tup = PyTuple_New(k)
for j in range(k):
val = keys[j][sorted_labels[j][n - 1]]
PyTuple_SET_ITEM(tup, j, val)
Py_INCREF(val)
result[tup] = index[start:]

return result
Expand Down
Loading