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

Skip to content

Commit 1c0c884

Browse files
committed
Update tests for data containers
1 parent 201c49d commit 1c0c884

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

lib/matplotlib/tests/test_collections.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -837,16 +837,16 @@ def test_collection_set_verts_array():
837837
verts = np.arange(80, dtype=np.double).reshape(10, 4, 2)
838838
col_arr = PolyCollection(verts)
839839
col_list = PolyCollection(list(verts))
840-
assert len(col_arr._paths) == len(col_list._paths)
841-
for ap, lp in zip(col_arr._paths, col_list._paths):
840+
assert len(col_arr.get_paths()) == len(col_list.get_paths())
841+
for ap, lp in zip(col_arr.get_paths(), col_list.get_paths()):
842842
assert np.array_equal(ap._vertices, lp._vertices)
843843
assert np.array_equal(ap._codes, lp._codes)
844844

845845
verts_tuple = np.empty(10, dtype=object)
846846
verts_tuple[:] = [tuple(tuple(y) for y in x) for x in verts]
847847
col_arr_tuple = PolyCollection(verts_tuple)
848-
assert len(col_arr._paths) == len(col_arr_tuple._paths)
849-
for ap, atp in zip(col_arr._paths, col_arr_tuple._paths):
848+
assert len(col_arr.get_paths()) == len(col_arr_tuple.get_paths())
849+
for ap, atp in zip(col_arr.get_paths(), col_arr_tuple.get_paths()):
850850
assert np.array_equal(ap._vertices, atp._vertices)
851851
assert np.array_equal(ap._codes, atp._codes)
852852

lib/matplotlib/tests/test_image.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,9 @@ def test_setdata_xya(image_cls, x, y, a):
781781
im = image_cls(ax)
782782
im.set_data(x, y, a)
783783
x[0] = y[0] = a[0, 0] = 9.9
784-
assert im._A[0, 0] == im._Ax[0] == im._Ay[0] == 0, 'value changed'
784+
Ax = im._container.x
785+
Ay = im._container.y
786+
assert im._A[0, 0] == Ax[0] == Ay[0] == 0, 'value changed'
785787
im.set_data(x, y, a.reshape((*a.shape, -1))) # Just a smoketest.
786788

787789

@@ -1660,8 +1662,8 @@ def test_axesimage_get_shape():
16601662
# generate dummy image to test get_shape method
16611663
ax = plt.gca()
16621664
im = AxesImage(ax)
1663-
with pytest.raises(RuntimeError, match="You must first set the image array"):
1664-
im.get_shape()
1665+
# Initial behavior is an empty 2D array
1666+
assert im.get_shape() == (1, 0)
16651667
z = np.arange(12, dtype=float).reshape((4, 3))
16661668
im.set_data(z)
16671669
assert im.get_shape() == (4, 3)

0 commit comments

Comments
 (0)