8000 move arguments check from axline function into _AxLine class · matplotlib/matplotlib@da0b344 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit da0b344

Browse files
committed
move arguments check from axline function into _AxLine class
1 parent d7c31c3 commit da0b344

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -843,11 +843,6 @@ def axline(self, xy1, xy2=None, *, slope=None, **kwargs):
843843
844844
>>> axline((0, 0), (1, 1), linewidth=4, color='r')
845845
"""
846-
if (xy2 is None and slope is None or
847-
xy2 is not None and slope is not None):
848-
raise TypeError(
849-
"Exactly one of 'xy2' and 'slope' must be given")
850-
851846
if slope is not None and (self.get_xscale() != 'linear' or
852847
self.get_yscale() != 'linear'):
853848
raise TypeError("'slope' cannot be used with non-linear scales")

lib/matplotlib/lines.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,12 @@ class _AxLine(Line2D):
14061406

14071407
def __init__(self, xy1, xy2, slope, **kwargs):
14081408
super().__init__([0, 1], [0, 1], **kwargs)
1409+
1410+
if (xy2 is None and slope is None or
1411+
xy2 is not None and slope is not None):
1412+
raise TypeError(
1413+
"Exactly one of 'xy2' and 'slope' must be given")
1414+
14091415
self._slope = slope
14101416
self._xy1 = xy1
14111417
self._xy2 = xy2

0 commit comments

Comments
 (0)
0