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 stubs for Axes3D and improve type hints in _AxesBase#30713

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

Draft
ABarpanda wants to merge8 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromABarpanda:abarpanda
Draft
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletionslib/matplotlib/axes/_base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -550,8 +550,8 @@
# In practice, this is ('x', 'y') for all 2D Axes and ('x', 'y', 'z')
# for Axes3D.
_axis_names = ("x", "y")
_shared_axes = {name: cbook.Grouper() for name in _axis_names}
_twinned_axes = cbook.Grouper()
_shared_axes: dict[str, cbook.Grouper] = {name: cbook.Grouper() for name in _axis_names}

Check warning on line 553 in lib/matplotlib/axes/_base.py

View workflow job for this annotation

GitHub Actions/ ruff

[rdjson] reported by reviewdog 🐶Line too long (92 > 88)Raw Output:message:"Line too long (92 > 88)" location:{path:"/home/runner/work/matplotlib/matplotlib/lib/matplotlib/axes/_base.py" range:{start:{line:553 column:89} end:{line:553 column:93}}} severity:WARNING source:{name:"ruff" url:"https://docs.astral.sh/ruff"} code:{value:"E501" url:"https://docs.astral.sh/ruff/rules/line-too-long"}
_twinned_axes: cbook.Grouper = cbook.Grouper()

_subclass_uses_cla = False

Expand Down
64 changes: 64 additions & 0 deletionslib/matplotlib/axes/_base.pyi
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,6 +41,60 @@ class _axis_method_wrapper:
) -> None: ...
def __set_name__(self, owner: Any, name: str) -> None: ...

class _TransformedBoundsLocator:
_bounds: Sequence[float]
_transform: Transform

def __init__(self, bounds: Sequence[float], transform: Transform) -> None: ...

def __call__(self, ax: Any, renderer: Any) -> Bbox: ...
Comment on lines +48 to +50
Copy link
Member

Choose a reason for hiding this comment

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

Don't need the blank lines between methods in type stubs.



def _process_plot_format(
fmt: str,
*,
ambiguous_fmt_datakey: bool = False
) -> tuple[str | None, str | None, ColorType | None]: ...

class _process_plot_var_args:
output: str

def __init__(self, output: str = ...) -> None: ...

def set_prop_cycle(self, cycler: Any) -> None: ...

def __call__(
self,
axes: Any,
*args: Any,
data: Any | None = ...,
return_kwargs: bool = ...,
**kwargs: Any,
) -> Iterator[Any]: ...

def get_next_color(self) -> Any: ...

def _getdefaults(self, kw: dict[str, Any], ignore: Any = ...) -> dict[str, Any]: ...

def _setdefaults(self, defaults: dict[str, Any], kw: dict[str, Any]) -> None: ...

def _make_line(self, axes: Any, x: Any, y: Any, kw: dict[str, Any], kwargs: dict[str, Any]) -> tuple[Any, dict[str, Any]]: ...

def _make_coordinates(self, axes: Any, x: Any, y: Any, kw: dict[str, Any], kwargs: dict[str, Any]) -> tuple[Any, dict[str, Any]]: ...

def _make_polygon(self, axes: Any, x: Any, y: Any, kw: dict[str, Any], kwargs: dict[str, Any]) -> tuple[Any, dict[str, Any]]: ...

def _plot_args(
self,
axes: Any,
tup: tuple[Any, ...],
kwargs: dict[str, Any],
*,
return_kwargs: bool = ...,
ambiguous_fmt_datakey: bool = ...,
) -> Iterator[Any]: ...


class _AxesBase(martist.Artist):
name: str
patch: Patch
Expand All@@ -64,6 +118,9 @@ class _AxesBase(martist.Artist):
title: Text
_axis_map: dict[str, Axis]
_projection_init: Any
_axis_names: tuple[Literal['x'], Literal['y']] | tuple[Literal['x'], Literal['y'], Literal['z']]
Copy link
Member

Choose a reason for hiding this comment

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

This type is definitely not literals.

Copy link
Member

Choose a reason for hiding this comment

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

@QuLogic not sure. I think right now this is true at least within the core library. At least PolarAxes still has("x", "y") whether that is desirable is another topic.

_shared_axes: dict[str, cbook.Grouper]
_twinned_axes: list[cbook.Grouper]

def __init__(
self,
Expand DownExpand Up@@ -462,3 +519,10 @@ class _AxesBase(martist.Artist):
) -> list[Text]: ...
def xaxis_date(self, tz: str | datetime.tzinfo | None = ...) -> None: ...
def yaxis_date(self, tz: str | datetime.tzinfo | None = ...) -> None: ...


def _draw_rasterized(
figure: Figure,
artists: list[Artist],
renderer: RendererBase,
) -> None: ...
39 changes: 24 additions & 15 deletionslib/mpl_toolkits/mplot3d/axes3d.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -246,7 +246,7 @@

