10000 Deprecate is_bbox · matplotlib/matplotlib@19aa67c · GitHub
[go: up one dir, main page]

Skip to content

Commit 19aa67c

Browse files
committed
Deprecate is_bbox
1 parent f47d561 commit 19aa67c

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Exception when not passing a Bbox to BboxTransform*-classes
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
The exception when not passing a Bbox to BboxTransform*-classes that expect one, e.g.,
5+
`~matplotlib.transforms.BboxTransform` has changed from ``ValueError`` to ``TypeError``.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
``TransformNode.is_bbox``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
... is deprecated. Instead check the object using ``isinstance(..., BboxBase)``.

lib/matplotlib/transforms.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class TransformNode:
102102
# Some metadata about the transform, used to determine whether an
103103
# invalidation is affine-only
104104
is_affine = False
105-
is_bbox = False
105+
is_bbox = _api.deprecated("3.9")(_api.classproperty(lambda cls: False))
106106

107107
pass_through = False
108108
"""
@@ -220,7 +220,7 @@ class BboxBase(TransformNode):
220220
and height, but these are not stored explicitly.
221221
"""
222222

223-
is_bbox = True
223+
is_bbox = _api.deprecated("3.9")(_api.classproperty(lambda cls: True))
224224
is_affine = True
225225

226226
if DEBUG:
@@ -1101,8 +1101,7 @@ def __init__(self, bbox, transform, **kwargs):
11011101
bbox : `Bbox`
11021102
transform : `Transform`
11031103
"""
1104-
if not getattr(bbox, 'is_bbox', False):
1105-
raise ValueError("'bbox' is not a bbox")
1104+
_api.check_isinstance(BboxBase, bbox=bbox)
11061105
_api.check_isinstance(Transform, transform=transform)
11071106
if transform.input_dims != 2 or transform.output_dims != 2:
11081107
raise ValueError(
@@ -1190,9 +1189,7 @@ def __init__(self, bbox, x0=None, y0=None, x1=None, y1=None, **kwargs):
11901189
The locked value for y1, or None to leave unlocked.
11911190
11921191
"""
1193-
if not getattr(bbox, 'is_bbox', False):
1194-
raise ValueError("'bbox' is not a bbox")
1195-
1192+
_api.check_isinstance(BboxBase, bbox=bbox)
11961193
super().__init__(**kwargs)
11971194
self._bbox = bbox
11981195
self.set_children(bbox)
@@ -2547,9 +2544,8 @@ def __init__(self, boxin, boxout, **kwargs):
25472544
Create a new `BboxTransform` that linearly transforms
25482545
points from *boxin* to *boxout*.
25492546
"""
2550-
if (not getattr(boxin, 'is_bbox', False) or
2551-
not getattr(boxout, 'is_bbox', False)):
2552-
raise ValueError("'boxin' and 'boxout' must be bbox")
2547+
_api.check_isinstance(BboxBase, boxin=boxin)
2548+
_api.check_isinstance(BboxBase, boxout=boxout)
25532549

25542550
super().__init__(**kwargs)
25552551
self._boxin = boxin
@@ -2592,8 +2588,7 @@ def __init__(self, boxout, **kwargs):
25922588
Create a new `BboxTransformTo` that linearly transforms
25932589
points from the unit bounding box to *boxout*.
25942590
"""
2595-
if not getattr(boxout, 'is_bbox', False):
2596-
raise ValueError("'boxout' must be bbox")
2591+
_api.check_isinstance(BboxBase, boxout=boxout)
25972592

25982593
super().__init__(**kwargs)
25992594
self._boxout = boxout
@@ -2646,8 +2641,7 @@ class BboxTransformFrom(Affine2DBase):
26462641
is_separable = True
26472642

26482643
def __init__(self, boxin, **kwargs):
2649-
if not getattr(boxin, 'is_bbox', False):
2650-
raise ValueError("'boxin' must be bbox")
2644+
_api.check_isinstance(BboxBase 48B8 , boxin=boxin)
26512645

26522646
super().__init__(**kwargs)
26532647
self._boxin = boxin

0 commit comments

Comments
 (0)
0