8000 More cbook deprecations. by anntzer · Pull Request #7999 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

More cbook deprecations. #7999

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/matplotlib/cbook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ def file_requires_unicode(x):
return False


@deprecated('2.1')
def is_scalar(obj):
"""return true if *obj* is not string like and is not iterable"""
return not is_string_like(obj) and not iterable(obj)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is is_scaler supposed to be broader than is_numlike?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arbitrary objects (that are not iterable) are scalars, not numlike. Why?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'cause that confuses me 'cause aren't scalers numbers? What definition of scalers are we using then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use this function and I exactly don't want to get bogged down into defining what its semantics should be.

Expand Down Expand Up @@ -582,6 +583,7 @@ def to_filehandle(fname, flag='rU', return_opened=False):
return fh


@deprecated('2.1')
def is_scalar_or_string(val):
"""Return whether the given object is a scalar or string like."""
return is_string_like(val) or not iterable(val)
Expand Down
38 changes: 12 additions & 26 deletions lib/mpl_toolkits/mplot3d/axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -1503,39 +1503,25 @@ def plot(self, xs, ys, *args, **kwargs):
Other arguments are passed on to
:func:`~matplotlib.axes.Axes.plot`
'''
# FIXME: This argument parsing might be better handled
# when we set later versions of python for
# minimum requirements. Currently at 2.4.
# Note that some of the reason for the current difficulty
# is caused by the fact that we want to insert a new
# (semi-optional) positional argument 'Z' right before
# many other traditional positional arguments occur
# such as the color, linestyle and/or marker.
had_data = self.has_data()
zs = kwargs.pop('zs', 0)
zdir = kwargs.pop('zdir', 'z')

argsi = 0
# First argument is array of zs
if args and cbook.iterable(args[0]) and len(xs) == len(args[0]):
# So, we know that it is an array with
# first dimension the same as xs.
# Next, check to see if the data contained
# therein (if any) is scalar (and not another array).
if len(args[0]) == 0 or cbook.is_scalar(args[0][0]):
zs = args[argsi]
argsi += 1

# First argument is z value
elif args and cbook.is_scalar(args[0]):
zs = args[argsi]
argsi += 1
# `zs` can be passed positionally or as keyword; checking with
# `_is_string_like` matches the behavior of 2D `plot` (via
# `_process_plot_var_args`).
if args and not cbook.is_string_like(args[0]):
zs = args[0]
args = args[1:]
if 'zs' in kwargs:
raise TypeError("plot() for multiple values for argument 'z'")
else:
zs = kwargs.pop('zs', 0)
zdir = kwargs.pop('zdir', 'z')

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

lines = Axes.plot(self, xs, ys, *args[argsi:], **kwargs)
lines = Axes.plot(self, xs, ys, *args, **kwargs)
for line in lines:
art3d.line_2d_to_3d(line, zs=zs, zdir=zdir)

Expand Down
0