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

Skip to content

Commit 848ed7a

Browse files
committed
fix error to raise, improved testing
1 parent 7c9bd99 commit 848ed7a

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

lib/matplotlib/table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def __setitem__(self, position, cell):
301301
Set a customcell in a given position
302302
"""
303303
if not isinstance(cell, CustomCell):
304-
raise ValueError('Table only accepts CustomCell')
304+
raise TypeError('Table only accepts CustomCell')
305305
try:
306306
row, col = position[0], position[1]
307307
except Exception:

lib/matplotlib/tests/test_table.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,13 @@ def test_auto_column():
184184

185185

186186
def test_table_cells():
187-
fig = plt.figure()
188-
ax = fig.add_subplot(1, 1, 1)
187+
fig, ax = plt.subplots()
189188
table = Table(ax)
190189

191190
cell = table.add_cell(1, 2, 1, 1)
192191
assert isinstance(cell, CustomCell)
193-
table[2, 1] = cell
194-
assert table[2, 1] is cell
192+
assert cell is table[1, 2]
193+
194+
cell2 = CustomCell((0, 0), 1, 2, visible_edges=None)
195+
table[2, 1] = cell2
196+
assert table[2, 1] is cell2

0 commit comments

Comments
 (0)