Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Adds Int64Index type and updates Series and DF methods to use it - #950

Merged
kozlov-alexey merged 4 commits into
IntelPython:masterfrom
kozlov-alexey:feature/add_int64index
Jan 29, 2021
Merged

kozlov-alexey merged 4 commits into
IntelPython:masterfrom
kozlov-alexey:feature/add_int64index

Conversation

@kozlov-alexey

Copy link
Copy Markdown
Contributor

Motivation: as part of the work on supporting common pandas indexes
a new type (Int64IndexType) representing pandas.Int64Index is added.
Boxing/unboxing of Series and DataFrames as well as common numpy-like
functions are changed accordingly to handle it.

@pep8speaks

pep8speaks commented Dec 9, 2020 •

Copy link
Copy Markdown

Hello @kozlov-alexey! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-01-27 13:27:22 UTC

Comment thread sdc/tests/test_dataframe.py Outdated
Comment thread sdc/tests/test_series.py Outdated
Comment thread sdc/tests/test_series.py Outdated
Comment thread sdc/tests/test_utils.py Outdated
@kozlov-alexey
kozlov-alexey force-pushed the feature/add_int64index branch from 019c607 to 6961a1a Compare December 9, 2020 23:37
Motivation: as part of the work on supporting common pandas indexes
a new type (Int64IndexType) representing pandas.Int64Index is added.
Boxing/unboxing of Series and DataFrames as well as common numpy-like
functions are changed accordingly to handle it.
@kozlov-alexey kozlov-alexey changed the title WIP: Adds Int64Index type and updates Series and DF methods to use it Adds Int64Index type and updates Series and DF methods to use it Dec 10, 2020
def typeof_int64_index(val, c):
index_data_ty = numba.typeof(val._data)
is_named = val.name is not None
return Int64IndexType(index_data_ty, is_named=is_named)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Named and unnamed indexes are two different types? Is that what we want?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlexanderKalistratov Yes, for now it's better to stick to the same design as in Series. Later we can move to types.Optional(types.unicode_type), but that might need some fixes in parfor, e.g. see this PR:

# This function is simply a workaround for problem with parfor lowering

Comment thread sdc/extensions/indexes/int64_index_ext.py
Comment thread sdc/extensions/indexes/int64_index_ext.py
index_len = len(self._data)
# FIXME_Numba#5801: Numba type unification rules make this float
idx = types.int64((index_len + idx) if idx < 0 else idx)
if (idx < 0 or idx >= index_len):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm... interesting. This would prevent vectorization on getitem. But we need to do the check. Could compiler take care of it in specific cases?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true, but I'm not sure compiler can remove dead branch from the loop body basing on loop variable range (or am I wrong?) It may be so that we would need checked/unchecked impl (same as Numba does for lists). Need to dig this further.

# names do not matter when comparing pd.Int64Index
left = self.values if self_is_index == True else self # noqa
right = other.values if other_is_index == True else other # noqa
return list(left == right) # FIXME_Numba#5157: result must be np.array, remove list when Numba is fixed

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why list?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a workaround for Numba issue, related to ArrayExpr rewrite incorrectly handling binop implementations for extension types (should be removed when this issue is resolved). See #5157 for details.

Comment thread sdc/extensions/indexes/int64_index_ext.py
Comment thread sdc/extensions/indexes/int64_index_ext.py
Comment thread sdc/extensions/indexes/range_index_ext.py
@kozlov-alexey
kozlov-alexey force-pushed the feature/add_int64index branch from 5977aa2 to f12594b Compare January 19, 2021 22:28
@kozlov-alexey
kozlov-alexey force-pushed the feature/add_int64index branch from f12594b to e3c5022 Compare January 27, 2021 02:04
@kozlov-alexey
kozlov-alexey merged commit 97cff23 into IntelPython:master Jan 29, 2021
kozlov-alexey added a commit that referenced this pull request Feb 19, 2021
* Adds Int64Index type and updates Series and DF methods to use it (#950)

* Adds Int64Index type and updates Series and DF methods to use it

Motivation: as part of the work on supporting common pandas indexes
a new type (Int64IndexType) representing pandas.Int64Index is added.
Boxing/unboxing of Series and DataFrames as well as common numpy-like
functions are changed accordingly to handle it.

* Fixing DateTime tests and PEP remarks

* Fixing review comments #1

* Move to Numba 0.52 (#939)

* Taking numba from master

* Moving to Numba 0.52

commit 3182540b127268ace11cf4042cd87f044875d9fa
Author: Kozlov, Alexey <alexey.kozlov@intel.com>
Date:   Wed Oct 21 19:49:58 2020 +0300

    Cleaning up before squash

commit 895668116542fe3057f73fcb276c441cbde66747
Author: Kozlov, Alexey <alexey.kozlov@intel.com>
Date:   Tue Oct 13 17:31:34 2020 +0300

    Workaround for set from str_arr problem

* Fixing correct NUMBA_VERSION

* Remove intel/label/beta channel from Azure CI builds

* Move to pandas=1.2.0 (#959)

* Move to pandas=1.2.0

Motivation: use latest versions of dependencies.

* More failed tests are fixed

* Fixing doc build

* Fixing bug in stability of mergesort impl for StringArray (#961)

Motivation: for StringArray type legacy implementation of stable sort
computed result when sorting with ascending=False by reversing the
result of argsorting with ascending=True, which produces wrong order in
groups of elements with the same value. Implemented solution adds
new function argument 'ascening' and uses it when calling native function
impl via serial stable_sort.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants