8000 Improve check for bbox · matplotlib/matplotlib@c8e34e3 · GitHub
[go: up one dir, main page]

Skip to content

Commit c8e34e3

Browse files
committed
Improve check for bbox
1 parent e90058d commit c8e34e3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/matplotlib/transforms.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ def __init__(self, bbox, transform, **kwargs):
11011101
bbox : `Bbox`
11021102
transform : `Transform`
11031103
"""
1104-
if not bbox.is_bbox:
1104+
if not hasattr(bbox, 'is_bbox') or not bbox.is_bbox:
11051105
raise ValueError("'bbox' is not a bbox")
11061106
_api.check_isinstance(Transform, transform=transform)
11071107
if transform.input_dims != 2 or transform.output_dims != 2:
@@ -1190,7 +1190,7 @@ def __init__(self, bbox, x0=None, y0=None, x1=None, y1=None, **kwargs):
11901190
The locked value for y1, or None to leave unlocked.
11911191
11921192
"""
1193-
if not bbox.is_bbox:
1193+
if not hasattr(bbox, 'is_bbox') or not bbox.is_bbox:
11941194
raise ValueError("'bbox' is not a bbox")
11951195

11961196
super().__init__(**kwargs)
@@ -2547,7 +2547,8 @@ def __init__(self, boxin, boxout, **kwargs):
25472547
Create a new `BboxTransform` that linearly transforms
25482548
points from *boxin* to *boxout*.
25492549
"""
2550-
if not boxin.is_bbox or not boxout.is_bbox:
2550+
if (not hasattr(boxin, 'is_bbox') or not hasattr(boxout, 'is_bbox') or
2551+
not boxin.is_bbox or not boxout.is_bbox):
25512552
raise ValueError("'boxin' and 'boxout' must be bbox")
25522553

25532554
super().__init__(**kwargs)
@@ -2591,7 +2592,7 @@ def __init__(self, boxout, **kwargs):
25912592
Create a new `BboxTransformTo` that linearly transforms
25922593
points from the unit bounding box to *boxout*.
25932594
"""
2594-
if not boxout.is_bbox:
2595+
if not hasattr(boxout, 'is_bbox') or not boxout.is_bbox:
25952596
raise ValueError("'boxout' must be bbox")
25962597

25972598
super().__init__(**kwargs)
@@ -2645,7 +2646,7 @@ class BboxTransformFrom(Affine2DBase):
26452646
is_separable = True
26462647

26472648
def __init__(self, boxin, **kwargs):
2648-
if not boxin.is_bbox:
2649+
if not hasattr(boxin, 'is_bbox') or not boxin.is_bbox:
26492650
raise ValueError("'boxin' must be bbox")
26502651

26512652
super().__init__(**kwargs)

0 commit comments

Comments
 (0)
0