Skip to content

TYP: annotate plotting._matplotlib.converter #35978

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 all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4c5eddd
REF: remove unnecesary try/except
jbrockmendel Aug 21, 2020
c632c9f
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel Aug 21, 2020
9e64be3
Merge branch 'master' of https://github.com/pandas-dev/pandas into re…
jbrockmendel Aug 21, 2020
42649fb
TST: add test for agg on ordered categorical cols (#35630)
mathurk1 Aug 21, 2020
47121dd
TST: resample does not yield empty groups (#10603) (#35799)
tkmz-n Aug 21, 2020
1decb3e
revert accidental rebase
jbrockmendel Aug 22, 2020
57c5dd3
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 22, 2020
a358463
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 23, 2020
ffa7ad7
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 23, 2020
e5e98d4
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 24, 2020
408db5a
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 24, 2020
d3493cf
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 25, 2020
75a805a
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 25, 2020
9f61070
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 25, 2020
2d10f6e
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 26, 2020
3e20187
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 26, 2020
e27d07f
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 27, 2020
c52bed4
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 27, 2020
b69d4d7
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 28, 2020
1c5f8fd
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 28, 2020
061c9e2
Merge branch 'master' of https://github.com/pandas-dev/pandas into ma…
jbrockmendel Aug 28, 2020
7b1c270
TYP: plotting._matplotlib.converter
jbrockmendel Aug 29, 2020
b865ba6
Merge branch 'master' of https://github.com/pandas-dev/pandas into an…
jbrockmendel Aug 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions pandas/plotting/_matplotlib/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import datetime as pydt
from datetime import datetime, timedelta, tzinfo
import functools
from typing import Optional, Tuple
from typing import Any, List, Optional, Tuple

from dateutil.relativedelta import relativedelta
import matplotlib.dates as dates
Expand Down Expand Up @@ -144,7 +144,7 @@ def convert(value, unit, axis):
return value

@staticmethod
def axisinfo(unit, axis):
def axisinfo(unit, axis) -> Optional[units.AxisInfo]:
if unit != "time":
return None

Expand Down Expand Up @@ -294,7 +294,7 @@ def try_parse(values):
return values

@staticmethod
def axisinfo(unit, axis):
def axisinfo(unit: Optional[tzinfo], axis) -> units.AxisInfo:
"""
Return the :class:`~matplotlib.units.AxisInfo` for *unit*.

Expand Down Expand Up @@ -473,7 +473,7 @@ def _get_default_annual_spacing(nyears) -> Tuple[int, int]:
return (min_spacing, maj_spacing)


def period_break(dates, period):
def period_break(dates: PeriodIndex, period: str) -> np.ndarray:
Copy link
Member

Choose a reason for hiding this comment

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

the docsting says that dates is "dates : PeriodIndex" and goes on to say "Array of intervals to monitor." could a PeriodArray be passed?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is only ever called with PeriodIndex. I guess passing PeriodArray wouldnt break the world.

Copy link
Member

Choose a reason for hiding this comment

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

while period_range returns a PeriodIndex there doesn't look like anything to gain by adding PeriodArray atm

"""
Returns the indices where the given period changes.

Expand All @@ -489,7 +489,7 @@ def period_break(dates, period):
return np.nonzero(current - previous)[0]


def has_level_label(label_flags, vmin):
def has_level_label(label_flags: np.ndarray, vmin: float) -> bool:
"""
Returns true if the ``label_flags`` indicate there is at least one label
for this level.
Expand Down Expand Up @@ -984,18 +984,24 @@ class TimeSeries_DateFormatter(Formatter):
----------
freq : {int, string}
Valid frequency specifier.
minor_locator : {False, True}
minor_locator : bool, default False
Whether the current formatter should apply to minor ticks (True) or
major ticks (False).
dynamic_mode : {True, False}
dynamic_mode : bool, default True
Whether the formatter works in dynamic mode or not.
"""

def __init__(self, freq, minor_locator=False, dynamic_mode=True, plot_obj=None):
def __init__(
self,
freq,
minor_locator: bool = False,
dynamic_mode: bool = True,
plot_obj=None,
):
freq = to_offset(freq)
self.format = None
self.freq = freq
self.locs = []
self.locs: List[Any] = [] # unused, for matplotlib compat
self.formatdict = None
self.isminor = minor_locator
self.isdynamic = dynamic_mode
Expand Down