@_api.delete_parameter("3.11", "share")
@_api.delete_parameter("3.11", "anchor")
def set_aspect(self, aspect, adjustable=None, anchor=None, share=False):
def set_aspect(self, aspect, adjustable=None):
"""
Set the aspect ratios.

Expand DownExpand Up@@ -663,10 +663,10 @@

def get_w_lims(self):
"""Get 3D world limits."""
minx, maxx = self.get_xlim3d()
miny, maxy = self.get_ylim3d()
minz, maxz = self.get_zlim3d()
return minx, maxx, miny, maxy, minz, maxz
minx, maxx = self.get_xlim()
miny, maxy = self.get_ylim()
minz, maxz = self.get_zlim()
return(minx, maxx, miny, maxy, minz, maxz)

def _set_bound3d(self, get_bound, set_lim, axis_inverted,
lower=None, upper=None, view_margin=None):
Expand DownExpand Up@@ -1013,7 +1013,7 @@

def get_xlim(self):
# docstring inherited
returntuple(self.xy_viewLim.intervalx)
return (self.xy_viewLim.intervalx)

def get_ylim(self):
# docstring inherited
Expand DownExpand Up@@ -1192,7 +1192,7 @@
self._focal_length = np.inf

def _roll_to_vertical(
self, arr: "np.typing.ArrayLike", reverse: bool = False
self, arr, reverse: bool = False
) -> np.ndarray:
"""
Roll arrays to match the different vertical axis.
Expand All@@ -1215,9 +1215,9 @@
# Transform to uniform world coordinates 0-1, 0-1, 0-1
box_aspect = self._roll_to_vertical(self._box_aspect)
worldM = proj3d.world_transformation(
*self.get_xlim3d(),
*self.get_ylim3d(),
*self.get_zlim3d(),
*self.get_xlim(),
*self.get_ylim(),
*self.get_zlim(),
pb_aspect=box_aspect,
)

Expand DownExpand Up@@ -1502,7 +1502,7 @@
p2 = p1 - scale*vec
return p2, pane_idx

def _arcball(self, x: float, y: float) -> np.ndarray:
def _arcball(self, x, y):
"""
Convert a point (x, y) to a point on a virtual trackball.

Expand DownExpand Up@@ -1808,7 +1808,7 @@
dx = (maxx - minx)
dy = (maxy - miny)
dz = (maxz - minz)
return cx, cy, cz, dx, dy, dz
return(cx, cy, cz, dx, dy, dz)

def set_zlabel(self, zlabel, fontdict=None, labelpad=None, **kwargs):
"""
Expand DownExpand Up@@ -2559,9 +2559,18 @@

return polyc

def _3d_extend_contour(self, cset, stride=5):
def _3d_extend_contour(self, cset, stride = 5) -> None:

Check warning on line 2562 in lib/mpl_toolkits/mplot3d/axes3d.py

View workflow job for this annotation

GitHub Actions/ ruff

[rdjson] reported by reviewdog 🐶Unexpected spaces around keyword / parameter equalsRaw Output:message:"Unexpected spaces around keyword / parameter equals" location:{path:"/home/runner/work/matplotlib/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py" range:{start:{line:2562 column:48} end:{line:2562 column:49}}} severity:WARNING source:{name:"ruff" url:"https://docs.astral.sh/ruff"} code:{value:"E251" url:"https://docs.astral.sh/ruff/rules/unexpected-spaces-around-keyword-parameter-equals"} suggestions:{range:{start:{line:2562 column:48} end:{line:2562 column:49}}}

Check warning on line 2562 in lib/mpl_toolkits/mplot3d/axes3d.py

View workflow job for this annotation

GitHub Actions/ ruff

[rdjson] reported by reviewdog 🐶Unexpected spaces around keyword / parameter equalsRaw Output:message:"Unexpected spaces around keyword / parameter equals" location:{path:"/home/runner/work/matplotlib/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py" range:{start:{line:2562 column:46} end:{line:2562 column:47}}} severity:WARNING source:{name:"ruff" url:"https://docs.astral.sh/ruff"} code:{value:"E251" url:"https://docs.astral.sh/ruff/rules/unexpected-spaces-around-keyword-parameter-equals"} suggestions:{range:{start:{line:2562 column:46} end:{line:2562 column:47}}}
"""
Extend a contour in 3D by creating
Extend a 2D contour set into 3D space by generating vertical faces between
contour levels.

Parameters
----------
cset : matplotlib.contour.QuadContourSet
The contour set (returned by plt.contour or ax.contour) whose levels
and paths will be extended into 3D.
stride : int, optional
Sampling stride for contour segments to reduce polygon count.
"""

dz = (cset.levels[1] - cset.levels[0]) / 2
Expand DownExpand Up@@ -2986,7 +2995,7 @@
if np.may_share_memory(zs_orig, zs): # Avoid unnecessary copies.
zs = zs.copy()

patches = super().scatter(xs, ys, s=s, c=c, *args, **kwargs)
patches = super().scatter(xs, ys,zs,s=s, c=c, *args, **kwargs)
art3d.patch_collection_2d_to_3d(
patches,
zs=zs,
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp