Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add type hints for matplotlib.dates module#30126

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
bandpooja wants to merge6 commits intomatplotlib:main
base:main
Choose a base branch
Loading
frombandpooja:main
Open
Changes fromall commits
Commits
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
200 changes: 200 additions & 0 deletionslib/matplotlib/dates.pyi
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
import datetime
import numpy as np
Copy link
Member

Choose a reason for hiding this comment

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

NumPy is third-party and thus should be in the second block between stdlib and first-party imports.

from typing import Any, Callable, Dict, List, Sequence
Copy link
Member

Choose a reason for hiding this comment

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

No need to useDict/List overdict/list.


from .axis import Axis
from .projections.polar import _AxisWrapper
from .ticker import _DummyAxis, Formatter, Locator
from .units import AxisInfo, ConversionInterface


# --- Global Functions ---

def _get_tzinfo(tz: str | datetime.tzinfo | None = ...) -> datetime.tzinfo: ...

def _reset_epoch_test_example() -> None: ...

def set_epoch(epoch: str) -> None: ...

def get_epoch() -> str: ...

def _dt64_to_ordinalf(d: np.datetime64 | np.ndarray) -> float | 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.

There seems to be a bug here; it doesn't actually acceptnp.datetime64 or return afloat, but crashes. Maybe something to be fixed, or else the type hint shouldn't mention them.


def _from_ordinalf(x: float, tz: str | datetime.tzinfo | None = ...) -> datetime.datetime: ...

def datestr2num(d: str | Sequence[str], default: datetime.datetime | None = ...) -> float | np.ndarray: ...

def date2num(d: datetime.datetime | np.datetime64 | Sequence[datetime.datetime | np.datetime64]) -> float | np.ndarray: ...

def num2date(x: float | Sequence[float], tz: str | datetime.tzinfo | None = ...) -> datetime.datetime | list[datetime.datetime]: ...

def num2timedelta(x: float | Sequence[float]) -> datetime.timedelta | list[datetime.timedelta]: ...
Comment on lines +25 to +31
Copy link
Member

Choose a reason for hiding this comment

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

We may want overloads on these for single input vs sequence input.


def drange(dstart: datetime.datetime, dend: datetime.datetime, delta: datetime.timedelta) -> np.ndarray: ...

def _wrap_in_tex(text: str) -> str: ...

# --- Formatter Classes ---

class DateFormatter(Formatter):
tz: str | datetime.tzinfo | None
Copy link
Member

Choose a reason for hiding this comment

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

This is passed through_get_tz_info before assignment, so should always be adatetime.tzinfo.

fmt: str
_usetex: bool | None
Copy link
Member

Choose a reason for hiding this comment

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

NeverNone, though since this is private and not part of the API, I'm not sure we should type hint it..


def __init__(self, fmt: str, tz: str | datetime.tzinfo | None = None, *, usetex: bool | None = None) -> None: ...
def __call__(self, x: float, pos: int | None = 0) -> str: ...
Comment on lines +44 to +45
Copy link
Member

Choose a reason for hiding this comment

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

Default values should be...:

Suggested change
def__init__(self,fmt:str,tz:str|datetime.tzinfo|None=None,*,usetex:bool|None=None)->None: ...
def__call__(self,x:float,pos:int|None=0)->str: ...
def__init__(self,fmt:str,tz:str|datetime.tzinfo|None=...,*,usetex:bool|None=...)->None: ...
def__call__(self,x:float,pos:int|None=...)->str: ...

def set_tzinfo(self, tz: str | datetime.tzinfo | None) -> None: ...

class ConciseDateFormatter(Formatter):
_locator: Locator
_tz: str | datetime.tzinfo | None
formats: List[str]
Copy link
Member

Choose a reason for hiding this comment

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

Missingdefaultfmt?

zero_formats: List[str]
offset_formats: List[str]
offset_string: str
show_offset: bool
_usetex: bool | None
Copy link
Member

Choose a reason for hiding this comment

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

Again, neverNone, but see above.


