Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7643d35

Browse files
committed
removed \, and moved error check after convert unit
Passed pep8
1 parent 77715d8 commit 7643d35

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2874,14 +2874,14 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False, **kw):
28742874

28752875
self._process_unit_info(xdata=(left, right))
28762876

2877-
if ((np.isscalar(left)) and not (np.isfinite(left))) \
2878-
or ((np.isscalar(right)) and (not np.isfinite(right))):
2879-
raise ValueError('left/right should be finite values')
2880-
28812877
if left is not None:
28822878
left = self.convert_xunits(left)
2879+
if ((np.isscalar(left)) and not (np.isfinite(left))):
2880+
raise ValueError('left/right should be finite values')
28832881
if right is not None:
28842882
right = self.convert_xunits(right)
2883+
if ((np.isscalar(right)) and (not np.isfinite(right))):
2884+
raise ValueError('left/right should be finite values')
28852885

28862886
old_left, old_right = self.get_xlim()
28872887
if left is None:
@@ -3172,14 +3172,14 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False, **kw):
31723172
if top is None and iterable(bottom):
31733173
bottom, top = bottom
31743174

3175-
if ((np.isscalar(top)) and not (np.isfinite(top))) \
3176-
or ((np.isscalar(bottom)) and (not np.isfinite(bottom))):
3177-
raise ValueError('top/bottom should be finite values')
3178-
31793175
if bottom is not None:
31803176
bottom = self.convert_yunits(bottom)
3177+
if ((np.isscalar(bottom)) and not (np.isfinite(bottom))):
3178+
raise ValueError('top/bottom should be finite values')
31813179
if top is not None:
31823180
top = self.convert_yunits(top)
3181+
if ((np.isscalar(top)) and (not np.isfinite(top))):
3182+
raise ValueError('top/bottom should be finite values')
31833183

31843184
old_bottom, old_top = self.get_ylim()
31853185

lib/matplotlib/tests/test_axes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,7 @@ def test_axes():
10211021
with pytest.raises(ValueError):
10221022
ax.set_ylim(bottom=np.inf)
10231023

1024+
10241025
@image_comparison(baseline_images=['canonical'])
10251026
def test_canonical():
10261027
fig, ax = plt.subplots()

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -602,15 +602,15 @@ def set_xlim3d(self, left=None, right=None, emit=True, auto=False, **kw):
602602
if right is None and cbook.iterable(left):
603603
left, right = left
604604

605-
if ((np.isscalar(left)) and not (np.isfinite(left))) \
606-
or ((np.isscalar(right)) and (not np.isfinite(right))):
607-
raise ValueError('left/right should be finite values')
608-
609605
self._process_unit_info(xdata=(left, right))
610606
if left is not None:
611607
left = self.convert_xunits(left)
608+
if ((np.isscalar(left)) and not (np.isfinite(left))):
609+
raise ValueError('left/right should be finite values')
612610
if right is not None:
613611
right = self.convert_xunits(right)
612+
if ((np.isscalar(right)) and (not np.isfinite(right))):
613+
raise ValueError('left/right should be finite values')
614614

615615
old_left, old_right = self.get_xlim()
616616
if left is None:
@@ -660,15 +660,15 @@ def set_ylim3d(self, bottom=None, top=None, emit=True, auto=False, **kw):
660660
if top is None and cbook.iterable(bottom):
661661
bottom, top = bottom
662662

663-
if ((np.isscalar(top)) and not (np.isfinite(top))) \
664-
or ((np.isscalar(bottom)) and (not np.isfinite(bottom))):
665-
raise ValueError('top/bottom should be finite values')
666-
667663
self._process_unit_info(ydata=(bottom, top))
668664
if bottom is not None:
669665
bottom = self.convert_yunits(bottom)
666+
if ((np.isscalar(bottom)) and not (np.isfinite(bottom))):
667+
raise ValueError('bottom should be finite values')
670668
if top is not None:
671669
top = self.convert_yunits(top)
670+
if ((np.isscalar(top)) and (not np.isfinite(top))):
671+
raise ValueError('top should be finite values')
672672

673673
old_bottom, old_top = self.get_ylim()
674674
if bottom is None:
@@ -720,14 +720,14 @@ def set_zlim3d(self, bottom=None, top=None, emit=True, auto=False, **kw):
720720

721721
self._process_unit_info(zdata=(bottom, top))
722722

723-
if ((np.isscalar(top)) and not (np.isfinite(top))) \
724-
or ((np.isscalar(bottom)) and (not np.isfinite(bottom))):
725-
raise ValueError('top/bottom should be finite values')
726-
727723
if bottom is not None:
728724
bottom = self.convert_zunits(bottom)
725+
if ((np.isscalar(bottom)) and not (np.isfinite(bottom))):
726+
raise ValueError('bottom should be finite values')
729727
if top is not None:
730728
top = self.convert_zunits(top)
729+
if ((np.isscalar(top)) and (not np.isfinite(top))):
730+
raise ValueError('top should be finite values')
731731

732732
old_bottom, old_top = self.get_zlim()
733733
if bottom is None:

0 commit comments

Comments
 (0)