Skip to content

Commit 2cafe97

Browse files
committed
faster minpos construction
1 parent 6ae9b66 commit 2cafe97

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/matplotlib/transforms.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class TransformNode:
110110
invalidated, even if 'self' is already invalid.
111111
"""
112112

113-
def __init__(self, shorthand_name=None):
113+
def __init__(self, shorthand_name=''):
114114
"""
115115
Parameters
116116
----------
@@ -122,7 +122,7 @@ def __init__(self, shorthand_name=None):
122122
self._parents = {}
123123
# Initially invalid, until first computation.
124124
self._invalid = self._INVALID_FULL
125-
self._shorthand_name = shorthand_name or ''
125+
self._shorthand_name = shorthand_name
126126

127127
if DEBUG:
128128
def __str__(self):
@@ -671,6 +671,8 @@ def intersection(bbox1, bbox2):
671671
y1 = np.minimum(bbox1.ymax, bbox2.ymax)
672672
return Bbox([[x0, y0], [x1, y1]]) if x0 <= x1 and y0 <= y1 else None
673673

674+
_default_minpos = np.array([np.inf, np.inf])
675+
674676

675677
class Bbox(BboxBase):
676678
"""
@@ -766,7 +768,7 @@ def __init__(self, points, **kwargs):
766768
raise ValueError('Bbox points must be of the form '
767769
'"[[x0, y0], [x1, y1]]".')
768770
self._points = points
769-
self._minpos = np.array([np.inf, np.inf])
771+
self._minpos = _default_minpos.copy()
770772
self._ignore = True
771773
# it is helpful in some contexts to know if the bbox is a
772774
# default or has been mutated; we store the orig points to

0 commit comments

Comments
 (0)