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

Skip to content

Commit 863ad9d

Browse files
committed
More cbook deprecations.
`is_scalar_or_string` was not used anymore, `is_scalar` was only used in one place (in mplot3d) and I rewrote that snippet into something more robust.
1 parent 6d3610b commit 863ad9d

File tree

2 files changed

+14
-26
lines changed

2 files changed

+14
-26
lines changed

lib/matplotlib/cbook/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ def file_requires_unicode(x):
543543
return False
544544

545545

546+
@deprecated('2.1')
546547
def is_scalar(obj):
547548
"""return true if *obj* is not string like and is not iterable"""
548549
return not is_string_like(obj) and not iterable(obj)
@@ -582,6 +583,7 @@ def to_filehandle(fname, flag='rU', return_opened=False):
582583
return fh
583584

584585

586+
@deprecated('2.1')
585587
def is_scalar_or_string(val):
586588
"""Return whether the given object is a scalar or string like."""
587589
return is_string_like(val) or not iterable(val)

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,39 +1503,25 @@ def plot(self, xs, ys, *args, **kwargs):
15031503
Other arguments are passed on to
15041504
:func:`~matplotlib.axes.Axes.plot`
15051505
'''
1506-
# FIXME: This argument parsing might be better handled
1507-
# when we set later versions of python for
1508-
# minimum requirements. Currently at 2.4.
1509-
# Note that some of the reason for the current difficulty
1510-
# is caused by the fact that we want to insert a new
1511-
# (semi-optional) positional argument 'Z' right before
1512-
# many other traditional positional arguments occur
1513-
# such as the color, linestyle and/or marker.
15141506
had_data = self.has_data()
1515-
zs = kwargs.pop('zs', 0)
1516-
zdir = kwargs.pop('zdir', 'z')
15171507

1518-
argsi = 0
1519-
# First argument is array of zs
1520-
if args and cbook.iterable(args[0]) and len(xs) == len(args[0]):
1521-
# So, we know that it is an array with
1522-
# first dimension the same as xs.
1523-
# Next, check to see if the data contained
1524-
# therein (if any) is scalar (and not another array).
1525-
if len(args[0]) == 0 or cbook.is_scalar(args[0][0]):
1526-
zs = args[argsi]
1527-
argsi += 1
1528-
1529-
# First argument is z value
1530-
elif args and cbook.is_scalar(args[0]):
1531-
zs = args[argsi]
1532-
argsi += 1
1508+
# `zs` can be passed positionally or as keyword; checking with
1509+
# `_is_string_like` matches the behavior of 2D `plot` (via
1510+
# `_process_plot_var_args`).
1511+
if args and not cbook.is_string_like(args[0]):
1512+
zs = args[0]
1513+
args = args[1:]
1514+
if 'zs' in kwargs:
1515+
raise TypeError("plot() for multiple values for argument 'z'")
1516+
else:
1517+
zs = kwargs.pop('zs', 0)
1518+
zdir = kwargs.pop('zdir', 'z')
15331519

15341520
# Match length
15351521
if not cbook.iterable(zs):
15361522
zs = np.ones(len(xs)) * zs
15371523

1538-
lines = Axes.plot(self, xs, ys, *args[argsi:], **kwargs)
1524+
lines = Axes.plot(self, xs, ys, *args, **kwargs)
15391525
for line in lines:
15401526
art3d.line_2d_to_3d(line, zs=zs, zdir=zdir)
15411527

0 commit comments

Comments
 (0)