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

Skip to content

Commit 5604109

Browse files
Code review updates
1 parent 274c5b4 commit 5604109

3 files changed

Lines changed: 7 additions & 14 deletions

File tree

lib/matplotlib/image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ def __init__(self, ax,
905905

906906
def get_window_extent(self, renderer=None):
907907
x0, x1, y0, y1 = self._extent
908-
bbox = Bbox.from_extents(x0, y0, x1, y1)
908+
bbox = Bbox.from_extents([x0, y0, x1, y1])
909909
return bbox.transformed(self.get_transform())
910910

911911
def make_image(self, renderer, magnification=1.0, unsampled=False):

lib/matplotlib/lines.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -683,15 +683,11 @@ def recache(self, always=False):
683683
else:
684684
y = self._y
685685

686-
# Fast path for common case where x and y have same shape
687-
if x.shape == y.shape:
688-
self._xy = np.empty((x.size, 2), dtype=float)
689-
self._xy[:, 0] = x
690-
self._xy[:, 1] = y
691-
else:
692-
self._xy = np.column_stack(np.broadcast_arrays(x, y)).astype(float)
693-
self._x = self._xy[:, 0] # view
694-
self._y = self._xy[:, 1] # view
686+
self._xy = np.empty((max(len(x), len(y)), 2), dtype=float)
687+
self._xy[:, 0] = x # broadcast x and y to the same shape
688+
self._xy[:, 1] = y
689+
self._x = self._xy[:, 0] # views of the x and y data
690+
self._y = self._xy[:, 1]
695691

696692
self._subslice = False
697693
if (self.axes

lib/matplotlib/transforms.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -841,10 +841,7 @@ def from_extents(*args, minpos=None):
841841
set. This is useful when dealing with logarithmic scales and other
842842
scales where negative bounds result in floating point errors.
843843
"""
844-
if len(args) == 4:
845-
bbox = Bbox(np.array([[args[0], args[1]], [args[2], args[3]]], dtype=float))
846-
else:
847-
bbox = Bbox(np.reshape(args, (2, 2)))
844+
bbox = Bbox(np.asarray(args, dtype=float).reshape((2, 2)))
848845
if minpos is not None:
849846
bbox._minpos[:] = minpos
850847
return bbox

0 commit comments

Comments
 (0)