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

Skip to content

Commit dc752b3

Browse files
authored
Merge pull request #6677 from anntzer/copyless-pcolormesh
API/MNT: Remove a copy in pcolormesh Internal data can now be mutated externally.
2 parents 191277a + be37304 commit dc752b3

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lib/matplotlib/collections.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,19 +1783,16 @@ def __init__(self, meshWidth, meshHeight, coordinates,
17831783
Collection.__init__(self, **kwargs)
17841784
self._meshWidth = meshWidth
17851785
self._meshHeight = meshHeight
1786-
self._coordinates = coordinates
1786+
# By converting to floats now, we can avoid that on every draw.
1787+
self._coordinates = np.asarray(coordinates, float).reshape(
1788+
(meshHeight + 1, meshWidth + 1, 2))
17871789
self._antialiased = antialiased
17881790
self._shading = shading
17891791

17901792
self._bbox = transforms.Bbox.unit()
17911793
self._bbox.update_from_data_xy(coordinates.reshape(
17921794
((meshWidth + 1) * (meshHeight + 1), 2)))
17931795

1794-
# By converting to floats now, we can avoid that on every draw.
1795-
self._coordinates = self._coordinates.reshape(
1796-
(meshHeight + 1, meshWidth + 1, 2))
1797-
self._coordinates = np.array(self._coordinates, float)
1798-
17991796
def get_paths(self):
18001797
if self._paths is None:
18011798
self.set_paths()

0 commit comments

Comments
 (0)