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

Skip to content

Commit a6d689c

Browse files
anntzertimhoffm
authored andcommitted
Simplify argument checking in Table.__getitem__. (#12932)
This just lets the exception, if any, propagate out of `dict.__getitem__`; this avoids e.g. `Table[a, b, c]` silently "working" by silently dropping the third argument.
1 parent 137effc commit a6d689c

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

lib/matplotlib/table.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -349,14 +349,8 @@ def __setitem__(self, position, cell):
349349
self.stale = True
350350

351351
def __getitem__(self, position):
352-
"""
353-
Retrieve a custom cell from a given position.
354-
"""
355-
try:
356-
row, col = position[0], position[1]
357-
except Exception:
358-
raise KeyError('Only tuples length 2 are accepted as coordinates')
359-
return self._cells[row, col]
352+
"""Retrieve a custom cell from a given position."""
353+
return self._cells[position]
360354

361355
@property
362356
def edges(self):

0 commit comments

Comments
 (0)