harbor run -t openthoughts/tasktrove-exp-rpt-issue-issue-1069harbor download openthoughts/tasktrove-exp-rpt-issue-issue-1069Title: Do not accept arbitrary positional parameters in Figure.add_axes()
Description The codebase currently allows extra positional parameters to be passed to Figure.add_axes(), and those extras are effectively ignored in some code paths. This makes the API hard to read and can lead to subtle bugs. The requested change is to deprecate and ignore any extra positional arguments to add_axes (instead of silently ignoring or misinterpreting them) and to adjust internal projection-argument handling to rely only on keyword arguments.
Expected behavior
Before state of the relevant code (pre-fix) The snippets below reflect the pre-fix behavior as it appeared in the repository. They show where extra positional arguments could be passed to add_axes and how the internal projection requirements were computed, as well as related call-sites that rely on positional arguments.
def add_axes(self, *args, **kwargs):
if len(args) == 1 and isinstance(args[0], Axes):
a = args[0]
key = a._projection_init
if a.get_figure() is not self:
raise ValueError(
"The Axes must have been created in the present figure")
else:
rect = args[0]
if not np.isfinite(rect).all():
raise ValueError('all entries in rect must be finite '
f'not {rect}')
projection_class, pkw = self._process_projection_requirements(
*args, **kwargs)
# create the new axes using the axes class given
a = projection_class(self, rect, **pkw)
key = (projection_class, pkw)
return self._add_axes_internal(a, key)
def _process_projection_requirements(
self, *args, axes_class=None, polar=False, projection=None,
**kwargs):
"""
Handle the args/kwargs to add_axes/add_subplot/gca, returning::
def subplot(*args, **kwargs) -> Axes:
...
if (ax.get_subplotspec() == key
and (kwargs == {}
or (ax._projection_init
== fig._process_projection_requirements(*args, **kwargs)))):
break
def inset_axes(self, bounds, *, transform=None, zorder=5, **kwargs):
# This puts the rectangle into figure-relative coordinates.
inset_locator = _TransformedBoundsLocator(bounds, transform)
bounds = inset_locator(self, None).bounds
projection_class, pkw = self.figure._process_projection_requirements(
bounds, **kwargs)
inset_ax = projection_class(self.figure, bounds, zorder=zorder, **pkw)
What to implement in /app/ Files to modify (or create under /app/ as needed)
What you should implement (high level, not exposing the exact patch)
How to test locally (manual checks)
Acceptance criteria
Notes
If you want me to tailor the code blocks further or adjust the exact deprecation wording/version, let me know and I can refine.