Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Create category.pyi#30093
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
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Create category.pyi#30093
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,58 @@ | ||||||
""" | ||||||
Plotting of string "category" data: ``plot(['d', 'f', 'a'], [1, 2, 3])`` will | ||||||
plot three points with x-axis values of 'd', 'f', 'a'. | ||||||
See :doc:`/gallery/lines_bars_and_markers/categorical_variables` for an | ||||||
example. | ||||||
The module uses Matplotlib's `matplotlib.units` mechanism to convert from | ||||||
strings to integers and provides a tick locator, a tick formatter, and the | ||||||
`.UnitData` class that creates and stores the string-to-integer mapping. | ||||||
""" | ||||||
Comment on lines +1 to +11 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. The .pyi files don't typically have doc strings | ||||||
from __future__ import annotations | ||||||
from matplotlib.units import ConversionInterface, AxisInfo | ||||||
from matplotlib import ticker | ||||||
from matplotlib.axis import Axis | ||||||
from collections import OrderedDict | ||||||
import numpy as np | ||||||
from typing import Any, Dict, Iterable, List, Optional, Union | ||||||
class StrCategoryConverter(ConversionInterface): | ||||||
@staticmethod | ||||||
def convert( | ||||||
value: Union[str, Iterable[str]], | ||||||
Check failure on line 24 in lib/matplotlib/category.pyi
| ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Suggested change
The .pyi files typically use the union operator rather than explicit union, please make this change to all the unions in this file | ||||||
unit: UnitData, | ||||||
Check failure on line 25 in lib/matplotlib/category.pyi
| ||||||
axis: Axis | ||||||
) -> Union[float, np.ndarray]: ... | ||||||
@staticmethod | ||||||
def axisinfo(unit: UnitData, axis: Axis) -> AxisInfo: ... | ||||||
@staticmethod | ||||||
def default_units( | ||||||
data: Union[str, Iterable[str]], | ||||||
Check failure on line 32 in lib/matplotlib/category.pyi
| ||||||
axis: Axis | ||||||
) -> UnitData: ... | ||||||
@staticmethod | ||||||
def _validate_unit(unit: UnitData) -> None: ... | ||||||
class StrCategoryLocator(ticker.Locator): | ||||||
def __init__(self, units_mapping: Dict[str, int]) -> None: ... | ||||||
def __call__(self) -> List[int]: ... | ||||||
def tick_values(self, vmin: Any, vmax: Any) -> List[int]: ... | ||||||
class StrCategoryFormatter(ticker.Formatter): | ||||||
def __init__(self, units_mapping: Dict[str, int]) -> None: ... | ||||||
def __call__(self, x: float, pos: Optional[int] = None) -> str: ... | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Suggested change
also use the | convetion for optional, seehttps://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html | ||||||
def format_ticks(self, values: Iterable[float]) -> List[str]: ... | ||||||
@staticmethod | ||||||
def _text(value: Union[str, bytes]) -> str: ... | ||||||
class UnitData: | ||||||
_mapping: OrderedDict[Union[str, bytes], int] | ||||||
def __init__( | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I think | ||||||
self, | ||||||
Check failure on line 53 in lib/matplotlib/category.pyi
| ||||||
data: Optional[Iterable[Union[str, bytes]]] = None | ||||||
) -> None: ... | ||||||
def update(self, data: Iterable[Union[str, bytes]]) -> None: ... | ||||||
@staticmethod | ||||||
def _str_is_convertible(val: Union[str, bytes]) -> bool: ... |
Uh oh!
There was an error while loading.Please reload this page.