{"instance_id": "matplotlib__matplotlib-24026", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/lib/matplotlib/stackplot.py b/lib/matplotlib/stackplot.py\nindex c580043eeb..1a3577e210 100644\n--- a/lib/matplotlib/stackplot.py\n+++ b/lib/matplotlib/stackplot.py\n@@ -6,6 +6,8 @@ https://stackoverflow.com/q/2225995/\n (https://stackoverflow.com/users/66549/doug)\n \"\"\"\n \n+import itertools\n+\n import numpy as np\n \n from matplotlib import _api\n@@ -70,7 +72,9 @@ def stackplot(axes, x, *args,\n \n     labels = iter(labels)\n     if colors is not None:\n-        axes.set_prop_cycle(color=colors)\n+        colors = itertools.cycle(colors)\n+    else:\n+        colors = (axes._get_lines.get_next_color() for _ in y)\n \n     # Assume data passed has not been 'stacked', so stack it here.\n     # We'll need a float buffer for the upcoming calculations.\n@@ -108,7 +112,7 @@ def stackplot(axes, x, *args,\n         stack += first_line\n \n     # Color between x = 0 and the first array.\n-    color = axes._get_lines.get_next_color()\n+    color = next(colors)\n     coll = axes.fill_between(x, first_line, stack[0, :],\n                              facecolor=color, label=next(labels, None),\n                              **kwargs)\n@@ -117,7 +121,7 @@ def stackplot(axes, x, *args,\n \n     # Color between array i-1 and array i\n     for i in range(len(y) - 1):\n-        color = axes._get_lines.get_next_color()\n+        color = next(colors)\n         r.append(axes.fill_between(x, stack[i, :], stack[i + 1, :],\n                                    facecolor=color, label=next(labels, None),\n                                    **kwargs))\n", "model": "claude-sonnet-5-5", "steps": 5, "finished": true, "patch_lines": 42, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 42, "steps": 5}], "ms": 15888}
{"instance_id": "matplotlib__matplotlib-24149", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py\nindex fdac0f3560..3a61e89e14 100644\n--- a/lib/matplotlib/axes/_axes.py\n+++ b/lib/matplotlib/axes/_axes.py\n@@ -2180,12 +2180,12 @@ class Axes(_AxesBase):\n             # wrap numpy arrays.\n             try:\n                 x0 = cbook._safe_first_finite(x0)\n-            except (TypeError, IndexError, KeyError):\n+            except (TypeError, IndexError, KeyError, StopIteration):\n                 pass\n \n             try:\n                 x = cbook._safe_first_finite(xconv)\n-            except (TypeError, IndexError, KeyError):\n+            except (TypeError, IndexError, KeyError, StopIteration):\n                 x = xconv\n \n             delist = False\n", "model": "claude-sonnet-5-5", "steps": 9, "finished": true, "patch_lines": 19, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 19, "steps": 9}], "ms": 20115}
{"instance_id": "matplotlib__matplotlib-24177", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py\nindex 4f805e0177..056ff7ea2c 100644\n--- a/lib/matplotlib/axes/_base.py\n+++ b/lib/matplotlib/axes/_base.py\n@@ -2434,7 +2434,7 @@ class _AxesBase(martist.Artist):\n         # Get all vertices on the path\n         # Loop through each segment to get extrema for Bezier curve sections\n         vertices = []\n-        for curve, code in p.iter_bezier():\n+        for curve, code in p.iter_bezier(simplify=False):\n             # Get distance along the curve of any extrema\n             _, dzeros = curve.axis_aligned_extrema()\n             # Calculate vertices of start, end and any extrema in between\n", "model": "claude-sonnet-5-5", "steps": 12, "finished": true, "patch_lines": 13, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 13, "steps": 12}], "ms": 29794}
{"instance_id": "matplotlib__matplotlib-24570", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/lib/matplotlib/offsetbox.py b/lib/matplotlib/offsetbox.py\nindex 3a506543ac..059a6c8ae3 100644\n--- a/lib/matplotlib/offsetbox.py\n+++ b/lib/matplotlib/offsetbox.py\n@@ -166,10 +166,10 @@ def _get_aligned_offsets(hd_list, height, align=\"baseline\"):\n         descent = max(d for h, d in hd_list)\n         height = height_descent + descent\n         offsets = [0. for h, d in hd_list]\n-    elif align in [\"left\", \"top\"]:\n+    elif align in [\"left\", \"bottom\"]:\n         descent = 0.\n         offsets = [d for h, d in hd_list]\n-    elif align in [\"right\", \"bottom\"]:\n+    elif align in [\"right\", \"top\"]:\n         descent = 0.\n         offsets = [height - h + d for h, d in hd_list]\n     elif align == \"center\":\n", "model": "claude-sonnet-5-5", "steps": 9, "finished": true, "patch_lines": 17, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 17, "steps": 9}], "ms": 23060}
{"instance_id": "matplotlib__matplotlib-24627", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py\nindex 90b0bf117e..5f48b629a9 100644\n--- a/lib/matplotlib/axes/_base.py\n+++ b/lib/matplotlib/axes/_base.py\n@@ -1308,7 +1308,9 @@ class _AxesBase(martist.Artist):\n         self._get_patches_for_fill = _process_plot_var_args(self, 'fill')\n \n         self._gridOn = mpl.rcParams['axes.grid']\n-        self._children = []\n+        old_children, self._children = self._children, []\n+        for chld in old_children:\n+            chld.axes = chld.figure = None\n         self._mouseover_set = _OrderedSet()\n         self.child_axes = []\n         self._current_image = None  # strictly for pyplot via _sci, _gci\ndiff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py\nindex 6c18ba1a64..1cb3d67837 100644\n--- a/lib/matplotlib/figure.py\n+++ b/lib/matplotlib/figure.py\n@@ -949,6 +949,9 @@ default: %(va)s\n             ax.clear()\n             self.delaxes(ax)  # Remove ax from self._axstack.\n \n+        for artist in (*self.artists, *self.lines, *self.patches, *self.texts,\n+                       *self.images, *self.legends):\n+            artist.axes = artist.figure = None\n         self.artists = []\n         self.lines = []\n         self.patches = []\n", "model": "claude-sonnet-5-5", "steps": 13, "finished": true, "patch_lines": 29, "candidates": [{"compile_ok": 0, "loc_hits": 2, "files": 2, "diff_lines": 29, "steps": 13}], "ms": 38358}
{"instance_id": "matplotlib__matplotlib-24637", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/lib/matplotlib/offsetbox.py b/lib/matplotlib/offsetbox.py\nindex efa34dd078..a9ac26affa 100644\n--- a/lib/matplotlib/offsetbox.py\n+++ b/lib/matplotlib/offsetbox.py\n@@ -1453,12 +1453,14 @@ or callable, default: value of *xycoords*\n         if not self.get_visible() or not self._check_xy(renderer):\n             return\n         self.update_positions(renderer)\n+        renderer.open_group(self.__class__.__name__, gid=self.get_gid())\n         if self.arrow_patch is not None:\n             if self.arrow_patch.figure is None and self.figure is not None:\n                 self.arrow_patch.figure = self.figure\n             self.arrow_patch.draw(renderer)\n         self.patch.draw(renderer)\n         self.offsetbox.draw(renderer)\n+        renderer.close_group(self.__class__.__name__)\n         self.stale = False\n \n \n", "model": "claude-sonnet-5-5", "steps": 8, "finished": true, "patch_lines": 19, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 19, "steps": 8}], "ms": 18742}
{"instance_id": "matplotlib__matplotlib-24870", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/lib/matplotlib/contour.py b/lib/matplotlib/contour.py\nindex 144eadeae2..17ea1c4a22 100644\n--- a/lib/matplotlib/contour.py\n+++ b/lib/matplotlib/contour.py\n@@ -1117,15 +1117,20 @@ class ContourSet(cm.ScalarMappable, ContourLabeler):\n \n         return lev[i0:i1]\n \n-    def _process_contour_level_args(self, args):\n+    def _process_contour_level_args(self, args, z_dtype):\n         \"\"\"\n         Determine the contour levels and store in self.levels.\n         \"\"\"\n         if self.levels is None:\n-            if len(args) == 0:\n-                levels_arg = 7  # Default, hard-wired.\n-            else:\n+            if args:\n                 levels_arg = args[0]\n+            elif np.issubdtype(z_dtype, bool):\n+                if self.filled:\n+                    levels_arg = [0, .5, 1]\n+                else:\n+                    levels_arg = [.5]\n+            else:\n+                levels_arg = 7  # Default, hard-wired.\n         else:\n             levels_arg = self.levels\n         if isinstance(levels_arg, Integral):\n@@ -1447,10 +1452,12 @@ class QuadContourSet(ContourSet):\n             fn = 'contour'\n         nargs = len(args)\n         if nargs <= 2:\n+            z_dtype = ma.asarray(args[0]).dtype\n             z = ma.asarray(args[0], dtype=np.float64)\n             x, y = self._initialize_x_y(z)\n             args = args[1:]\n         elif nargs <= 4:\n+            z_dtype = ma.asarray(args[2]).dtype\n             x, y, z = self._check_xyz(args[:3], kwargs)\n             args = args[3:]\n         else:\n@@ -1462,7 +1469,7 @@ class QuadContourSet(ContourSet):\n             z = ma.masked_where(z <= 0, z)\n             _api.warn_external('Log scale: values of z <= 0 have been masked')\n             self.zmin = float(z.min())\n-        self._process_contour_level_args(args)\n+        self._process_contour_level_args(args, z_dtype)\n         return (x, y, z)\n \n     def _check_xyz(self, args, kwargs):\ndiff --git a/lib/matplotlib/tri/_tricontour.py b/lib/matplotlib/tri/_tricontour.py\nindex c403ebae70..aa1e5a5ba2 100644\n--- a/lib/matplotlib/tri/_tricontour.py\n+++ b/lib/matplotlib/tri/_tricontour.py\n@@ -74,7 +74,7 @@ class TriContourSet(ContourSet):\n         if self.logscale and self.zmin <= 0:\n             func = 'contourf' if self.filled else 'contour'\n             raise ValueError(f'Cannot {func} log of negative values.')\n-        self._process_contour_level_args(args[1:])\n+        self._process_contour_level_args(args[1:], z.dtype)\n         return (tri, z)\n \n \n", "model": "claude-sonnet-5-5", "steps": 16, "finished": true, "patch_lines": 64, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 2, "diff_lines": 64, "steps": 16}], "ms": 44594}
{"instance_id": "matplotlib__matplotlib-24970", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py\nindex 2d3072da04..c52a386a3d 100644\n--- a/lib/matplotlib/colors.py\n+++ b/lib/matplotlib/colors.py\n@@ -725,6 +725,9 @@ class Colormap:\n                 # Avoid converting large positive values to negative integers.\n                 np.clip(xa, -1, self.N, out=xa)\n                 xa = xa.astype(int)\n+        # Avoid overflow of the special indices for small integer dtypes.\n+        if xa.dtype.kind in \"iu\" and np.iinfo(xa.dtype).max < self.N + 2:\n+            xa = xa.astype(int)\n         # Set the over-range indices before the under-range;\n         # otherwise the under-range values get converted to over-range.\n         xa[xa > self.N - 1] = self._i_over\n", "model": "claude-sonnet-5-5", "steps": 6, "finished": true, "patch_lines": 14, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 14, "steps": 6}], "ms": 11236}
{"instance_id": "matplotlib__matplotlib-25122", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/lib/matplotlib/mlab.py b/lib/matplotlib/mlab.py\nindex 3552904c3d..2eec639960 100644\n--- a/lib/matplotlib/mlab.py\n+++ b/lib/matplotlib/mlab.py\n@@ -424,10 +424,10 @@ def _spectral_helper(x, y=None, NFFT=None, Fs=None, detrend_func=None,\n             result /= Fs\n             # Scale the spectrum by the norm of the window to compensate for\n             # windowing loss; see Bendat & Piersol Sec 11.5.2.\n-            result /= (np.abs(window)**2).sum()\n+            result /= (window**2).sum()\n         else:\n             # In this case, preserve power in the segment, not amplitude\n-            result /= np.abs(window).sum()**2\n+            result /= window.sum()**2\n \n     t = np.arange(NFFT/2, len(x) - NFFT/2 + 1, NFFT - noverlap)/Fs\n \n", "model": "claude-sonnet-5-5", "steps": 8, "finished": true, "patch_lines": 17, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 17, "steps": 8}], "ms": 15195}
{"instance_id": "matplotlib__matplotlib-25287", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py\nindex c0e706e2b3..62dbe41614 100644\n--- a/lib/matplotlib/axis.py\n+++ b/lib/matplotlib/axis.py\n@@ -2255,7 +2255,9 @@ class XAxis(Axis):\n             transform=mtransforms.blended_transform_factory(\n                 self.axes.transAxes, mtransforms.IdentityTransform()),\n             fontsize=mpl.rcParams['xtick.labelsize'],\n-            color=mpl.rcParams['xtick.color'],\n+            color=mpl.rcParams['xtick.color']\n+            if mpl.rcParams['xtick.labelcolor'] == 'inherit'\n+            else mpl.rcParams['xtick.labelcolor'],\n         )\n         self.offset_text_position = 'bottom'\n \n@@ -2515,7 +2517,9 @@ class YAxis(Axis):\n             transform=mtransforms.blended_transform_factory(\n                 self.axes.transAxes, mtransforms.IdentityTransform()),\n             fontsize=mpl.rcParams['ytick.labelsize'],\n-            color=mpl.rcParams['ytick.color'],\n+            color=mpl.rcParams['ytick.color']\n+            if mpl.rcParams['ytick.labelcolor'] == 'inherit'\n+            else mpl.rcParams['ytick.labelcolor'],\n         )\n         self.offset_text_position = 'left'\n \n", "model": "claude-sonnet-5-5", "steps": 6, "finished": true, "patch_lines": 26, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 26, "steps": 6}], "ms": 15394}