def __init__(self, locator: Locator,
tz: str | datetime.tzinfo | None = None,
formats: Sequence[str] | None = None,
offset_formats: Sequence[str] | None = None,
zero_formats: Sequence[str] | None = None,
show_offset: bool = True,
*, usetex: bool | None = None) -> None: ...
def __call__(self, x: float, pos: int | None = 0) -> str: ...
Comment on lines +59 to +65
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
tz:str|datetime.tzinfo|None=None,
formats:Sequence[str]|None=None,
offset_formats:Sequence[str]|None=None,
zero_formats:Sequence[str]|None=None,
show_offset:bool=True,
*,usetex:bool|None=None)->None: ...
def__call__(self,x:float,pos:int|None=0)->str: ...
tz:str|datetime.tzinfo|None=...,
formats:Sequence[str]|None=...,
offset_formats:Sequence[str]|None=...,
zero_formats:Sequence[str]|None=...,
show_offset:bool=...,
*,usetex:bool|None=...)->None: ...
def__call__(self,x:float,pos:int|None=...)->str: ...

def format_ticks(self, values: Sequence[float]) -> List[str]: ...
def get_offset(self) -> str: ...
def format_data_short(self, value: float) -> str: ...

class AutoDateFormatter(Formatter):
_locator: Locator
_tz: str | datetime.tzinfo | None
defaultfmt: str
_formatter: DateFormatter
_usetex: bool | None
scaled: dict
Copy link
Member

Choose a reason for hiding this comment

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

Missing key/value types.


def __init__(self, locator: Locator,
tz: str | datetime.tzinfo | None = None,
defaultfmt: str = '%Y-%m-%d',
*, usetex: bool | None = None) -> None: ...
def _set_locator(self, locator: Locator) -> None: ...
def __call__(self, x: float, pos: int | None = 0) -> str: ...
Comment on lines +78 to +83
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def__init__(self,locator:Locator,
tz:str|datetime.tzinfo|None=None,
defaultfmt:str='%Y-%m-%d',
*,usetex:bool|None=None)->None: ...
def_set_locator(self,locator:Locator)->None: ...
def__call__(self,x:float,pos:int|None=0)->str: ...
def__init__(self,locator:Locator,
tz:str|datetime.tzinfo|None=...,
defaultfmt:str=...,
*,usetex:bool|None=...)->None: ...
def_set_locator(self,locator:Locator)->None: ...
def__call__(self,x:float,pos:int|None=...)->str: ...


# --- rrulewrapper (assuming it's in rrule.py and this is its stub) ---
Copy link
Member

Choose a reason for hiding this comment

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

I don't know what this parentheses means.

class rrulewrapper:
def __init__(self, freq: int, tzinfo: datetime.tzinfo | None = None, **kwargs: Any) -> None: ...
def set(self, **kwargs: Any) -> None: ...
def _update_rrule(self, **kwargs: Any) -> None: ...
def _attach_tzinfo(self, dt: datetime.datetime, tzinfo: datetime.tzinfo) -> datetime.datetime: ...
def _aware_return_wrapper(self, f: Callable[..., Any], returns_list: bool = False) -> Callable[..., Any]: ...
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def_aware_return_wrapper(self,f:Callable[...,Any],returns_list:bool=False)->Callable[...,Any]: ...
def_aware_return_wrapper(self,f:Callable[...,Any],returns_list:bool=...)->Callable[...,Any]: ...

def __getattr__(self, name: str) -> Any: ...
def __setstate__(self, state: dict) -> None: ...

# --- Locator Classes ---

class DateLocator(Locator):
hms0d: dict[str, int]

def __init__(self, tz: datetime.tzinfo | None = None) -> None: ...
def set_tzinfo(self, tz: datetime.tzinfo | None) -> None: ...
def datalim_to_dt(self) -> tuple[datetime.datetime, datetime.datetime]: ...
def viewlim_to_dt(self) -> tuple[datetime.datetime, datetime.datetime]: ...
def _get_unit(self) -> float: ...
def _get_interval(self) -> int: ...
def nonsingular(self, v0: float, v1: float) -> tuple[float, float]: ...

class RRuleLocator(DateLocator):
def __init__(self, o: rrulewrapper, tz: datetime.tzinfo | None = None) -> None: ...
def __call__(self) -> List[float]: ...
def tick_values(self, vmin: float, vmax: float) -> List[float]: ...
def _create_rrule(self, vmin: datetime.datetime, vmax: datetime.datetime) -> tuple[datetime.datetime, datetime.datetime]: ...
def _get_unit(self) -> float: ...
@staticmethod
def get_unit_generic(freq: int) -> float: ...
def _get_interval(self) -> int: ...

