-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DEPR: Rolling.win_type returning freq & is_datetimelike #38963
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
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e798b10
DEPR: Rolling.win_type returning freq
mroeschke dcdb380
Add PR number
mroeschke e9cffde
Add extra space below
mroeschke 6cd2e55
Deprecate is_datetimelike as well
mroeschke bf43e57
Filter warning when copying
mroeschke 1def4d9
Add better warning handling
mroeschke 1870a52
Merge remote-tracking branch 'upstream/master' into depr/win_type
mroeschke 36e1ae7
Move warning to lower level
mroeschke 10b8d6c
supress warning in groupby
mroeschke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -110,7 +110,8 @@ def __init__( | |||||||||||
self.window = window | ||||||||||||
self.min_periods = min_periods | ||||||||||||
self.center = center | ||||||||||||
self.win_type = win_type | ||||||||||||
# TODO: Change this back to self.win_type once deprecation is enforced | ||||||||||||
self._win_type = win_type | ||||||||||||
self.axis = obj._get_axis_number(axis) if axis is not None else None | ||||||||||||
self.method = method | ||||||||||||
self._win_freq_i8 = None | ||||||||||||
|
@@ -131,6 +132,32 @@ def __init__( | |||||||||||
) | ||||||||||||
self.validate() | ||||||||||||
|
||||||||||||
# TODO: Remove once win_type deprecation is enforced | ||||||||||||
def _shallow_copy(self, obj, **kwargs): | ||||||||||||
warnings.simplefilter("ignore", FutureWarning) | ||||||||||||
super()._shallow_copy(obj, **kwargs) | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
this should ensure the warning filter is only changed inside that context |
||||||||||||
|
||||||||||||
@property | ||||||||||||
def win_type(self): | ||||||||||||
if self._win_freq_i8 is not None: | ||||||||||||
warnings.warn( | ||||||||||||
"win_type will no longer return 'freq' in a future version. " | ||||||||||||
"Check the type of self.window instead.", | ||||||||||||
FutureWarning, | ||||||||||||
stacklevel=2, | ||||||||||||
) | ||||||||||||
return "freq" | ||||||||||||
return self._win_type | ||||||||||||
|
||||||||||||
@property | ||||||||||||
def is_datetimelike(self): | ||||||||||||
warnings.warn( | ||||||||||||
"is_datetimelike is deprecated and will be removed in a future version.", | ||||||||||||
FutureWarning, | ||||||||||||
stacklevel=2, | ||||||||||||
) | ||||||||||||
return self._win_freq_i8 is not None | ||||||||||||
|
||||||||||||
def validate(self) -> None: | ||||||||||||
if self.center is not None and not is_bool(self.center): | ||||||||||||
raise ValueError("center must be a boolean") | ||||||||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small future note: since
pd.Rolling
does not exist, such a:attr:`Rolling.win_type`
does not workThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay thanks for the note.