Skip to content

remove _ensure_plottable #5763

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 0 additions & 5 deletions xarray/plot/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
_add_colorbar,
_adjust_legend_subtitles,
_assert_valid_xy,
_ensure_plottable,
_infer_interval_breaks,
_infer_xy_labels,
_is_numeric,
Expand Down Expand Up @@ -435,8 +434,6 @@ def line(
xlabel = label_from_attrs(xplt, extra=x_suffix)
ylabel = label_from_attrs(yplt, extra=y_suffix)

_ensure_plottable(xplt_val, yplt_val)

primitive = ax.plot(xplt_val, yplt_val, *args, **kwargs)

if _labels:
Expand Down Expand Up @@ -1175,8 +1172,6 @@ def newplotfunc(
xplt, xlab_extra = _resolve_intervals_2dplot(xval, plotfunc.__name__)
yplt, ylab_extra = _resolve_intervals_2dplot(yval, plotfunc.__name__)

_ensure_plottable(xplt, yplt, zval)

cmap_params, cbar_kwargs = _process_cmap_cbar_kwargs(
plotfunc,
zval.data,
Expand Down
44 changes: 0 additions & 44 deletions xarray/plot/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import itertools
import textwrap
import warnings
from datetime import datetime
from inspect import getfullargspec
from typing import Any, Iterable, Mapping, Tuple, Union

Expand Down Expand Up @@ -622,49 +621,6 @@ def _valid_numpy_subdtype(x, numpy_types):
return any(np.issubdtype(x.dtype, t) for t in numpy_types)


def _ensure_plottable(*args):
"""
Raise exception if there is anything in args that can't be plotted on an
axis by matplotlib.
"""
numpy_types = [
np.floating,
np.integer,
np.timedelta64,
np.datetime64,
np.bool_,
np.str_,
]
other_types = [datetime]
if cftime is not None:
cftime_datetime_types = [cftime.datetime]
other_types = other_types + cftime_datetime_types
else:
cftime_datetime_types = []
for x in args:
if not (
_valid_numpy_subdtype(np.array(x), numpy_types)
or _valid_other_type(np.array(x), other_types)
):
raise TypeError(
"Plotting requires coordinates to be numeric, boolean, "
"or dates of type numpy.datetime64, "
"datetime.datetime, cftime.datetime or "
f"pandas.Interval. Received data of type {np.array(x).dtype} instead."
)
if (
_valid_other_type(np.array(x), cftime_datetime_types)
and not nc_time_axis_available
):
raise ImportError(
"Plotting of arrays of cftime.datetime "
"objects or arrays indexed by "
"cftime.datetime objects requires the "
"optional `nc-time-axis` (v1.2.0 or later) "
"package."
)


def _is_numeric(arr):
numpy_types = [np.floating, np.integer]
return _valid_numpy_subdtype(arr, numpy_types)
Expand Down