-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
TYP: plotting._matplotlib #47311
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
TYP: plotting._matplotlib #47311
Conversation
| ) | ||
| assert isinstance(vmin, Period) | ||
| assert isinstance(vmax, Period) | ||
| span = vmax.ordinal - vmin.ordinal + 1 |
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.
Can safely assert as NaT has no attribute called ordinal
| return Period(ordinal=int(x), freq=self.freq).strftime(fmt) | ||
| period = Period(ordinal=int(x), freq=self.freq) | ||
| assert isinstance(period, Period) | ||
| return period.strftime(fmt) |
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.
same here: NaT has no strftime
| return Period(x[0], freq_str).to_timestamp().tz_localize(x.tz) == x[0] | ||
| period = Period(x[0], freq_str) | ||
| assert isinstance(period, Period) | ||
| return period.to_timestamp().tz_localize(x.tz) == x[0] |
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.
NaT has no to_timestamp
| return "vertical" | ||
|
|
||
| @property | ||
| def _kind(self) -> Literal["line", "area", "hist", "kde", "box"]: |
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.
Needed so that the sub-classes are compatible with LinePlot
|
|
||
|
|
||
| def _get_period_alias(freq) -> str | None: | ||
| def _get_period_alias(freq: BaseOffset | str) -> str | None: |
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.
The pyi is typed as timedelta | BaseOffset | str and the docstring says to_offset takes timedeltas as well. Should that be included here?
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.
Thanks, yes timedelta should be allowed.
* TYP: plotting._matplotlib * somehow super causes issues * fix pickle issue: was accessing _kind on class * and the last plotting file * add timedelta
The two main changes are 1) consistently using
propertyand 2) checking whetherPeriod()returnsNaT.