{"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..8832834ed5 100644\n--- a/lib/matplotlib/axes/_base.py\n+++ b/lib/matplotlib/axes/_base.py\n@@ -1308,6 +1308,10 @@ 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+        for chld in self._children:\n+            chld.axes = chld.figure = None\n+        for chld in getattr(self, 'child_axes', []):\n+            chld.axes = chld.figure = None\n         self._children = []\n         self._mouseover_set = _OrderedSet()\n         self.child_axes = []\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}, {"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 13, "steps": 13}], "ms": 70513}
{"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..c4cc5d21af 100644\n--- a/lib/matplotlib/contour.py\n+++ b/lib/matplotlib/contour.py\n@@ -1117,13 +1117,16 @@ 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+                if np.issubdtype(z_dtype, np.bool_):\n+                    levels_arg = [0, .5, 1] if self.filled else [.5]\n+                else:\n+                    levels_arg = 7  # Default, hard-wired.\n             else:\n                 levels_arg = args[0]\n         else:\n@@ -1446,11 +1449,14 @@ class QuadContourSet(ContourSet):\n         else:\n             fn = 'contour'\n         nargs = len(args)\n+        z_dtype = None\n         if nargs <= 2:\n+            z_dtype = np.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 = np.asarray(args[2]).dtype\n             x, y, z = self._check_xyz(args[:3], kwargs)\n             args = args[3:]\n         else:\n@@ -1462,7 +1468,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": 11, "finished": true, "patch_lines": 60, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 2, "diff_lines": 60, "steps": 11}], "ms": 32710}
{"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..951b6845c6 100644\n--- a/lib/matplotlib/colors.py\n+++ b/lib/matplotlib/colors.py\n@@ -725,6 +725,10 @@ 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+        elif xa.dtype.kind in \"biu\" and xa.dtype.itemsize < np.dtype(int).itemsize:\n+            # Small integer dtypes may not be able to hold the special\n+            # indices N, N+1, 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": 15, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 15, "steps": 6}], "ms": 19077}
{"instance_id": "matplotlib__matplotlib-25311", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/lib/matplotlib/offsetbox.py b/lib/matplotlib/offsetbox.py\nindex 1dee8a23d9..3423145788 100644\n--- a/lib/matplotlib/offsetbox.py\n+++ b/lib/matplotlib/offsetbox.py\n@@ -1505,7 +1505,6 @@ class DraggableBase:\n         if not ref_artist.pickable():\n             ref_artist.set_picker(True)\n         self.got_artist = False\n-        self.canvas = self.ref_artist.figure.canvas\n         self._use_blit = use_blit and self.canvas.supports_blit\n         self.cids = [\n             self.canvas.callbacks._connect_picklable(\n@@ -1514,6 +1513,10 @@ class DraggableBase:\n                 'button_release_event', self.on_release),\n         ]\n \n+    # Not stored as an attribute so that the (unpicklable) canvas is not\n+    # pickled along with the draggable helper.\n+    canvas = property(lambda self: self.ref_artist.figure.canvas)\n+\n     def on_motion(self, evt):\n         if self._check_still_parented() and self.got_artist:\n             dx = evt.x - self.mouse_x\n", "model": "claude-sonnet-5-5", "steps": 11, "finished": true, "patch_lines": 23, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 23, "steps": 11}], "ms": 32284}
{"instance_id": "matplotlib__matplotlib-25332", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/lib/matplotlib/cbook.py b/lib/matplotlib/cbook.py\nindex c9699b2e21..4767f94332 100644\n--- a/lib/matplotlib/cbook.py\n+++ b/lib/matplotlib/cbook.py\n@@ -788,6 +788,15 @@ class Grouper:\n     def __init__(self, init=()):\n         self._mapping = {weakref.ref(x): [weakref.ref(x)] for x in init}\n \n+    def __getstate__(self):\n+        # Weak references can't be pickled; store the groups of live objects.\n+        return {\"groups\": list(self)}\n+\n+    def __setstate__(self, state):\n+        self._mapping = {}\n+        for group in state[\"groups\"]:\n+            self.join(*group)\n+\n     def __contains__(self, item):\n         return weakref.ref(item) in self._mapping\n \n", "model": "claude-sonnet-5-5", "steps": 10, "finished": true, "patch_lines": 20, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 20, "steps": 10}], "ms": 25070}
{"instance_id": "matplotlib__matplotlib-25775", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/lib/matplotlib/_mathtext.py b/lib/matplotlib/_mathtext.py\nindex 09f5c61879..e649fd1fe7 100644\n--- a/lib/matplotlib/_mathtext.py\n+++ b/lib/matplotlib/_mathtext.py\n@@ -99,7 +99,9 @@ class Output:\n               for x1, y1, x2, y2 in self.rects]\n         return VectorParse(w, h + d, d, gs, rs)\n \n-    def to_raster(self):\n+    def to_raster(self, *, antialiased=None):\n+        if antialiased is None:\n+            antialiased = mpl.rcParams['text.antialiased']\n         # Metrics y's and mathtext y's are oriented in opposite directions,\n         # hence the switch between ymin and ymax.\n         xmin = min([*[ox + info.metrics.xmin for ox, oy, info in self.glyphs],\n@@ -124,7 +126,7 @@ class Output:\n         for ox, oy, info in shifted.glyphs:\n             info.font.draw_glyph_to_bitmap(\n                 image, ox, oy - info.metrics.iceberg, info.glyph,\n-                antialiased=mpl.rcParams['text.antialiased'])\n+                antialiased=antialiased)\n         for x1, y1, x2, y2 in shifted.rects:\n             height = max(int(y2 - y1) - 1, 0)\n             if height == 0:\ndiff --git a/lib/matplotlib/backends/backend_agg.py b/lib/matplotlib/backends/backend_agg.py\nindex 7d038a998f..f8750e173c 100644\n--- a/lib/matplotlib/backends/backend_agg.py\n+++ b/lib/matplotlib/backends/backend_agg.py\n@@ -189,7 +189,7 @@ class RendererAgg(RendererBase):\n     def draw_mathtext(self, gc, x, y, s, prop, angle):\n         \"\"\"Draw mathtext using :mod:`matplotlib.mathtext`.\"\"\"\n         ox, oy, width, height, descent, font_image = \\\n-            self.mathtext_parser.parse(s, self.dpi, prop)\n+            self.mathtext_parser.parse(s, self.dpi, prop, gc.get_antialiased())\n \n         xd = descent * sin(radians(angle))\n         yd = descent * cos(radians(angle))\n@@ -206,7 +206,7 @@ class RendererAgg(RendererBase):\n         # space) in the following call to draw_text_image).\n         font.set_text(s, 0, flags=get_hinting_flag())\n         font.draw_glyphs_to_bitmap(\n-            antialiased=mpl.rcParams['text.antialiased'])\n+            antialiased=gc.get_antialiased())\n         d = font.get_descent() / 64.0\n         # The descent needs to be adjusted for the angle.\n         xo, yo = font.get_bitmap_offset()\ndiff --git a/lib/matplotlib/backends/backend_cairo.py b/lib/matplotlib/backends/backend_cairo.py\nindex 9ccadcdf1c..196e414788 100644\n--- a/lib/matplotlib/backends/backend_cairo.py\n+++ b/lib/matplotlib/backends/backend_cairo.py\n@@ -25,7 +25,6 @@ except ImportError:\n             \"cairo backend requires that pycairo>=1.14.0 or cairocffi \"\n             \"is installed\") from err\n \n-import matplotlib as mpl\n from .. import _api, cbook, font_manager\n from matplotlib.backend_bases import (\n     _Backend, FigureCanvasBase, FigureManagerBase, GraphicsContextBase,\n@@ -205,7 +204,7 @@ class RendererCairo(RendererBase):\n             ctx.set_font_size(self.points_to_pixels(prop.get_size_in_points()))\n             opts = cairo.FontOptions()\n             opts.set_antialias(\n-                cairo.ANTIALIAS_DEFAULT if mpl.rcParams[\"text.antialiased\"]\n+                cairo.ANTIALIAS_DEFAULT if gc.get_antialiased()\n                 else cairo.ANTIALIAS_NONE)\n             ctx.set_font_options(opts)\n             if angle:\ndiff --git a/lib/matplotlib/mathtext.py b/lib/matplotlib/mathtext.py\nindex e538d451f8..aeb55bd796 100644\n--- a/lib/matplotlib/mathtext.py\n+++ b/lib/matplotlib/mathtext.py\n@@ -18,6 +18,7 @@ metrics for those fonts.\n import functools\n import logging\n \n+import matplotlib as mpl\n from matplotlib import _api, _mathtext\n from matplotlib.ft2font import LOAD_NO_HINTING\n from matplotlib.font_manager import FontProperties\n@@ -58,7 +59,7 @@ class MathTextParser:\n             {\"path\": \"vector\", \"agg\": \"raster\", \"macosx\": \"raster\"},\n             output=output.lower())\n \n-    def parse(self, s, dpi=72, prop=None):\n+    def parse(self, s, dpi=72, prop=None, antialiased=None):\n         \"\"\"\n         Parse the given math expression *s* at the given *dpi*.  If *prop* is\n         provided, it is a `.FontProperties` object specifying the \"default\"\n@@ -69,15 +70,20 @@ class MathTextParser:\n \n         Depending on the *output* type, this returns either a `VectorParse` or\n         a `RasterParse`.\n+\n+        *antialiased* (only used for raster output) defaults to\n+        :rc:`text.antialiased`.\n         \"\"\"\n         # lru_cache can't decorate parse() directly because prop\n         # is mutable; key the cache using an internal copy (see\n         # text._get_text_metrics_with_cache for a similar case).\n         prop = prop.copy() if prop is not None else None\n-        return self._parse_cached(s, dpi, prop)\n+        if antialiased is None:\n+            antialiased = mpl.rcParams['text.antialiased']\n+        return self._parse_cached(s, dpi, prop, bool(antialiased))\n \n     @functools.lru_cache(50)\n-    def _parse_cached(self, s, dpi, prop):\n+    def _parse_cached(self, s, dpi, prop, antialiased):\n         from matplotlib.backends import backend_agg\n \n         if prop is None:\n@@ -100,7 +106,7 @@ class MathTextParser:\n         if self._output_type == \"vector\":\n             return output.to_vector()\n         elif self._output_type == \"raster\":\n-            return output.to_raster()\n+            return output.to_raster(antialiased=antialiased)\n \n \n def math_to_image(s, filename_or_obj, prop=None, dpi=None, format=None,\ndiff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py\nindex 4591316cf9..571acb99b0 100644\n--- a/lib/matplotlib/text.py\n+++ b/lib/matplotlib/text.py\n@@ -187,6 +187,7 @@ class Text(Artist):\n             linespacing = 1.2  # Maybe use rcParam later.\n         self.set_linespacing(linespacing)\n         self.set_rotation_mode(rotation_mode)\n+        self.set_antialiased(mpl.rcParams['text.antialiased'])\n \n     def update(self, kwargs):\n         # docstring inherited\n@@ -322,6 +323,7 @@ class Text(Artist):\n         self._transform_rotates_text = other._transform_rotates_text\n         self._picker = other._picker\n         self._linespacing = other._linespacing\n+        self._antialiased = other._antialiased\n         self.stale = True\n \n     def _get_layout(self, renderer):\n@@ -737,6 +739,7 @@ class Text(Artist):\n             gc.set_foreground(self.get_color())\n             gc.set_alpha(self.get_alpha())\n             gc.set_url(self._url)\n+            gc.set_antialiased(self._antialiased)\n             self._set_gc_clip(gc)\n \n             angle = self.get_rotation()\n@@ -1301,6 +1304,21 @@ class Text(Artist):\n         \"\"\"Return whether this `Text` object uses TeX for rendering.\"\"\"\n         return self._usetex\n \n+    def set_antialiased(self, antialiased):\n+        \"\"\"\n+        Set whether to use antialiased rendering.\n+\n+        Parameters\n+        ----------\n+        antialiased : bool\n+        \"\"\"\n+        self._antialiased = bool(antialiased)\n+        self.stale = True\n+\n+    def get_antialiased(self):\n+        \"\"\"Return whether antialiased rendering is used.\"\"\"\n+        return self._antialiased\n+\n     def set_parse_math(self, parse_math):\n         \"\"\"\n         Override switch to disable any mathtext parsing for this `Text`.\n", "model": "claude-sonnet-5-5", "steps": 18, "finished": false, "patch_lines": 170, "candidates": [{"compile_ok": 0, "loc_hits": 2, "files": 5, "diff_lines": 170, "steps": 18}], "ms": 61023}
{"instance_id": "matplotlib__matplotlib-25960", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py\nindex dab2bc4a5a..303d63c5d3 100644\n--- a/lib/matplotlib/figure.py\n+++ b/lib/matplotlib/figure.py\n@@ -1582,6 +1582,7 @@ default: %(va)s\n             If not given, all rows will have the same height.\n         \"\"\"\n         gs = GridSpec(nrows=nrows, ncols=ncols, figure=self,\n+                      left=0, right=1, bottom=0, top=1,\n                       wspace=wspace, hspace=hspace,\n                       width_ratios=width_ratios,\n                       height_ratios=height_ratios)\n@@ -2274,12 +2275,14 @@ class SubFigure(FigureBase):\n             return\n         # need to figure out *where* this subplotspec is.\n         gs = self._subplotspec.get_gridspec()\n-        wr = np.asarray(gs.get_width_ratios())\n-        hr = np.asarray(gs.get_height_ratios())\n-        dx = wr[self._subplotspec.colspan].sum() / wr.sum()\n-        dy = hr[self._subplotspec.rowspan].sum() / hr.sum()\n-        x0 = wr[:self._subplotspec.colspan.start].sum() / wr.sum()\n-        y0 = 1 - hr[:self._subplotspec.rowspan.stop].sum() / hr.sum()\n+        fig_bottoms, fig_tops, fig_lefts, fig_rights = \\\n+            gs.get_grid_positions(self.figure)\n+        rowspan = self._subplotspec.rowspan\n+        colspan = self._subplotspec.colspan\n+        x0 = fig_lefts[colspan.start]\n+        dx = fig_rights[colspan.stop - 1] - x0\n+        y0 = fig_bottoms[rowspan.stop - 1]\n+        dy = fig_tops[rowspan.start] - y0\n         if self.bbox_relative is None:\n             self.bbox_relative = Bbox.from_bounds(x0, y0, dx, dy)\n         else:\n", "model": "claude-sonnet-5-5", "steps": 14, "finished": true, "patch_lines": 33, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 33, "steps": 14}], "ms": 47485}
{"instance_id": "matplotlib__matplotlib-26291", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/lib/mpl_toolkits/axes_grid1/inset_locator.py b/lib/mpl_toolkits/axes_grid1/inset_locator.py\nindex 9d35051074..46284c6802 100644\n--- a/lib/mpl_toolkits/axes_grid1/inset_locator.py\n+++ b/lib/mpl_toolkits/axes_grid1/inset_locator.py\n@@ -69,6 +69,8 @@ class AnchoredLocatorBase(AnchoredOffsetbox):\n         raise RuntimeError(\"No draw method should be called\")\n \n     def __call__(self, ax, renderer):\n+        if renderer is None:\n+            renderer = ax.figure._get_renderer()\n         self.axes = ax\n         bbox = self.get_window_extent(renderer)\n         px, py = self.get_offset(bbox.width, bbox.height, 0, 0, renderer)\n", "model": "claude-sonnet-5-5", "steps": 5, "finished": true, "patch_lines": 13, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 13, "steps": 5}], "ms": 16175}
{"instance_id": "matplotlib__matplotlib-26342", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/lib/matplotlib/contour.py b/lib/matplotlib/contour.py\nindex 3f84250b64..6e8df0e1fa 100644\n--- a/lib/matplotlib/contour.py\n+++ b/lib/matplotlib/contour.py\n@@ -1092,6 +1092,17 @@ class ContourSet(ContourLabeler, mcoll.Collection):\n \n         return kwargs\n \n+    def set_paths(self, paths):\n+        \"\"\"\n+        Set the paths of the contour set.\n+\n+        Parameters\n+        ----------\n+        paths : list of `.Path`\n+        \"\"\"\n+        self._paths = paths\n+        self.stale = True\n+\n     def _make_paths_from_contour_generator(self):\n         \"\"\"Compute ``paths`` using C extension.\"\"\"\n         if self._paths is not None:\n", "model": "claude-sonnet-5-5", "steps": 8, "finished": true, "patch_lines": 22, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 22, "steps": 8}], "ms": 18641}
{"instance_id": "sphinx-doc__sphinx-10435", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py\nindex e0c7d56f8..85899c10d 100644\n--- a/sphinx/writers/latex.py\n+++ b/sphinx/writers/latex.py\n@@ -1710,11 +1710,11 @@ class LaTeXTranslator(SphinxTranslator):\n         # TODO: Use nowrap option once LaTeX formatter supports it\n         # https://github.com/pygments/pygments/pull/1343\n         hlcode = hlcode.replace(r'\\begin{Verbatim}[commandchars=\\\\\\{\\}]',\n-                                r'\\sphinxcode{\\sphinxupquote{')\n+                                r'\\sphinxcode{\\sphinxupquote{%')\n         # get consistent trailer\n         hlcode = hlcode.rstrip()[:-14]  # strip \\end{Verbatim}\n-        self.body.append(hlcode)\n-        self.body.append('}}')\n+        self.body.append(hlcode.rstrip('\\n'))\n+        self.body.append('%' + CR + '}}')\n         raise nodes.SkipNode\n \n     def depart_literal(self, node: Element) -> None:\ndiff --git a/tests/test_build_latex.py b/tests/test_build_latex.py\nindex dd0db8aef..709dce05d 100644\n--- a/tests/test_build_latex.py\n+++ b/tests/test_build_latex.py\n@@ -1623,7 +1623,7 @@ def test_latex_code_role(app):\n         r'\\PYG{p}{)}'\n         r'\\PYG{p}{:} '\n         r'\\PYG{k}{pass}')\n-    assert (r'Inline \\sphinxcode{\\sphinxupquote{' + '\\n' +\n-            common_content + '\\n}} code block') in content\n+    assert (r'Inline \\sphinxcode{\\sphinxupquote{%' + '\\n' +\n+            common_content + '%\\n}} code block') in content\n     assert (r'\\begin{sphinxVerbatim}[commandchars=\\\\\\{\\}]' +\n             '\\n' + common_content + '\\n' + r'\\end{sphinxVerbatim}') in content\n", "model": "claude-sonnet-5-5", "steps": 7, "finished": true, "patch_lines": 33, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 2, "diff_lines": 33, "steps": 7}, {"compile_ok": 0, "loc_hits": 1, "files": 2, "diff_lines": 33, "steps": 6}], "ms": 36936}
