Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove deprecations: is_bbox and more #30067

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
23 changes: 23 additions & 0 deletions doc/api/next_api_changes/removals/30067-OG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
``TransformNode.is_bbox``
^^^^^^^^^^^^^^^^^^^^^^^^^

... is removed. Instead check the object using ``isinstance(..., BboxBase)``.

``rcsetup.interactive_bk``, ``rcsetup.non_interactive_bk`` and ``rcsetup.all_backends``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

... are removed and replaced by ``matplotlib.backends.backend_registry.list_builtin``
with the following arguments

- ``matplotlib.backends.BackendFilter.INTERACTIVE``
- ``matplotlib.backends.BackendFilter.NON_INTERACTIVE``
- ``None``

``BboxTransformToMaxOnly``
^^^^^^^^^^^^^^^^^^^^^^^^^^

... is removed. If you rely on this, please make a copy of old the code.
Copy link
Member

Choose a reason for hiding this comment

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

I think you can replace it with a BboxTransformTo(LockableBbox(bbox, x0=0, y0=0))


*interval* parameter of ``TimerBase.start``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The timer interval parameter can no longer be set while starting it. The interval can be specified instead in the timer constructor, or by setting the timer.interval attribute.
15 changes: 2 additions & 13 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,19 +1067,8 @@ def __del__(self):
"""Need to stop timer and possibly disconnect timer."""
self._timer_stop()

@_api.delete_parameter("3.9", "interval", alternative="timer.interval")
def start(self, interval=None):
"""
Start the timer object.

Parameters
----------
interval : int, optional
Timer interval in milliseconds; overrides a previously set interval
if provided.
"""
if interval is not None:
self.interval = interval
def start(self):
"""Start the timer."""
self._timer_start()

def stop(self):
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backend_bases.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class TimerBase:
callbacks: list[tuple[Callable, tuple, dict[str, Any]]] | None = ...,
) -> None: ...
def __del__(self) -> None: ...
def start(self, interval: int | None = ...) -> None: ...
def start(self) -> None: ...
def stop(self) -> None: ...
@property
def interval(self) -> int: ...
Expand Down
28 changes: 1 addition & 27 deletions lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import matplotlib as mpl
from matplotlib import _api, cbook
from matplotlib.backends import BackendFilter, backend_registry
from matplotlib.backends import backend_registry
from matplotlib.cbook import ls_mapper
from matplotlib.colors import Colormap, is_color_like
from matplotlib._fontconfig_pattern import parse_fontconfig_pattern
Expand All @@ -34,32 +34,6 @@
from cycler import Cycler, cycler as ccycler


@_api.caching_module_getattr
class __getattr__:
@_api.deprecated(
"3.9",
alternative="``matplotlib.backends.backend_registry.list_builtin"
"(matplotlib.backends.BackendFilter.INTERACTIVE)``")
@property
def interactive_bk(self):
return backend_registry.list_builtin(BackendFilter.INTERACTIVE)

@_api.deprecated(
"3.9",
alternative="``matplotlib.backends.backend_registry.list_builtin"
"(matplotlib.backends.BackendFilter.NON_INTERACTIVE)``")
@property
def non_interactive_bk(self):
return backend_registry.list_builtin(BackendFilter.NON_INTERACTIVE)

@_api.deprecated(
"3.9",
alternative="``matplotlib.backends.backend_registry.list_builtin()``")
@property
def all_backends(self):
return backend_registry.list_builtin()


class ValidateInStrings:
def __init__(self, key, valid, ignorecase=False, *,
_deprecated_since=None):
Expand Down
3 changes: 0 additions & 3 deletions lib/matplotlib/rcsetup.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ from collections.abc import Callable, Iterable
from typing import Any, Literal, TypeVar
from matplotlib.typing import ColorType, LineStyleType, MarkEveryType

interactive_bk: list[str]
non_interactive_bk: list[str]
all_backends: list[str]

_T = TypeVar("_T")

Expand Down
11 changes: 0 additions & 11 deletions lib/matplotlib/tests/test_backend_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import pytest

import matplotlib as mpl
from matplotlib.backends import BackendFilter, backend_registry


Expand Down Expand Up @@ -95,16 +94,6 @@ def test_backend_normalization(backend, normalized):
assert backend_registry._backend_module_name(backend) == normalized


def test_deprecated_rcsetup_attributes():
match = "was deprecated in Matplotlib 3.9"
with pytest.warns(mpl.MatplotlibDeprecationWarning, match=match):
mpl.rcsetup.interactive_bk
with pytest.warns(mpl.MatplotlibDeprecationWarning, match=match):
mpl.rcsetup.non_interactive_bk
with pytest.warns(mpl.MatplotlibDeprecationWarning, match=match):
mpl.rcsetup.all_backends


def test_entry_points_inline():
pytest.importorskip('matplotlib_inline')
backends = backend_registry.list_all()
Expand Down
23 changes: 0 additions & 23 deletions lib/matplotlib/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ class TransformNode:
# Some metadata about the transform, used to determine whether an
# invalidation is affine-only
is_affine = False
is_bbox = _api.deprecated("3.9")(_api.classproperty(lambda cls: False))

pass_through = False
"""
Expand Down Expand Up @@ -216,7 +215,6 @@ class BboxBase(TransformNode):
and height, but these are not stored explicitly.
"""

is_bbox = _api.deprecated("3.9")(_api.classproperty(lambda cls: True))
is_affine = True

if DEBUG:
Expand Down Expand Up @@ -2627,27 +2625,6 @@ def get_matrix(self):
return self._mtx


@_api.deprecated("3.9")
class BboxTransformToMaxOnly(BboxTransformTo):
"""
`BboxTransformToMaxOnly` is a transformation that linearly transforms points from
the unit bounding box to a given `Bbox` with a fixed upper left of (0, 0).
"""
def get_matrix(self):
# docstring inherited
if self._invalid:
xmax, ymax = self._boxout.max
if DEBUG and (xmax == 0 or ymax == 0):
raise ValueError("Transforming to a singular bounding box.")
self._mtx = np.array([[xmax, 0.0, 0.0],
[ 0.0, ymax, 0.0],
[ 0.0, 0.0, 1.0]],
float)
self._inverted = None
self._invalid = 0
return self._mtx


class BboxTransformFrom(Affine2DBase):
"""
`BboxTransformFrom` linearly transforms points from a given `Bbox` to the
Expand Down
4 changes: 0 additions & 4 deletions lib/matplotlib/transforms.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class TransformNode:
INVALID_NON_AFFINE: int
INVALID_AFFINE: int
INVALID: int
is_bbox: bool
# Implemented as a standard attr in base class, but functionally readonly and some subclasses implement as such
@property
def is_affine(self) -> bool: ...
Expand All @@ -24,7 +23,6 @@ class TransformNode:
def frozen(self) -> TransformNode: ...

class BboxBase(TransformNode):
is_bbox: bool
is_affine: bool
def frozen(self) -> Bbox: ...
def __array__(self, *args, **kwargs): ...
Expand Down Expand Up @@ -295,8 +293,6 @@ class BboxTransform(Affine2DBase):
class BboxTransformTo(Affine2DBase):
def __init__(self, boxout: BboxBase, **kwargs) -> None: ...

class BboxTransformToMaxOnly(BboxTransformTo): ...

class BboxTransformFrom(Affine2DBase):
def __init__(self, boxin: BboxBase, **kwargs) -> None: ...

Expand Down
Loading