Skip to content

refactor: #718 only drop TimestampSeries #1274

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

Draft
wants to merge 33 commits into
base: main
Choose a base branch
from

Conversation

cmp0xff
Copy link
Contributor

@cmp0xff cmp0xff commented Jul 13, 2025

@cmp0xff cmp0xff marked this pull request as ready for review July 13, 2025 07:05
@cmp0xff cmp0xff changed the title fix: #718 only drop TimestampSeries refactor: #718 only drop TimestampSeries Jul 13, 2025
@cmp0xff cmp0xff force-pushed the hotfix/cmp0xff/gh718-drop-tss branch from c81cd6e to d5e1089 Compare July 16, 2025 17:54
@cmp0xff cmp0xff marked this pull request as draft July 16, 2025 17:56
@cmp0xff cmp0xff force-pushed the hotfix/cmp0xff/gh718-drop-tss branch from d5e1089 to 41c7015 Compare July 16, 2025 18:19
@cmp0xff cmp0xff marked this pull request as ready for review July 16, 2025 20:11
@cmp0xff cmp0xff force-pushed the hotfix/cmp0xff/gh718-drop-tss branch 2 times, most recently from abf9147 to cbbd372 Compare July 17, 2025 15:10
@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Jul 23, 2025

@cmp0xff you have a number of PRs submitted while I was out on vacation for 2 weeks. Can you let me know which ones I should prioritize for review?

@cmp0xff
Copy link
Contributor Author

cmp0xff commented Jul 23, 2025

Hi @Dr-Irv, I hope you had a nice vacation. My pull requests are categorised below. Each category is independent, but those in a higher position have a slightly higher priority in my opinion.

Series: arithmetic operations

The following two PRs are independent. They migrate test_series.py to a subfolder series, and add quite a few test_*.py files there.

DataFrame.to_dict

Index.append

Series: address #718

  1. refactor: #718 only drop TimestampSeries #1274 - this is a prerequisite for the next one.
  2. refactor: #718 also drop TimedeltaSeries #1273

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

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

Thanks for doing this. It's a lot of good work.

Main thing - if I'm going to merge this PR, it needs to be in a state where we don't need the followup PR.

Basic rule - we don't put ignore in the tests unless we are testing that the stubs should not accept something that is invalid. You have places where you have added ignore in the tests and I won't merge that in (unless we know it is a bug in the type checker)

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Jul 24, 2025

Hi @Dr-Irv, I hope you had a nice vacation. My pull requests are categorised below. Each category is independent, but those in a higher position have a slightly higher priority in my opinion.

I've reviewed them all, except #1273 as noted there.

Thanks for all the great work.

@cmp0xff
Copy link
Contributor Author

cmp0xff commented Jul 24, 2025

I've reviewed them all, except #1273 as noted there.

Thanks for all the great work.

Thank you very much for your quick and thorough reviews. I will be able to work on them next week.

@cmp0xff cmp0xff force-pushed the hotfix/cmp0xff/gh718-drop-tss branch from cbbd372 to ed69ec5 Compare July 28, 2025 15:05
@cmp0xff cmp0xff marked this pull request as draft July 30, 2025 07:52
@cmp0xff cmp0xff force-pushed the hotfix/cmp0xff/gh718-drop-tss branch from b095af2 to f1cf19f Compare August 4, 2025 21:36
@cmp0xff cmp0xff mentioned this pull request Aug 19, 2025
1 task
@cmp0xff
Copy link
Contributor Author

cmp0xff commented Aug 20, 2025

Before making this PR as "ready for review", I probably can still clean up the sub family, make some simplifications and homogenise __sub__ and sub.

@cmp0xff cmp0xff marked this pull request as ready for review August 21, 2025 10:12
@cmp0xff cmp0xff requested a review from Dr-Irv August 21, 2025 10:13
Comment on lines +173 to +174
check(assert_type(left_ts.rsub(s), pd.Series), pd.Series, pd.Timedelta)
check(assert_type(left_ts.rsub(a), pd.Series), pd.Series, pd.Timedelta)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

datetime - Series[Any] can either be timedelta-like or datetime-like, depending on Any. I would not give an exact type here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, that makes sense.

) -> TimestampProperties: ...
@overload
def __get__(
self, instance: Series[Timedelta], owner: Any
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use TimedeltaSeries here or TimedeltaSeries | Series[Timedelta] and then change in the PR that will remove TimedeltaSeries

Comment on lines 2247 to 2266
def __mul__(
self, other: timedelta | Timedelta | TimedeltaSeries | np.timedelta64
self: Series[bool],
other: timedelta | np.timedelta64 | np_ndarray_td | TimedeltaSeries,
) -> TimedeltaSeries: ...
@overload
def __mul__(self: Series[bool], other: Series[Timedelta]) -> Series[Timedelta]: ... # type: ignore[overload-overlap]
@overload
def __mul__(
self: Series[int],
other: timedelta | np.timedelta64 | np_ndarray_td | TimedeltaSeries,
) -> TimedeltaSeries: ...
@overload
def __mul__(self: Series[int], other: Series[Timedelta]) -> Series[Timedelta]: ...
@overload
def __mul__(
self: Series[float],
other: timedelta | np.timedelta64 | np_ndarray_td | TimedeltaSeries,
) -> TimedeltaSeries: ...
@overload
def __mul__(self: Series[float], other: Series[Timedelta]) -> Series[Timedelta]: ...
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible to combine these overloads like this?

 @overload
    def __mul__(
        self: Series[bool] | Series[int] | Series[float],
        other: timedelta | np.timedelta64 | np_ndarray_td | TimedeltaSeries,
    ) -> TimedeltaSeries: ...
    @overload
    def __mul__(self: Series[bool]  | Series[int] | Series[float],, other: Series[Timedelta]) -> Series[Timedelta]: ...  # type: ignore[overload-overlap]

def median(
self,
self: Series[float],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
self: Series[float],
self: Series[float] | Series[int]

And then for Series[bool], median() returns np.floating

Comment on lines +3975 to +3982
@overload
def to_numpy(
self,
dtype: DTypeLike | None = None,
copy: bool = False,
na_value: Scalar = ...,
**kwargs,
) -> np_1darray: ...
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think you need this overload because IndexOpsMixin has it. Then you can get rid of the ignores in _SeriesSubClassBase

@cmp0xff cmp0xff marked this pull request as draft August 21, 2025 19:43
@cmp0xff cmp0xff mentioned this pull request Aug 21, 2025
1 task
Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

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

Looked at the most recent version, and found one issue, and there are a few other issues open from previous review. Ping when you want me to look at it.

# checking, where our `__radd__` cannot override. At runtime, they return
# `Series`s.
if TYPE_CHECKING_INVALID_USAGE:
assert_type(i + left, "npt.NDArray[np.int64]")
Copy link
Collaborator

Choose a reason for hiding this comment

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

any assert_type() within the if TYPE_CHECKING_INVALID_USAGE has to have a # type: ignore in it.

If it fails at runtime, and we can't detect it (which is the case here, I think), then just comment out the test and include a comment indicating why this can't be tested.

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

Successfully merging this pull request may close these issues.

3 participants