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

Skip to content

Commit b62f0b0

Browse files
committed
Replace all instances of hasattr.
1 parent 56f341f commit b62f0b0

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/matplotlib/lines.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,16 +237,16 @@ class Line2D(Artist):
237237
def __str__(self):
238238
if self._label != "":
239239
return "Line2D(%s)" % (self._label)
240-
elif hasattr(self, '_x') and len(self._x) > 3:
240+
elif self._x is None:
241+
return "Line2D()"
242+
elif len(self._x) > 3:
241243
return "Line2D((%g,%g),(%g,%g),...,(%g,%g))"\
242244
% (self._x[0], self._y[0], self._x[0],
243245
self._y[0], self._x[-1], self._y[-1])
244-
elif hasattr(self, '_x'):
246+
else:
245247
return "Line2D(%s)"\
246248
% (",".join(["(%g,%g)" % (x, y) for x, y
247249
in zip(self._x, self._y)]))
248-
else:
249-
return "Line2D()"
250250

251251
def __init__(self, xdata, ydata,
252252
linewidth=None, # all Nones default to rc
@@ -653,7 +653,7 @@ def recache(self, always=False):
653653
else:
654654
self._x_filled = self._x
655655

656-
if hasattr(self, '_path'):
656+
if self._path is not None:
657657
interpolation_steps = self._path._interpolation_steps
658658
else:
659659
interpolation_steps = 1
@@ -1449,7 +1449,7 @@ def __init__(self, line):
14491449
:class:`matplotlib.axes.Axes` instance and should have the
14501450
picker property set.
14511451
"""
1452-
if not hasattr(line, 'axes'):
1452+
if line.axes is None:
14531453
raise RuntimeError('You must first add the line to the Axes')
14541454

14551455
if line.get_picker() is None:

0 commit comments

Comments
 (0)