{"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..1b71959e15 100644\n--- a/lib/matplotlib/offsetbox.py\n+++ b/lib/matplotlib/offsetbox.py\n@@ -1500,12 +1500,14 @@ class DraggableBase:\n     coordinate and set a relevant attribute.\n     \"\"\"\n \n+    # A property, not an attribute, to maintain picklability.\n+    canvas = property(lambda self: self.ref_artist.figure.canvas)\n+\n     def __init__(self, ref_artist, use_blit=False):\n         self.ref_artist = ref_artist\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", "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": 30417}
{"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..6ed415670b 100644\n--- a/lib/matplotlib/cbook.py\n+++ b/lib/matplotlib/cbook.py\n@@ -788,6 +788,29 @@ 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+        # Convert weak refs to strong ones, preserving shared groups.\n+        groups = {}\n+        mapping = {}\n+        for k, vs in self._mapping.items():\n+            if k() is None:\n+                continue\n+            if id(vs) not in groups:\n+                groups[id(vs)] = [v() for v in vs if v() is not None]\n+            mapping[k()] = groups[id(vs)]\n+        return {**vars(self), \"_mapping\": mapping}\n+\n+    def __setstate__(self, state):\n+        vars(self).update(state)\n+        # Convert strong refs to weak ones, preserving shared groups.\n+        groups = {}\n+        mapping = {}\n+        for k, vs in self._mapping.items():\n+            if id(vs) not in groups:\n+                groups[id(vs)] = [weakref.ref(v) for v in vs]\n+            mapping[weakref.ref(k)] = groups[id(vs)]\n+        self._mapping = mapping\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": 34, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 34, "steps": 10}], "ms": 30543}
{"instance_id": "matplotlib__matplotlib-25479", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/lib/matplotlib/cm.py b/lib/matplotlib/cm.py\nindex 38158db956..01c25470f7 100644\n--- a/lib/matplotlib/cm.py\n+++ b/lib/matplotlib/cm.py\n@@ -146,6 +146,10 @@ class ColormapRegistry(Mapping):\n                                \"that was already in the registry.\")\n \n         self._cmaps[name] = cmap.copy()\n+        # The registered copy must carry the registered name, so that lookups\n+        # by ``cmap.name`` (e.g. in pyplot.set_cmap) keep working.\n+        if self._cmaps[name].name != name:\n+            self._cmaps[name].name = name\n \n     def unregister(self, name):\n         \"\"\"\n", "model": "claude-sonnet-5-5", "steps": 7, "finished": true, "patch_lines": 15, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 15, "steps": 7}], "ms": 17647}
{"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..0ca6b71c45 100644\n--- a/lib/matplotlib/_mathtext.py\n+++ b/lib/matplotlib/_mathtext.py\n@@ -99,7 +99,7 @@ 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):\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 +124,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..a019d3b38e 100644\n--- a/lib/matplotlib/backends/backend_agg.py\n+++ b/lib/matplotlib/backends/backend_agg.py\n@@ -189,7 +189,8 @@ 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(\n+                s, self.dpi, prop, antialiased=gc.get_antialiased())\n \n         xd = descent * sin(radians(angle))\n         yd = descent * cos(radians(angle))\n@@ -206,7 +207,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..89bfdb0ef1 100644\n--- a/lib/matplotlib/backends/backend_cairo.py\n+++ b/lib/matplotlib/backends/backend_cairo.py\n@@ -205,7 +205,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:\n@@ -312,6 +312,9 @@ class GraphicsContextCairo(GraphicsContextBase):\n         self.ctx.set_antialias(\n             cairo.ANTIALIAS_DEFAULT if b else cairo.ANTIALIAS_NONE)\n \n+    def get_antialiased(self):\n+        return self.ctx.get_antialias()\n+\n     def set_capstyle(self, cs):\n         self.ctx.set_line_cap(_api.check_getitem(self._capd, capstyle=cs))\n         self._capstyle = cs\ndiff --git a/lib/matplotlib/mathtext.py b/lib/matplotlib/mathtext.py\nindex e538d451f8..982962799a 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..7d92fec65a 100644\n--- a/lib/matplotlib/text.py\n+++ b/lib/matplotlib/text.py\n@@ -115,6 +115,7 @@ class Text(Artist):\n                  wrap=False,\n                  transform_rotates_text=False,\n                  parse_math=None,    # defaults to rcParams['text.parse_math']\n+                 antialiased=None,   # defaults to rcParams['text.antialiased']\n                  **kwargs\n                  ):\n         \"\"\"\n@@ -141,6 +142,7 @@ class Text(Artist):\n             fontproperties=fontproperties,\n             usetex=usetex,\n             parse_math=parse_math,\n+            antialiased=antialiased,\n             wrap=wrap,\n             verticalalignment=verticalalignment,\n             horizontalalignment=horizontalalignment,\n@@ -159,6 +161,7 @@ class Text(Artist):\n         fontproperties=None,\n         usetex=None,\n         parse_math=None,\n+        antialiased=None,\n         wrap=False,\n         verticalalignment='baseline',\n         horizontalalignment='left',\n@@ -175,6 +178,8 @@ class Text(Artist):\n         self.set_usetex(usetex)\n         self.set_parse_math(parse_math if parse_math is not None else\n                             mpl.rcParams['text.parse_math'])\n+        self.set_antialiased(antialiased if antialiased is not None\n+                             else mpl.rcParams['text.antialiased'])\n         self.set_wrap(wrap)\n         self.set_verticalalignment(verticalalignment)\n         self.set_horizontalalignment(horizontalalignment)\n@@ -318,6 +323,7 @@ class Text(Artist):\n         self._horizontalalignment = other._horizontalalignment\n         self._fontproperties = other._fontproperties.copy()\n         self._usetex = other._usetex\n+        self._antialiased = other._antialiased\n         self._rotation = other._rotation\n         self._transform_rotates_text = other._transform_rotates_text\n         self._picker = other._picker\n@@ -737,6 +743,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@@ -1297,6 +1304,21 @@ class Text(Artist):\n             self._usetex = bool(usetex)\n         self.stale = True\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 = 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 get_usetex(self):\n         \"\"\"Return whether this `Text` object uses TeX for rendering.\"\"\"\n         return self._usetex\n", "model": "claude-sonnet-5-5", "steps": 16, "finished": true, "patch_lines": 196, "candidates": [{"compile_ok": 0, "loc_hits": 2, "files": 5, "diff_lines": 196, "steps": 16}], "ms": 74931}
{"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..ee2a866aa1 100644\n--- a/lib/matplotlib/figure.py\n+++ b/lib/matplotlib/figure.py\n@@ -2276,10 +2276,24 @@ class SubFigure(FigureBase):\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+        nrows, ncols = gs.get_geometry()\n+        wspace = getattr(gs, 'wspace', None) or 0\n+        hspace = getattr(gs, 'hspace', None) or 0\n+        colspan = self._subplotspec.colspan\n+        rowspan = self._subplotspec.rowspan\n+\n+        cell_w = 1 / (ncols + wspace * (ncols - 1))\n+        sep_w = wspace * cell_w\n+        wnorm = cell_w * ncols / wr.sum()\n+        cell_h = 1 / (nrows + hspace * (nrows - 1))\n+        sep_h = hspace * cell_h\n+        hnorm = cell_h * nrows / hr.sum()\n+\n+        dx = wr[colspan].sum() * wnorm + sep_w * (len(wr[colspan]) - 1)\n+        dy = hr[rowspan].sum() * hnorm + sep_h * (len(hr[rowspan]) - 1)\n+        x0 = wr[:colspan.start].sum() * wnorm + sep_w * colspan.start\n+        y0 = 1 - (hr[:rowspan.stop].sum() * hnorm\n+                  + sep_h * (rowspan.stop - 1))\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": 16, "finished": false, "patch_lines": 33, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 33, "steps": 16}], "ms": 64367}
{"instance_id": "matplotlib__matplotlib-26113", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py\nindex 5369eadbde..e7bd5c75d4 100644\n--- a/lib/matplotlib/axes/_axes.py\n+++ b/lib/matplotlib/axes/_axes.py\n@@ -4848,7 +4848,7 @@ default: :rc:`scatter.edgecolors`\n             Use a linear or log10 scale on the vertical axis.\n \n         mincnt : int > 0, default: *None*\n-            If not *None*, only display cells with more than *mincnt*\n+            If not *None*, only display cells with at least *mincnt*\n             number of points in the cell.\n \n         marginals : bool, default: *False*\n@@ -5011,10 +5011,10 @@ default: :rc:`scatter.edgecolors`\n                     Cs_at_i1[i1[i]].append(C[i])\n                 else:\n                     Cs_at_i2[i2[i]].append(C[i])\n-            if mincnt is None:\n-                mincnt = 0\n+            # Empty bins can't be reduced, so require at least one point.\n+            mincnt = 1 if mincnt is None else max(mincnt, 1)\n             accum = np.array(\n-                [reduce_C_function(acc) if len(acc) > mincnt else np.nan\n+                [reduce_C_function(acc) if len(acc) >= mincnt else np.nan\n                  for Cs_at_i in [Cs_at_i1, Cs_at_i2]\n                  for acc in Cs_at_i[1:]],  # [1:] drops out-of-range points.\n                 float)\n", "model": "claude-sonnet-5-5", "steps": 6, "finished": true, "patch_lines": 27, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 27, "steps": 6}], "ms": 16304}
{"instance_id": "matplotlib__matplotlib-26208", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py\nindex 5203e3232c..addaf3729d 100644\n--- a/lib/matplotlib/axes/_base.py\n+++ b/lib/matplotlib/axes/_base.py\n@@ -2251,20 +2251,24 @@ class _AxesBase(martist.Artist):\n             # Make sure viewLim is not stale (mostly to match\n             # pre-lazy-autoscale behavior, which is not really better).\n             self._unstale_viewLim()\n-            datalim = collection.get_datalim(self.transData)\n-            points = datalim.get_points()\n-            if not np.isinf(datalim.minpos).all():\n-                # By definition, if minpos (minimum positive value) is set\n-                # (i.e., non-inf), then min(points) <= minpos <= max(points),\n-                # and minpos would be superfluous. However, we add minpos to\n-                # the call so that self.dataLim will update its own minpos.\n-                # This ensures that log scales see the correct minimum.\n-                points = np.concatenate([points, [datalim.minpos]])\n-            self.update_datalim(points)\n+            self._update_collection_limits(collection)\n \n         self.stale = True\n         return collection\n \n+    def _update_collection_limits(self, collection):\n+        \"\"\"Update ``self.dataLim`` with the extent of *collection*.\"\"\"\n+        datalim = collection.get_datalim(self.transData)\n+        points = datalim.get_points()\n+        if not np.isinf(datalim.minpos).all():\n+            # By definition, if minpos (minimum positive value) is set\n+            # (i.e., non-inf), then min(points) <= minpos <= max(points),\n+            # and minpos would be superfluous. However, we add minpos to\n+            # the call so that self.dataLim will update its own minpos.\n+            # This ensures that log scales see the correct minimum.\n+            points = np.concatenate([points, [datalim.minpos]])\n+        self.update_datalim(points)\n+\n     def add_image(self, image):\n         \"\"\"\n         Add an `.AxesImage` to the Axes; return the image.\n@@ -2472,6 +2476,8 @@ class _AxesBase(martist.Artist):\n                     self._update_patch_limits(artist)\n                 elif isinstance(artist, mimage.AxesImage):\n                     self._update_image_limits(artist)\n+                elif isinstance(artist, mcoll.PolyCollection):\n+                    self._update_collection_limits(artist)\n \n     def update_datalim(self, xys, updatex=True, updatey=True):\n         \"\"\"\n", "model": "claude-sonnet-5-5", "steps": 16, "finished": false, "patch_lines": 48, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 48, "steps": 16}], "ms": 54077}
{"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..3a32f2bbb2 100644\n--- a/lib/mpl_toolkits/axes_grid1/inset_locator.py\n+++ b/lib/mpl_toolkits/axes_grid1/inset_locator.py\n@@ -70,6 +70,8 @@ class AnchoredLocatorBase(AnchoredOffsetbox):\n \n     def __call__(self, ax, renderer):\n         self.axes = ax\n+        if renderer is None:\n+            renderer = ax.figure._get_renderer()\n         bbox = self.get_window_extent(renderer)\n         px, py = self.get_offset(bbox.width, bbox.height, 0, 0, renderer)\n         bbox_canvas = Bbox.from_bounds(px, py, bbox.width, bbox.height)\n", "model": "claude-sonnet-5-5", "steps": 4, "finished": true, "patch_lines": 13, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 13, "steps": 4}], "ms": 13861}
{"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..9cd925c5c2 100644\n--- a/lib/matplotlib/contour.py\n+++ b/lib/matplotlib/contour.py\n@@ -1113,6 +1113,10 @@ class ContourSet(ContourLabeler, mcoll.Collection):\n                              if len(vertices) else empty_path)\n         return paths\n \n+    def set_paths(self, paths):\n+        self._paths = paths\n+        self.stale = True\n+\n     def _get_lowers_and_uppers(self):\n         \"\"\"\n         Return ``(lowers, uppers)`` for filled contours.\ndiff --git a/lib/matplotlib/contour.pyi b/lib/matplotlib/contour.pyi\nindex c7179637a1..a125bc22af 100644\n--- a/lib/matplotlib/contour.pyi\n+++ b/lib/matplotlib/contour.pyi\n@@ -154,6 +154,7 @@ class ContourSet(ContourLabeler, Collection):\n     def legend_elements(\n         self, variable_name: str = ..., str_format: Callable[[float], str] = ...\n     ) -> tuple[list[Artist], list[str]]: ...\n+    def set_paths(self, paths: Iterable[Path]) -> None: ...\n     def find_nearest_contour(\n         self, x: float, y: float, indices: Iterable[int] | None = ..., pixel: bool = ...\n     ) -> tuple[Collection, int, int, float, float, float]: ...\n", "model": "claude-sonnet-5-5", "steps": 16, "finished": true, "patch_lines": 27, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 2, "diff_lines": 27, "steps": 16}], "ms": 30908}
{"instance_id": "matplotlib__matplotlib-26466", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py\nindex d4922fc517..56dc47dfd1 100644\n--- a/lib/matplotlib/text.py\n+++ b/lib/matplotlib/text.py\n@@ -1456,7 +1456,8 @@ class _AnnotationBase:\n                  xycoords='data',\n                  annotation_clip=None):\n \n-        self.xy = xy\n+        x, y = xy  # Make copy when xy is an array (and check the shape).\n+        self.xy = x, y\n         self.xycoords = xycoords\n         self.set_annotation_clip(annotation_clip)\n \n", "model": "claude-sonnet-5-5", "steps": 8, "finished": true, "patch_lines": 14, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 14, "steps": 8}], "ms": 19355}
