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

Revert inclusive default change of IntervalDtype #47367

Merged
merged 11 commits into from
Jul 6, 2022

Conversation

phofl
Copy link
Member

@phofl phofl commented Jun 15, 2022

This adresses the changed default, will add the attribute back in as a follow up

@phofl phofl changed the title Revert inclusive change of IntervalDtype Revert inclusive default change of IntervalDtype Jun 15, 2022
@phofl phofl added the Interval Interval data type label Jun 15, 2022
@phofl phofl added this to the 1.5 milestone Jun 15, 2022
@phofl
Copy link
Member Author

phofl commented Jun 16, 2022

I've moved closed to the end of the arguments, this means the previous position of closed is now filled by inclusive, e.g. positional arguments just work and if something is using keyword arguments, it will show the warning but not disturb the previous order of arguments.

Added propeties for closed and deprecated them

@simonjayhawkins Coud you have a look?

Things still to do (but as follow up):

  • deprecate set_closed and add set_inclusive
  • rename private _closed attritubtes
  • Clean up tests
  • Clean up typing

@@ -69,7 +69,7 @@ cdef class IntervalTree(IntervalMixin):
inclusive, closed = _warning_interval(inclusive, closed)

if inclusive is None:
inclusive = "both"
inclusive = "right"
Copy link
Member

Choose a reason for hiding this comment

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

is IntervalTree public? (or is the class the return type of a public function/method?)

maybe we don't need the deprecation here or don't even need to change at all.

is your understanding that the change from closed -> inclusive is for the public api or across the whole codebase?

Copy link
Member Author

Choose a reason for hiding this comment

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

As far as I can see IntervalTree is private (There are no docs around). It obviously makes sense to rename the kwarg across the whole code base. But since its private, we don't have to be backwards compatible.

Copy link
Member

Choose a reason for hiding this comment

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

yep. probably ok to remove the deprecation here as a follow-up

@@ -229,7 +231,7 @@ def _warning_interval(inclusive: str | None = None, closed: None | lib.NoDefault
stacklevel=2,
)
if closed is None:
inclusive = "both"
inclusive = "right"
Copy link
Member

Choose a reason for hiding this comment

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

not sure about some of the handling/validation here but that's outside the scope of this PR.

we have a deprecate_kwarg decorator that caters for renaming keywords. not sure why not used.

Copy link
Member Author

Choose a reason for hiding this comment

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

I forgot about it, not sure why it was not used before. Switched over now.

@jreback
Copy link
Contributor

jreback commented Jun 18, 2022

this looks fine ex the comments

Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

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

@simonjayhawkins for any followups

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.

Thanks @phofl generally lgtm.

is it possible that _warning_interval can be removed entirely as a follow-up?

not sure if can be done easily but can deprecate_kwarg be used without allowing None as an an acceptable type and just set the default? (not this PR) (so that the deprecation is just removing the decorator)

also some duplication for renaming attribute. maybe some sort of deprecate_attr possible? (not this PR)

@simonjayhawkins simonjayhawkins merged commit d9dd128 into pandas-dev:main Jul 6, 2022
@phofl
Copy link
Member Author

phofl commented Jul 6, 2022

Will have a look. I think if we remove the deprecation for IntervallTree, we should be able to remove _warning_interval

Edit: Will probably put up a few clean up prs separately to keep them easy to review

@phofl phofl deleted the 47365 branch July 6, 2022 12:41
yehoshuadimarsky pushed a commit to yehoshuadimarsky/pandas that referenced this pull request Jul 13, 2022
mroeschke added a commit to mroeschke/pandas that referenced this pull request Aug 17, 2022
mroeschke added a commit that referenced this pull request Aug 18, 2022
…48116)

* Revert "Cln tests interval wrt inclusive (#47775)"

This reverts commit 2d6e0b2.

* Revert "CLN: Rename private variables to inclusive  (#47655)"

This reverts commit 102b3ca.

* Revert "TYP: Improve typing interval inclusive (#47646)"

This reverts commit 5506476.

* Revert "DEPR: Deprecate set_closed and add set_incluive (#47636)"

This reverts commit bd4ff39.

* Revert "DEPR: Remove deprecation from private class IntervalTree (#47637)"

This reverts commit f6658ef.

* Revert "Revert inclusive default change of IntervalDtype (#47367)"

This reverts commit d9dd128.

* Revert "ENH: consistency of input args for boundaries - Interval (#46522)"

This reverts commit 7e23a37.

* Revert "ENH: consistency of input args for boundaries -  pd.interval_range (#46355)"

This reverts commit 073b353.

* Fix ArrowIntervalType manually

* Remove unused import

* Fix doctest and leftover usage

* Fix remaining tests

* Fix wording in doctoring

Co-authored-by: Patrick Hoefler <61934744+phofl@users.noreply.github.com>
noatamir pushed a commit to noatamir/pandas that referenced this pull request Nov 9, 2022
…andas-dev#48116)

* Revert "Cln tests interval wrt inclusive (pandas-dev#47775)"

This reverts commit 2d6e0b2.

* Revert "CLN: Rename private variables to inclusive  (pandas-dev#47655)"

This reverts commit 102b3ca.

* Revert "TYP: Improve typing interval inclusive (pandas-dev#47646)"

This reverts commit 5506476.

* Revert "DEPR: Deprecate set_closed and add set_incluive (pandas-dev#47636)"

This reverts commit bd4ff39.

* Revert "DEPR: Remove deprecation from private class IntervalTree (pandas-dev#47637)"

This reverts commit f6658ef.

* Revert "Revert inclusive default change of IntervalDtype (pandas-dev#47367)"

This reverts commit d9dd128.

* Revert "ENH: consistency of input args for boundaries - Interval (pandas-dev#46522)"

This reverts commit 7e23a37.

* Revert "ENH: consistency of input args for boundaries -  pd.interval_range (pandas-dev#46355)"

This reverts commit 073b353.

* Fix ArrowIntervalType manually

* Remove unused import

* Fix doctest and leftover usage

* Fix remaining tests

* Fix wording in doctoring

Co-authored-by: Patrick Hoefler <61934744+phofl@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Interval Interval data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants