Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
correct raise_on_incompatible again
  • Loading branch information
natmokval committed Feb 13, 2024
commit 751ab4964cb9ef69883bda0b510bcf76f35e784f
4 changes: 3 additions & 1 deletion pandas/core/arrays/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,9 @@ def raise_on_incompatible(left, right) -> IncompatibleFrequency:
if isinstance(right, (np.ndarray, ABCTimedeltaArray)) or right is None:
other_freq = None
elif isinstance(right, BaseOffset):
other_freq = PeriodDtype(right)._freqstr
with warnings.catch_warnings():
warnings.simplefilter("ignore")
Copy link
Member

Choose a reason for hiding this comment

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

looks a bit dangerous :) is this for the business day warning? if so, I'd suggest either enforcing that one first, or using warnings.filterwarnings and only filtering the warning you mean to

Copy link
Contributor Author

@natmokval natmokval Feb 15, 2024

Choose a reason for hiding this comment

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

yes, this is for the business day warning. I agree, it's better to use warnings.filterwarnings instead of warnings.simplefilter. I made changes in order to filter: "Future warning "PeriodDtype[B] is deprecated"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can rid of this warnings.filterwarnings after enforcing depreciation of PeriodDtype[B], or we can postpone merging this PR until enforcing deprecation of PeriodDtype[B] is done.

other_freq = PeriodDtype(right)._freqstr
elif isinstance(right, (ABCPeriodIndex, PeriodArray, Period)):
other_freq = right.freqstr
else:
Expand Down