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

Skip to content

Commit a071304

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

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/matplotlib/tests/test_collections.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import io
22
from types import SimpleNamespace
3+
from typing import Type
34

45
import numpy as np
56
from numpy.testing import assert_array_equal, assert_array_almost_equal
@@ -677,6 +678,22 @@ def test_collection_set_verts_array():
677678
assert np.array_equal(ap._codes, atp._codes)
678679

679680

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

0 commit comments

Comments
 (0)