Skip to content
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

Resolve issues with ambiguity in typed Series #5

Closed
Dr-Irv opened this issue May 3, 2022 · 2 comments
Closed

Resolve issues with ambiguity in typed Series #5

Dr-Irv opened this issue May 3, 2022 · 2 comments

Comments

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented May 3, 2022

pyright and mypy have issues in dealing with overloads on generics that are ambiguous, as pointed out by numpy. See the following:

Issue comes in to play with respect to subtraction. For pandas, we'd like an untyped Series to remain untyped, but subtraction of two Series[Timestamp] to yield Series[Timedelta] . This doesn't seem possible. Right now, the current stubs return Series[Timestamp] when subtracting two untyped series, but do return Series[Timedelta] when subtracting two Series[Timestamp]. Discovered this by using the new assert_type() feature.

In the current stubs from MS copied here, we use Series[bool], Series[Timestamp], Series[Timedelta], Series[float] and Series[int] as arguments and/or return types of different methods, which sharpens up some of the type checks.

Possible solutions:

  1. Give up on using generic Series.
  2. For typing purposes, create BoolSeries, TimestampSeries, TimedeltaSeries, FloatSeries and IntSeries that are typing subclasses of Series that can help with series that have types and those that don't.

Need to experiment with (2), and if it can't work, just remove all the generic stuff.

@Dr-Irv
Copy link
Collaborator Author

Dr-Irv commented May 3, 2022

Latest commit #12250f0de83ba445507dc301a62c46f659f0a6aa has a start in using (2) above which seems to be a promising solution.

@Dr-Irv
Copy link
Collaborator Author

Dr-Irv commented May 11, 2022

Closing - now seems to work by creating special classes for Series of Timestamp and Series of Timedelta

@Dr-Irv Dr-Irv closed this as completed May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant