Skip to content

BUG: PeriodDtype incorrectly caching different DateOffset freqs #52991

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 5 commits into from
May 2, 2023

Conversation

mroeschke
Copy link
Member

@mroeschke mroeschke commented Apr 28, 2023

@mroeschke mroeschke added Frequency DateOffsets Period Period data type labels Apr 28, 2023
@mroeschke mroeschke added this to the 2.1 milestone Apr 28, 2023
@jbrockmendel
Copy link
Member

pandas/core/dtypes/dtypes.py:902: error: Incompatible types in assignment (expression has type "Dict[int, PandasExtensionDtype]", base class "PandasExtensionDtype" defined the type as "Dict[str, PandasExtensionDtype]") [assignment]
Found 1 error in 1 file (checked 1417 source files)

This is one of the complaints I've been seeing locally for a while. No idea why its showing up now

@@ -22,6 +22,15 @@ def test_registered():
assert result == expected


def test_perioddtype_caching_dateoffset_normalize():
Copy link
Member

Choose a reason for hiding this comment

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

Can this go with other PeriodDtype tests (as opposed to the Array)

@@ -899,7 +899,7 @@ class PeriodDtype(PeriodDtypeBase, PandasExtensionDtype):
num = 102
_metadata = ("freq",)
_match = re.compile(r"(P|p)eriod\[(?P<freq>.+)\]")
_cache_dtypes: dict[int, PandasExtensionDtype] = {}
_cache_dtypes: dict[BaseOffset, PandasExtensionDtype] = {} # type: ignore[assignment] # noqa:E501
Copy link
Member

Choose a reason for hiding this comment

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

missing the usual "# error: ..." in the previous line? should the value be PeriodDtype instead of PandasExtensionDtype?

@jbrockmendel jbrockmendel merged commit 638a414 into pandas-dev:main May 2, 2023
@jbrockmendel
Copy link
Member

thanks @mroeschke

@mroeschke mroeschke deleted the bug/perioddtype/cache branch May 2, 2023 16:28
topper-123 pushed a commit to topper-123/pandas that referenced this pull request May 7, 2023
…as-dev#52991)

* BUG: PeriodDtype incorrectly caching different DateOffset freqs

* Change typing

* Address review

* Add more specific typing and error message
Rylie-W pushed a commit to Rylie-W/pandas that referenced this pull request May 19, 2023
…as-dev#52991)

* BUG: PeriodDtype incorrectly caching different DateOffset freqs

* Change typing

* Address review

* Add more specific typing and error message
Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
…as-dev#52991)

* BUG: PeriodDtype incorrectly caching different DateOffset freqs

* Change typing

* Address review

* Add more specific typing and error message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Frequency DateOffsets Period Period data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG - PeriodIndex.freq.normalize option gets cached per process
2 participants