Skip to content
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

Support numpy 1.24 #5581

Merged
merged 3 commits into from
Jan 3, 2023
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
20 changes: 19 additions & 1 deletion holoviews/core/data/spatialpandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ def to_geom_dict(eltype, data, kdims, vdims, interface=None):

xname, yname = (kd.name for kd in kdims[:2])
if isinstance(data, dict):
data = {k: v if isscalar(v) else np.asarray(v) for k, v in data.items()}
data = {k: v if isscalar(v) else _asarray(v) for k, v in data.items()}
return data
new_el = Dataset(data, kdims, vdims)
if new_el.interface is interface:
Expand Down Expand Up @@ -888,4 +888,22 @@ def from_shapely(data):
return data


def _asarray(v):
"""Convert input to array

First it tries with a normal `np.asarray(v)` if this does not work
it tries with `np.asarray(v, dtype=object)`.

The ValueError raised is because of an inhomogeneous shape of the input,
which raises an error in numpy v1.24 and above.

Reason why it is not located in holoviews.core.util is that there is a already a
function called `asarray`.
"""
try:
return np.asarray(v)
except ValueError:
return np.asarray(v, dtype=object)


Interface.register(SpatialPandasInterface)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ filterwarnings = [
"ignore:make_current is deprecated; start the event loop first:DeprecationWarning:panel.io.server",
# 2023-01-02: Numpy 1.24 warnings
"ignore:`.+?` is a deprecated alias for `.+?`.:DeprecationWarning:bokeh", # https://github.com/bokeh/bokeh/pull/12690
"ignore:`.+?` is a deprecated alias for `.+?`.:DeprecationWarning:cupy", # https://github.com/cupy/cupy/issues/7211
"ignore:`.+?` is a deprecated alias for `.+?`.:DeprecationWarning:cupy", # https://github.com/cupy/cupy/pull/7245
"ignore:`.+?` is a deprecated alias for `.+?`.:DeprecationWarning:plotly.express.imshow_utils", # https://github.com/plotly/plotly.py/pull/3997
"ignore:`.+?` is a deprecated alias for `.+?`.:DeprecationWarning:skimage.util.dtype", # https://github.com/scikit-image/scikit-image/pull/6637
]