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

Move towards having get_shared_{x,y}_axes return immutable views.#21584

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

Merged
jklymak merged 1 commit intomatplotlib:mainfromanntzer:gmf
Jun 2, 2022
Merged
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
6 changes: 6 additions & 0 deletionsdoc/api/next_api_changes/deprecations/21584-AL.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
Modifications to the Groupers returned by ``get_shared_x_axes`` and ``get_shared_y_axes``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... are deprecated. In the future, these methods will return immutable views
on the grouper structures. Note that previously, calling e.g. ``join()``
would already fail to set up the correct structures for sharing axes; use
`.Axes.sharex` or `.Axes.sharey` instead.
8 changes: 4 additions & 4 deletionslib/matplotlib/axes/_base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4595,9 +4595,9 @@ def twiny(self):
return ax2

def get_shared_x_axes(self):
"""Returna reference tothe shared axes Grouper object for x axes."""
return self._shared_axes["x"]
"""Returnan immutable view onthe sharedx-axes Grouper."""
returncbook.GrouperView(self._shared_axes["x"])

def get_shared_y_axes(self):
"""Returna reference tothe shared axes Grouper object for y axes."""
return self._shared_axes["y"]
"""Returnan immutable view onthe sharedy-axes Grouper."""
returncbook.GrouperView(self._shared_axes["y"])
28 changes: 28 additions & 0 deletionslib/matplotlib/cbook/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -907,6 +907,34 @@ def get_siblings(self, a):
return [x() for x in siblings]


class GrouperView:
"""Immutable view over a `.Grouper`."""

def __init__(self, grouper):
self._grouper = grouper

class _GrouperMethodForwarder:
def __init__(self, deprecated_kw=None):
self._deprecated_kw = deprecated_kw

def __set_name__(self, owner, name):
wrapped = getattr(Grouper, name)
forwarder = functools.wraps(wrapped)(
lambda self, *args, **kwargs: wrapped(
self._grouper, *args, **kwargs))
if self._deprecated_kw:
forwarder = _api.deprecated(**self._deprecated_kw)(forwarder)
setattr(owner, name, forwarder)

__contains__ = _GrouperMethodForwarder()
__iter__ = _GrouperMethodForwarder()
joined = _GrouperMethodForwarder()
get_siblings = _GrouperMethodForwarder()
clean = _GrouperMethodForwarder(deprecated_kw=dict(since="3.6"))
join = _GrouperMethodForwarder(deprecated_kw=dict(since="3.6"))
remove = _GrouperMethodForwarder(deprecated_kw=dict(since="3.6"))


def simple_linear_interpolation(a, steps):
"""
Resample an array with ``steps - 1`` points between original point pairs.
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp