Skip to content

CLN: annotations in core.apply #29477

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 5 commits into from
Nov 12, 2019
Merged

Conversation

jbrockmendel
Copy link
Member

make apply_broadcast have consistent signature.

After this I plan to do a pass to make these classes much less stateful

Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

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

@jbrockmendel generally lgtm. a few comments.


@property
def axis(self) -> int:
raise AbstractMethodError(self)
Copy link
Member

Choose a reason for hiding this comment

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

can we not use @abc.abstractmethod going forward for new code?

Copy link
Member Author

Choose a reason for hiding this comment

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

OK. It looks like for axis I can do just axis: int but for the others I have to use property+abc.abstractmethod.

Updated.


def __init__(
self,
obj: "DataFrame",
Copy link
Member

Choose a reason for hiding this comment

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

should we consider making FrameApply generic if we want subclassed DataFrames to return same type?

Copy link
Member Author

Choose a reason for hiding this comment

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

im not sure i understand the question. FrameApply is the base class for ColumnFrameApply and RowFrameApply

Copy link
Member

Choose a reason for hiding this comment

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

I've not looked in detail but may not be relevant here.

Not sure how geopandas (or other downstream packages work), Just keeping in mind that, say GeoDataFrame, may return a GeoDataFrame with certain operations.

did start to type geopandas so I had a better idea, see geopandas/geopandas@master...simonjayhawkins:typing.

Note to self: Should try and get back to this.

raise AbstractMethodError(self)

@property
def series_generator(self) -> Iterator["Series"]:
Copy link
Member

Choose a reason for hiding this comment

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

For return types, this could also be typed as Iterable. we've done this in a couple of places.

Copy link
Member Author

Choose a reason for hiding this comment

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

isnt iterator more informative than iterable?

Copy link
Member

Choose a reason for hiding this comment

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

for a return type it's nor relevant, so it's just a consistency thing.

@simonjayhawkins simonjayhawkins added this to the 1.0 milestone Nov 8, 2019
@simonjayhawkins simonjayhawkins added the Typing type annotations, mypy/pyright type checking label Nov 8, 2019
@jbrockmendel
Copy link
Member Author

updated the abstractmethod thing. didnt change Iterator-> Iterable because i still have a mild preference, but will if its a deal-breaker.

@jreback jreback merged commit 57e1b34 into pandas-dev:master Nov 12, 2019
@jreback
Copy link
Contributor

jreback commented Nov 12, 2019

cool

@jbrockmendel jbrockmendel deleted the cln-apply2 branch November 13, 2019 00:02
Reksbril pushed a commit to Reksbril/pandas that referenced this pull request Nov 18, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants