Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Avoid unneeded copies from flatten(). #13381

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

Merged
merged 1 commit into from
Feb 7, 2019
Merged
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
10 changes: 5 additions & 5 deletions 10 lib/matplotlib/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def __array__(self, *args, **kwargs):

def is_unit(self):
"""Return whether this is the unit box (from (0, 0) to (1, 1))."""
return list(self.get_points().flatten()) == [0., 0., 1., 1.]
return self.get_points().tolist() == [[0., 0.], [1., 1.]]

@property
def x0(self):
Expand Down Expand Up @@ -413,13 +413,13 @@ def size(self):
@property
def bounds(self):
"""Return (:attr:`x0`, :attr:`y0`, :attr:`width`, :attr:`height`)."""
x0, y0, x1, y1 = self.get_points().flatten()
(x0, y0), (x1, y1) = self.get_points()
return (x0, y0, x1 - x0, y1 - y0)

@property
def extents(self):
"""Return (:attr:`x0`, :attr:`y0`, :attr:`x1`, :attr:`y1`)."""
return self.get_points().flatten().copy()
return self.get_points().flatten() # flatten returns a copy.

def get_points(self):
raise NotImplementedError
Expand Down Expand Up @@ -1758,10 +1758,10 @@ def is_separable(self):

def to_values(self):
"""
Return the values of the matrix as a sequence (a,b,c,d,e,f)
Return the values of the matrix as an ``(a, b, c, d, e, f)`` tuple.
"""
mtx = self.get_matrix()
return tuple(mtx[:2].swapaxes(0, 1).flatten())
return tuple(mtx[:2].swapaxes(0, 1).flat)

@staticmethod
def matrix_from_values(a, b, c, d, e, f):
Expand Down
24 changes: 9 additions & 15 deletions 24 lib/mpl_toolkits/mplot3d/axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,22 +490,16 @@ def autoscale(self, enable=True, axis='both', tight=None):
scalez=scalez)

def auto_scale_xyz(self, X, Y, Z=None, had_data=None):
x, y, z = map(np.asarray, (X, Y, Z))
try:
x, y = x.flatten(), y.flatten()
if Z is not None:
z = z.flatten()
except AttributeError:
raise

# This updates the bounding boxes as to keep a record as
# to what the minimum sized rectangular volume holds the
# data.
self.xy_dataLim.update_from_data_xy(np.array([x, y]).T, not had_data)
if z is not None:
# This updates the bounding boxes as to keep a record as to what the
# minimum sized rectangular volume holds the data.
X = np.reshape(X, -1)
Y = np.reshape(Y, -1)
self.xy_dataLim.update_from_data_xy(
np.column_stack([X, Y]), not had_data)
if Z is not None:
Z = np.reshape(Z, -1)
self.zz_dataLim.update_from_data_xy(
np.array([z, z]).T, not had_data)

np.column_stack([Z, Z]), not had_data)
# Let autoscale_view figure out how to use this data.
self.autoscale_view()

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.