FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Don't call np.identity() in transforms. by anntzer · Pull Request #10327 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
8 changes: 5 additions & 3 deletions lib/matplotlib/transforms.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1928,7 +1928,8 @@ def __init__(self, matrix=None, **kwargs):
"""
Affine2DBase.__init__(self, **kwargs)
if matrix is None:
matrix = np.identity(3)
# A bit faster than np.identity(3).
matrix = IdentityTransform._mtx.copy()
self._mtx = matrix
self._invalid = 0

Expand Down Expand Up @@ -1999,13 +2000,14 @@ def identity():
Unless this transform will be mutated later on, consider using
the faster :class:`IdentityTransform` class instead.
"""
return Affine2D(np.identity(3))
return Affine2D()

def clear(self):
"""
Reset the underlying matrix to the identity transform.
"""
self._mtx = np.identity(3)
# A bit faster than np.identity(3).
self._mtx = IdentityTransform._mtx.copy()
self.invalidate()
return self

Expand Down

Back | FazBrowse Home | New Git URL