# Buggy code
def _contour_args(self, args, kwargs):
    if self.filled:
        fn = "contourf"
    else:
        fn = "contour"
    Nargs = len(args)
    if Nargs <= 2:
        z = ma.asarray(args[0], dtype=np.float64)
        x, y = self._initialize_x_y(z)
        args = args[1:]
    elif Nargs <= 4:
        x, y, z = self._check_xyz(args[:3], kwargs)
        args = args[3:]
    else:
        raise TypeError("Too many arguments to %s; see help(%s)" % (fn, fn))
    z = ma.masked_invalid(z, copy=False)
    self.zmax = ma.maximum(z)
    self.zmin = ma.minimum(z)
    if self.logscale and self.zmin <= 0:
        z = ma.masked_where(z <= 0, z)
        warnings.warn("Log scale: values of z <= 0 have been masked")
        self.zmin = z.min()
    self._contour_level_args(z, args)
    return (x, y, z)


# Traceback (TypeError)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-13-37a1d06c84a1> in <module>()
30 # the label
31 plt.figure()
---> 32 CS = plt.contour(X, Y, Z,locator=matplotlib.ticker.LinearLocator(10))
33 plt.clabel(CS, inline=1, fontsize=10)
34 plt.title('Simplest default with labels')

/home/w2naf/code/matplotlib/lib/matplotlib/pyplot.pyc in contour(*args, **kwargs)
2764         ax.hold(hold)
2765     try:
-> 2766         ret = ax.contour(*args, **kwargs)
2767     finally:
2768         ax.hold(washold)

/home/w2naf/code/matplotlib/lib/matplotlib/__init__.pyc in inner(ax, *args, **kwargs)
1810                     warnings.warn(msg % (label_namer, func.__name__),
1811                                   RuntimeWarning, stacklevel=2)
-> 1812             return func(ax, *args, **kwargs)
1813         pre_doc = inner.__doc__
1814         if pre_doc is None:

/home/w2naf/code/matplotlib/lib/matplotlib/axes/_axes.pyc in contour(self, *args, **kwargs)
5642             self.cla()
5643         kwargs['filled'] = False
-> 5644         return mcontour.QuadContourSet(self, *args, **kwargs)
5645     contour.__doc__ = mcontour.QuadContourSet.contour_doc
5646

/home/w2naf/code/matplotlib/lib/matplotlib/contour.pyc in __init__(self, ax, *args, **kwargs)
1422         are described in QuadContourSet.contour_doc.
1423         """
-> 1424         ContourSet.__init__(self, ax, *args, **kwargs)
1425
1426     def _process_args(self, *args, **kwargs):

/home/w2naf/code/matplotlib/lib/matplotlib/contour.pyc in __init__(self, ax, *args, **kwargs)
861         self._transform = kwargs.get('transform', None)
862
--> 863         self._process_args(*args, **kwargs)
864         self._process_levels()
865

/home/w2naf/code/matplotlib/lib/matplotlib/contour.pyc in _process_args(self, *args, **kwargs)
1443                 self._corner_mask = mpl.rcParams['contour.corner_mask']
1444
-> 1445             x, y, z = self._contour_args(args, kwargs)
1446
1447             _mask = ma.getmask(z)

/home/w2naf/code/matplotlib/lib/matplotlib/contour.pyc in _contour_args(self, args, kwargs)
1538             warnings.warn('Log scale: values of z <= 0 have been masked')
1539             self.zmin = z.min()
-> 1540         self._contour_level_args(z, args)
1541         return (x, y, z)
1542

/home/w2naf/code/matplotlib/lib/matplotlib/contour.pyc in _contour_level_args(self, z, args)
1167         if self.levels is None:
1168             if len(args) == 0:
-> 1169                 lev = self._autolev(z, 7)
1170             else:
1171                 level_arg = args[0]

/home/w2naf/code/matplotlib/lib/matplotlib/contour.pyc in _autolev(self, z, N)
1149         zmax = self.zmax
1150         zmin = self.zmin
-> 1151         lev = self.locator.tick_values(zmin, zmax)
1152         self._auto = True
1153         if self.filled:

/home/w2naf/code/matplotlib/lib/matplotlib/ticker.pyc in tick_values(self, vmin, vmax)
1173             vmin, vmax = vmax, vmin
1174
-> 1175         if (vmin, vmax) in self.presets:
1176             return self.presets[(vmin, vmax)]
1177

TypeError: unhashable type: 'MaskedArray'

# Fixed code
def _contour_args(self, args, kwargs):
    if self.filled:
        fn = "contourf"
    else:
        fn = "contour"
    Nargs = len(args)
    if Nargs <= 2:
        z = ma.asarray(args[0], dtype=np.float64)
        x, y = self._initialize_x_y(z)
        args = args[1:]
    elif Nargs <= 4:
        x, y, z = self._check_xyz(args[:3], kwargs)
        args = args[3:]
    else:
        raise TypeError("Too many arguments to %s; see help(%s)" % (fn, fn))
    z = ma.masked_invalid(z, copy=False)
    self.zmax = float(z.max())
    self.zmin = float(z.min())
    if self.logscale and self.zmin <= 0:
        z = ma.masked_where(z <= 0, z)
        warnings.warn("Log scale: values of z <= 0 have been masked")
        self.zmin = float(z.min())
    self._contour_level_args(z, args)
    return (x, y, z)