Skip to content

Commit c4b9f9f

Browse files
committed
Test set_array for copy and wrong dtype
1 parent 9cc32b0 commit c4b9f9f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/matplotlib/tests/test_collections.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,22 @@ def test_collection_set_verts_array():
677677
assert np.array_equal(ap._codes, atp._codes)
678678

679679

680+
def test_collection_set_array():
681+
vals = [*range(10)]
682+
683+
# Test set_array with list
684+
c = Collection()
685+
c.set_array(vals)
686+
687+
# Test set_array with wrong dtype
688+
with pytest.raises(TypeError, match="^Image data of dtype"):
689+
c.set_array("wrong_input")
690+
691+
# Test if array kwarg is copied
692+
vals[5] = 45
693+
assert np.not_equal(vals, c.get_array()).any()
694+
695+
680696
def test_blended_collection_autolim():
681697
a = [1, 2, 4]
682698
height = .2

0 commit comments

Comments
 (0)