Skip to content

TYP: sparse.pyi #43514

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
Sep 12, 2021
Merged

TYP: sparse.pyi #43514

merged 1 commit into from
Sep 12, 2021

Conversation

mzeitlin11
Copy link
Member

A start to typing sparse stuff, tried to do this without touching the cython code, hopefully some cleanups possible once typing somewhat specified.

cc @jbrockmendel, one annoying piece going on here is the abstract base class SparseIndex - it functions entirely like an interface, and so has nothing but abstract methods. Currently, in cython only __init__ is defined for the base class, so the current typing with multiple methods in the base class is a bit of a white lie. We could just add all the methods to the base class and have them raise NotImplementedError, but not sure if that's just unnecessary code bloat since it works as is.


index: SparseIndex
Copy link
Member Author

Choose a reason for hiding this comment

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

This could probably be narrowed further in a followup using the relation
kind = "integer" -> returns IntIndex
kind = "block" -> returns BlockIndex

@mzeitlin11 mzeitlin11 added Sparse Sparse Data Type Typing type annotations, mypy/pyright type checking labels Sep 11, 2021
@jbrockmendel
Copy link
Member

LGTM; i think we've gone the white lie route elsewhere but not sure where off the top of my head

@jreback jreback added this to the 1.4 milestone Sep 12, 2021
@jreback jreback merged commit 663185e into pandas-dev:master Sep 12, 2021
@jreback
Copy link
Contributor

jreback commented Sep 12, 2021

thanks @mzeitlin11

@mzeitlin11 mzeitlin11 deleted the typ_sparse_pyi branch September 12, 2021 15:11
AlexeyGy pushed a commit to AlexeyGy/pandas that referenced this pull request Sep 13, 2021
AlexeyGy pushed a commit to AlexeyGy/pandas that referenced this pull request Sep 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Sparse Sparse Data Type Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants