Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f6dc5bc

Browse filesBrowse files
committed
Simplify parameter handling in FloatingAxesBase.
- `grid_helper` can just become a standard kwonly arg. - `GridHelperCurveLinear` is the only class that defines `get_boundary`, so in practice the hasattr check is the same as an isinstance check. (It is technically possible that someone wrote their own GridHelperCurveLinear-like subclass with the same API, but let's not overly worry about that... and they can always still completely inherit GridHelperCurveLinear and full override everything if really needed.)
1 parent 8a8dd90 commit f6dc5bc
Copy full SHA for f6dc5bc

File tree

Expand file treeCollapse file tree

1 file changed

+4
-8
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-8
lines changed

‎lib/mpl_toolkits/axisartist/floating_axes.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axisartist/floating_axes.py
+4-8Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import numpy as np
99

1010
from matplotlib import _api, cbook
11+
import matplotlib.axes as maxes
1112
import matplotlib.patches as mpatches
1213
from matplotlib.path import Path
13-
import matplotlib.axes as maxes
1414

1515
from mpl_toolkits.axes_grid1.parasite_axes import host_axes_class_factory
1616

@@ -311,13 +311,9 @@ def get_boundary(self):
311311

312312
class FloatingAxesBase:
313313

314-
def __init__(self, *args, **kwargs):
315-
grid_helper = kwargs.get("grid_helper", None)
316-
if grid_helper is None:
317-
raise ValueError("FloatingAxes requires grid_helper argument")
318-
if not hasattr(grid_helper, "get_boundary"):
319-
raise ValueError("grid_helper must implement get_boundary method")
320-
super().__init__(*args, **kwargs)
314+
def __init__(self, *args, grid_helper, **kwargs):
315+
_api.check_isinstance(GridHelperCurveLinear, grid_helper=grid_helper)
316+
super().__init__(*args, grid_helper=grid_helper, **kwargs)
321317
self.set_aspect(1.)
322318
self.adjust_axes_lim()
323319

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.