diff --git a/holoviews/core/data/spatialpandas.py b/holoviews/core/data/spatialpandas.py index 9af858daf7..d31b0d2aa2 100644 --- a/holoviews/core/data/spatialpandas.py +++ b/holoviews/core/data/spatialpandas.py @@ -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: @@ -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) diff --git a/pyproject.toml b/pyproject.toml index 0163c79d6f..489a78a99f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 ]