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

Skip to content

Commit 09f62a4

Browse files
committed
moved super.__init()__
1 parent 23a9d8e commit 09f62a4

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

lib/matplotlib/cm.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,10 @@ def set_array(self, A):
367367
----------
368368
A : ndarray or None
369369
"""
370+
if A is None:
371+
self._A = None
372+
return
373+
370374
if isinstance(self, mpl.collections.QuadMesh):
371375
A_ = A.ravel()
372376
width, height = self._meshWidth, self._meshHeight

lib/matplotlib/collections.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1993,7 +1993,6 @@ class QuadMesh(Collection):
19931993
"""
19941994
def __init__(self, meshWidth, meshHeight, coordinates,
19951995
antialiased=True, shading='flat', **kwargs):
1996-
super().__init__(**kwargs)
19971996
self._meshWidth = meshWidth
19981997
self._meshHeight = meshHeight
19991998
# By converting to floats now, we can avoid that on every draw.
@@ -2005,6 +2004,7 @@ def __init__(self, meshWidth, meshHeight, coordinates,
20052004
self._bbox = transforms.Bbox.unit()
20062005
self._bbox.update_from_data_xy(coordinates.reshape(
20072006
((meshWidth + 1) * (meshHeight + 1), 2)))
2007+
super().__init__(**kwargs)
20082008

20092009
def get_paths(self):
20102010
if self._paths is None:

lib/matplotlib/tests/test_collections.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import io
2+
import re
23
from types import SimpleNamespace
34

45
import numpy as np
@@ -706,17 +707,17 @@ def test_quadmesh_set_array_validation():
706707
coll = ax.pcolormesh(x, y, np.ones(z.shape))
707708
z = np.arange(16).reshape((4, 4))
708709

709-
with pytest.raises(TypeError, match="Dimensions of A (4, 4) "
710-
"are incompatible with X (3) and/or Y (3)"):
710+
with pytest.raises(TypeError, match=re.escape("Dimensions of A (4, 4) "
711+
"are incompatible with X (3) and/or Y (3)")):
711712
coll.set_array(z)
712-
with pytest.raises(TypeError, match="Dimensions of A (16,) "
713-
"are incompatible with X (3) and/or Y (3)"):
713+
with pytest.raises(TypeError, match=re.escape("Dimensions of A (16,) "
714+
"are incompatible with X (3) and/or Y (3)")):
714715
coll.set_array(z.ravel())
715716

716717
fig, ax = plt.subplots()
717718
coll = ax.pcolormesh(x, y, np.ones(z.shape), shading='nearest')
718-
with pytest.raises(TypeError, match="Dimensions of A (3, 3) "
719-
"are incompatible with X (4) and/or Y (4)"):
719+
with pytest.raises(TypeError, match=re.escape("Dimensions of A (3, 3) "
720+
"are incompatible with X (4) and/or Y (4)")):
720721
z = np.arange(9).reshape((3, 3))
721722
coll.set_array(z)
722723

@@ -726,8 +727,8 @@ def test_quadmesh_set_array_validation():
726727
fig, ax = plt.subplots()
727728
coll = ax.pcolormesh(x, y, np.ones(z.shape), shading='gouraud')
728729
z = np.arange(16).reshape((4, 4))
729-
with pytest.raises(TypeError, match="Dimensions of A (4, 4) "
730-
"are incompatible with X (2) and/or Y (2)"):
730+
with pytest.raises(TypeError, match=re.escape("Dimensions of A (4, 4) "
731+
"are incompatible with X (2) and/or Y (2)")):
731732
coll.set_array(z)
732733

733734

0 commit comments

Comments
 (0)