Skip to content

Commit e6e8fae

Browse files
committed
Raise TypeError on unsupported kwargs of spy()
1 parent 391c0cb commit e6e8fae

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
`matplotlib.axes.Axes.spy` raises `TypeError` for unsupported kwargs
2+
---------------------------------------------------------------------
3+
4+
The method `matplotlib.axes.Axes.spy` now raises a `TypeError` for the keyword
5+
arguments 'interpolation', 'extent' and 'linestyle' instead of silently
6+
ignoring them.

lib/matplotlib/axes/_axes.py

+7
Original file line numberDiff line numberDiff line change
@@ -7360,6 +7360,10 @@ def spy(self, Z, precision=0, marker=None, markersize=None,
73607360
name='binary')
73617361
nr, nc = Z.shape
73627362
extent = [-0.5, nc - 0.5, nr - 0.5, -0.5]
7363+
for kw in ['interpolation', 'extent']:
7364+
if kw in kwargs:
7365+
raise TypeError(
7366+
"spy() got an unexpected keyword argument '%s'" % kw)
73637367
ret = self.imshow(mask, interpolation='nearest', aspect=aspect,
73647368
extent=extent, origin=origin, **kwargs)
73657369
else:
@@ -7380,6 +7384,9 @@ def spy(self, Z, precision=0, marker=None, markersize=None,
73807384
marker = 's'
73817385
if markersize is None:
73827386
markersize = 10
7387+
if 'linestyle' in kwargs:
7388+
raise TypeError(
7389+
"spy() got an unexpected keyword argument 'linestyle'")
73837390
marks = mlines.Line2D(x, y, linestyle='None',
73847391
marker=marker, markersize=markersize, **kwargs)
73857392
self.add_line(marks)

0 commit comments

Comments
 (0)