class AutoDateLocator(DateLocator):
def __init__(self, tz: str | datetime.tzinfo | None = None, minticks: int = 5,
maxticks: int | Dict[int, int] | None = None,
interval_multiples: bool = True) -> None: ...
def __call__(self) -> List[float]: ...
def tick_values(self, vmin: float, vmax: float) -> List[float]: ...
def nonsingular(self, v0: float, v1: float) -> tuple[float, float]: ...
def _get_unit(self) -> float: ...
def get_locator(self, dmin: datetime.datetime, dmax: datetime.datetime) -> RRuleLocator: ...


class YearLocator(RRuleLocator):
def __init__(self, base: int = 1, month: int = 1, day: int = 1,
tz: str | datetime.tzinfo | None = None) -> None: ...
def _create_rrule(self, vmin: datetime.datetime, vmax: datetime.datetime) -> tuple[datetime.datetime, datetime.datetime]: ...


class MonthLocator(RRuleLocator):
def __init__(self, bymonth: int | List[int] | None = None,
bymonthday: int = 1, interval: int = 1,
tz: str | datetime.tzinfo | None = None) -> None: ...

class WeekdayLocator(RRuleLocator):
def __init__(self, byweekday: int | List[int] = 1, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ...


class DayLocator(RRuleLocator):
def __init__(self, bymonthday: int | List[int] | None = None, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ...


class HourLocator(RRuleLocator):
def __init__(self, byhour: int | List[int] | None = None, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ...


class MinuteLocator(RRuleLocator):
def __init__(self, byminute: int | List[int] | None = None, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ...


class SecondLocator(RRuleLocator):
def __init__(self, bysecond: int | List[int] | None = None, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ...


class MicrosecondLocator(DateLocator):
def __init__(self, interval: int = 1, tz: str | datetime.tzinfo | None = None) -> None: ...
def set_axis(self, axis: Axis | _DummyAxis | _AxisWrapper | None) -> None: ...
def __call__(self) -> List[float]: ...
def tick_values(self, vmin: float, vmax: float) -> Sequence[float]: ...
def _get_unit(self) -> float: ...
def _get_interval(self) -> int: ...

# --- Converter Classes ---

class DateConverter(ConversionInterface):
def __init__(self, *, interval_multiples: bool = True) -> None: ...
@staticmethod
def axisinfo(unit: datetime.tzinfo | None, axis: Axis) -> None: ...
@staticmethod
def convert(obj: datetime.datetime | datetime.date | float | np.datetime64 | Sequence[datetime.datetime | datetime.date | float | np.datetime64],
unit: datetime.tzinfo | None, axis: Axis) -> float | np.ndarray: ...
@staticmethod
def default_units(x: datetime.datetime | datetime.date | float | np.ndarray | Sequence[datetime.datetime | datetime.date | float | np.datetime64],
axis: Axis) -> None: ...


class ConciseDateConverter(DateConverter):
def __init__(self, formats: List[str] | None = None, zero_formats: List[str] | None = None,
offset_formats: List[str] | None = None,
show_offset: bool = True, *, interval_multiples: bool = True) -> None: ...
@staticmethod
def axisinfo(unit: datetime.tzinfo | None, axis: Axis) -> None: ...


class _SwitchableDateConverter:
@staticmethod
def _get_converter() -> "ConciseDateConverter" | "DateConverter": ...
@staticmethod
def axisinfo(unit: datetime.tzinfo | None, axis: Axis) -> AxisInfo: ...
@staticmethod
def default_units(x: datetime.datetime | datetime.date | float | np.ndarray | Sequence[datetime.datetime | datetime.date | float | np.datetime64],
axis: Axis) -> datetime.tzinfo | None: ...
@staticmethod
def convert(value: datetime.datetime | datetime.date | float | np.datetime64 | Sequence[datetime.datetime | datetime.date | float | np.datetime64],
unit: datetime.tzinfo | None, axis: Axis) -> float | np.ndarray: ...
Loading

[8]ページ先頭

©2009-2025 Movatter.jp