datashade=True broken with numpy version 1.24.3
tlogan2000 opened this issue · 5 comments
Thanks for contacting us! Please read and follow these instructions carefully, then delete this introductory text to keep your issue easy to read. Note that the issue tracker is NOT the place for usage questions and technical assistance; post those at Discourse instead. Issues without the required information below may be closed immediately.
ALL software version info
hvplot 0.8.3
numpy 1.24.3
datashader 0.14.4
panel 0.14.4
running on rocky linux
Description of expected behavior and the observed behavior
Can't use datashade=True
with hvplot.quadmesh()
with numpy v. 1.24.3
Complete, minimal, self-contained example code that reproduces the issue
import xarray as xr
import hvplot.xarray
import cartopy.crs as ccrs
import numpy as np
print("numpy version:",np.__version__)
air_ds = xr.tutorial.open_dataset('air_temperature').load()
air_ds.hvplot.quadmesh(
'lon', 'lat', 'air', projection=ccrs.Orthographic(-90, 30),
global_extent=True, frame_height=540, cmap='viridis', datashade=True,
coastline=True
)
Stack traceback and/or browser JavaScript console output
WARNING:param.dynamic_operation: Callable raised "AttributeError("module 'numpy' has no attribute 'warnings'")".
Invoked as dynamic_operation(numpy.datetime64('2013-01-01T00:00:00.000000000'), height=400, scale=1.0, width=400, x_range=None, y_range=None)
WARNING:param.dynamic_mul: Callable raised "AttributeError("module 'numpy' has no attribute 'warnings'")".
Invoked as dynamic_mul(numpy.datetime64('2013-01-01T00:00:00.000000000'))
WARNING:param.dynamic_operation: Callable raised "AttributeError("module 'numpy' has no attribute 'warnings'")".
Invoked as dynamic_operation(numpy.datetime64('2013-01-01T00:00:00.000000000'))
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/IPython/core/formatters.py:974, in MimeBundleFormatter.__call__(self, obj, include, exclude)
971 method = get_real_method(obj, self.print_method)
973 if method is not None:
--> 974 return method(include=include, exclude=exclude)
975 return None
976 else:
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/core/dimension.py:1290, in Dimensioned._repr_mimebundle_(self, include, exclude)
1283 def _repr_mimebundle_(self, include=None, exclude=None):
1284 """
1285 Resolves the class hierarchy for the class rendering the
1286 object using any display hooks registered on Store.display
1287 hooks. The output of all registered display_hooks is then
1288 combined and returned.
1289 """
-> 1290 return Store.render(self)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/core/options.py:1425, in Store.render(cls, obj)
1423 data, metadata = {}, {}
1424 for hook in hooks:
-> 1425 ret = hook(obj)
1426 if ret is None:
1427 continue
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/ipython/display_hooks.py:280, in pprint_display(obj)
278 if not ip.display_formatter.formatters['text/plain'].pprint:
279 return None
--> 280 return display(obj, raw_output=True)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/ipython/display_hooks.py:254, in display(obj, raw_output, **kwargs)
252 elif isinstance(obj, (HoloMap, DynamicMap)):
253 with option_state(obj):
--> 254 output = map_display(obj)
255 elif isinstance(obj, Plot):
256 output = render(obj)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/ipython/display_hooks.py:142, in display_hook.<locals>.wrapped(element)
140 try:
141 max_frames = OutputSettings.options['max_frames']
--> 142 mimebundle = fn(element, max_frames=max_frames)
143 if mimebundle is None:
144 return {}, {}
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/ipython/display_hooks.py:202, in map_display(vmap, max_frames)
199 max_frame_warning(max_frames)
200 return None
--> 202 return render(vmap)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/ipython/display_hooks.py:69, in render(obj, **kwargs)
66 if renderer.fig == 'pdf':
67 renderer = renderer.instance(fig='png')
---> 69 return renderer.components(obj, **kwargs)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/plotting/renderer.py:399, in Renderer.components(self, obj, fmt, comm, **kwargs)
396 embed = (not (dynamic or streams or self.widget_mode == 'live') or config.embed)
398 if embed or config.comms == 'default':
--> 399 return self._render_panel(plot, embed, comm)
400 return self._render_ipywidget(plot)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/plotting/renderer.py:406, in Renderer._render_panel(self, plot, embed, comm)
404 doc = Document()
405 with config.set(embed=embed):
--> 406 model = plot.layout._render_model(doc, comm)
407 if embed:
408 return render_model(model, comm)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/panel/viewable.py:509, in Renderable._render_model(self, doc, comm)
507 if comm is None:
508 comm = state._comm_manager.get_server_comm()
--> 509 model = self.get_root(doc, comm)
511 if config.embed:
512 embed_state(self, model, doc,
513 json=config.embed_json,
514 json_prefix=config.embed_json_prefix,
515 save_path=config.embed_save_path,
516 load_path=config.embed_load_path,
517 progress=False)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/panel/viewable.py:560, in Renderable.get_root(self, doc, comm, preprocess)
543 """
544 Returns the root model and applies pre-processing hooks
545
(...)
557 Returns the bokeh model corresponding to this panel object
558 """
559 doc = init_doc(doc)
--> 560 root = self._get_model(doc, comm=comm)
561 if preprocess:
562 self._preprocess(root)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/panel/layout/base.py:146, in Panel._get_model(self, doc, root, parent, comm)
144 if root is None:
145 root = model
--> 146 objects = self._get_objects(model, [], doc, root, comm)
147 props = dict(self._init_params(), objects=objects)
148 model.update(**self._process_param_change(props))
File /opt/conda/envs/birdy/lib/python3.9/site-packages/panel/layout/base.py:131, in Panel._get_objects(self, model, old_objects, doc, root, comm)
129 else:
130 try:
--> 131 child = pane._get_model(doc, root, model, comm)
132 except RerenderError:
133 return self._get_objects(model, current_objects[:i], doc, root, comm)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/panel/pane/holoviews.py:367, in HoloViews._get_model(self, doc, root, parent, comm)
365 plot = self.object
366 else:
--> 367 plot = self._render(doc, comm, root)
369 plot.pane = self
370 backend = plot.renderer.backend
File /opt/conda/envs/birdy/lib/python3.9/site-packages/panel/pane/holoviews.py:442, in HoloViews._render(self, doc, comm, root)
439 if comm:
440 kwargs['comm'] = comm
--> 442 return renderer.get_plot(self.object, **kwargs)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/plotting/bokeh/renderer.py:70, in BokehRenderer.get_plot(self_or_cls, obj, doc, renderer, **kwargs)
63 @bothmethod
64 def get_plot(self_or_cls, obj, doc=None, renderer=None, **kwargs):
65 """
66 Given a HoloViews Viewable return a corresponding plot instance.
67 Allows supplying a document attach the plot to, useful when
68 combining the bokeh model with another plot.
69 """
---> 70 plot = super().get_plot(obj, doc, renderer, **kwargs)
71 if plot.document is None:
72 plot.document = Document() if self_or_cls.notebook_context else curdoc()
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/plotting/renderer.py:218, in Renderer.get_plot(self_or_cls, obj, doc, renderer, comm, **kwargs)
215 raise SkipRendering(msg.format(dims=dims))
217 # Initialize DynamicMaps with first data item
--> 218 initialize_dynamic(obj)
220 if not renderer:
221 renderer = self_or_cls
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/plotting/util.py:257, in initialize_dynamic(obj)
255 continue
256 if not len(dmap):
--> 257 dmap[dmap._initial_key()]
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/core/spaces.py:1213, in DynamicMap.__getitem__(self, key)
1211 # Not a cross product and nothing cached so compute element.
1212 if cache is not None: return cache
-> 1213 val = self._execute_callback(*tuple_key)
1214 if data_slice:
1215 val = self._dataslice(val, data_slice)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/core/spaces.py:980, in DynamicMap._execute_callback(self, *args)
977 kwargs['_memoization_hash_'] = hash_items
979 with dynamicmap_memoization(self.callback, self.streams):
--> 980 retval = self.callback(*args, **kwargs)
981 return self._style(retval)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/core/spaces.py:580, in Callable.__call__(self, *args, **kwargs)
577 args, kwargs = (), dict(pos_kwargs, **kwargs)
579 try:
--> 580 ret = self.callable(*args, **kwargs)
581 except KeyError:
582 # KeyError is caught separately because it is used to signal
583 # invalid keys on DynamicMap and should not warn
584 raise
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/util/__init__.py:1025, in Dynamic._dynamic_operation.<locals>.dynamic_operation(*key, **kwargs)
1024 def dynamic_operation(*key, **kwargs):
-> 1025 key, obj = resolve(key, kwargs)
1026 return apply(obj, *key, **kwargs)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/util/__init__.py:1014, in Dynamic._dynamic_operation.<locals>.resolve(key, kwargs)
1012 elif isinstance(map_obj, DynamicMap) and map_obj._posarg_keys and not key:
1013 key = tuple(kwargs[k] for k in map_obj._posarg_keys)
-> 1014 return key, map_obj[key]
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/core/spaces.py:1213, in DynamicMap.__getitem__(self, key)
1211 # Not a cross product and nothing cached so compute element.
1212 if cache is not None: return cache
-> 1213 val = self._execute_callback(*tuple_key)
1214 if data_slice:
1215 val = self._dataslice(val, data_slice)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/core/spaces.py:980, in DynamicMap._execute_callback(self, *args)
977 kwargs['_memoization_hash_'] = hash_items
979 with dynamicmap_memoization(self.callback, self.streams):
--> 980 retval = self.callback(*args, **kwargs)
981 return self._style(retval)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/core/spaces.py:580, in Callable.__call__(self, *args, **kwargs)
577 args, kwargs = (), dict(pos_kwargs, **kwargs)
579 try:
--> 580 ret = self.callable(*args, **kwargs)
581 except KeyError:
582 # KeyError is caught separately because it is used to signal
583 # invalid keys on DynamicMap and should not warn
584 raise
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/core/spaces.py:282, in HoloMap.__mul__.<locals>.dynamic_mul(*args, **kwargs)
281 def dynamic_mul(*args, **kwargs):
--> 282 element = self[args]
283 if reverse:
284 return other * element
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/core/spaces.py:1213, in DynamicMap.__getitem__(self, key)
1211 # Not a cross product and nothing cached so compute element.
1212 if cache is not None: return cache
-> 1213 val = self._execute_callback(*tuple_key)
1214 if data_slice:
1215 val = self._dataslice(val, data_slice)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/core/spaces.py:980, in DynamicMap._execute_callback(self, *args)
977 kwargs['_memoization_hash_'] = hash_items
979 with dynamicmap_memoization(self.callback, self.streams):
--> 980 retval = self.callback(*args, **kwargs)
981 return self._style(retval)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/core/spaces.py:580, in Callable.__call__(self, *args, **kwargs)
577 args, kwargs = (), dict(pos_kwargs, **kwargs)
579 try:
--> 580 ret = self.callable(*args, **kwargs)
581 except KeyError:
582 # KeyError is caught separately because it is used to signal
583 # invalid keys on DynamicMap and should not warn
584 raise
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/util/__init__.py:1026, in Dynamic._dynamic_operation.<locals>.dynamic_operation(*key, **kwargs)
1024 def dynamic_operation(*key, **kwargs):
1025 key, obj = resolve(key, kwargs)
-> 1026 return apply(obj, *key, **kwargs)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/util/__init__.py:1018, in Dynamic._dynamic_operation.<locals>.apply(element, *key, **kwargs)
1016 def apply(element, *key, **kwargs):
1017 kwargs = dict(util.resolve_dependent_kwargs(self.p.kwargs), **kwargs)
-> 1018 processed = self._process(element, key, kwargs)
1019 if (self.p.link_dataset and isinstance(element, Dataset) and
1020 isinstance(processed, Dataset) and processed._dataset is None):
1021 processed._dataset = element.dataset
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/util/__init__.py:1000, in Dynamic._process(self, element, key, kwargs)
998 elif isinstance(self.p.operation, Operation):
999 kwargs = {k: v for k, v in kwargs.items() if k in self.p.operation.param}
-> 1000 return self.p.operation.process_element(element, key, **kwargs)
1001 else:
1002 return self.p.operation(element, **kwargs)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/core/operation.py:194, in Operation.process_element(self, element, key, **params)
191 else:
192 self.p = param.ParamOverrides(self, params,
193 allow_extra_keywords=self._allow_extra_keywords)
--> 194 return self._apply(element, key)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/core/operation.py:141, in Operation._apply(self, element, key)
139 if not in_method:
140 element._in_method = True
--> 141 ret = self._process(element, key)
142 if hasattr(element, '_in_method') and not in_method:
143 element._in_method = in_method
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/operation/datashader.py:1422, in datashade._process(self, element, key)
1421 def _process(self, element, key=None):
-> 1422 agg = rasterize._process(self, element, key)
1423 shaded = shade._process(self, agg, key)
1424 return shaded
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/operation/datashader.py:1401, in rasterize._process(self, element, key)
1398 op = transform.instance(**{k:v for k,v in extended_kws.items()
1399 if k in transform.param})
1400 op._precomputed = self._precomputed
-> 1401 element = element.map(op, predicate)
1402 self._precomputed = op._precomputed
1404 unused_params = list(all_supplied_kws - all_allowed_kws)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/core/data/__init__.py:199, in PipelineMeta.pipelined.<locals>.pipelined_fn(*args, **kwargs)
196 inst._in_method = True
198 try:
--> 199 result = method_fn(*args, **kwargs)
200 if PipelineMeta.disable:
201 return result
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/core/data/__init__.py:1207, in Dataset.map(self, *args, **kwargs)
1205 @wraps(LabelledData.map)
1206 def map(self, *args, **kwargs):
-> 1207 return super().map(*args, **kwargs)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/core/dimension.py:700, in LabelledData.map(self, map_fn, specs, clone)
698 return deep_mapped
699 else:
--> 700 return map_fn(self) if applies else self
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/core/operation.py:214, in Operation.__call__(self, element, **kwargs)
210 return element.clone([(k, self._apply(el, key=k))
211 for k, el in element.items()])
212 elif ((self._per_element and isinstance(element, Element)) or
213 (not self._per_element and isinstance(element, ViewableElement))):
--> 214 return self._apply(element)
215 elif 'streams' not in kwargs:
216 kwargs['streams'] = self.p.streams
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/core/operation.py:141, in Operation._apply(self, element, key)
139 if not in_method:
140 element._in_method = True
--> 141 ret = self._process(element, key)
142 if hasattr(element, '_in_method') and not in_method:
143 element._in_method = in_method
File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/operation/datashader.py:1042, in quadmesh_rasterize._process(self, element, key)
1038 cvs = ds.Canvas(plot_width=width, plot_height=height,
1039 x_range=x_range, y_range=y_range)
1041 vdim = getattr(agg_fn, 'column', element.vdims[0].name)
-> 1042 agg = cvs.quadmesh(data[vdim], x.name, y.name, agg_fn)
1043 xdim, ydim = list(agg.dims)[:2][::-1]
1044 if xtype == "datetime":
File /opt/conda/envs/birdy/lib/python3.9/site-packages/datashader/core.py:835, in Canvas.quadmesh(self, source, x, y, agg)
832 if upsample_width and upsample_height:
833 # Override aggregate with more efficient one for upsampling
834 agg = rd._upsample(name)
--> 835 return bypixel(source, self, glyph, agg)
836 elif not upsample_width and not upsample_height:
837 # Downsample both width and height
838 return bypixel(source, self, glyph, agg)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/datashader/core.py:1258, in bypixel(source, canvas, glyph, agg, antialias)
1255 canvas.validate()
1257 # All-NaN objects (e.g. chunks of arrays with no data) are valid in Datashader
-> 1258 with np.warnings.catch_warnings():
1259 np.warnings.filterwarnings('ignore', r'All-NaN (slice|axis) encountered')
1260 return bypixel.pipeline(source, schema, canvas, glyph, agg, antialias=antialias)
File /opt/conda/envs/birdy/lib/python3.9/site-packages/numpy/__init__.py:320, in __getattr__(attr)
317 from .testing import Tester
318 return Tester
--> 320 raise AttributeError("module {!r} has no attribute "
321 "{!r}".format(__name__, attr))
AttributeError: module 'numpy' has no attribute 'warnings'
Screenshots or screencasts of the bug in action
This will be fixed in the next release of Datashader (expected next week). Until then, you can downgrade Numpy to 1.23 to get it to work.
I would just add that this also does not work for rasterize=True
using
xarray - [ 2023.5.0 ]
hvplot - [ 0.8.3 ]
numpy - [ 1.24.3 ]
holoviews - [ 1.16.0 ]
geoviews - [ 1.10.0 ]
panel - [ 1.0.3 ]
bokeh - [ 3.1.1 ]
Python - 3.10.11
JupyterLab - 3.6.3
Datashader 0.15 has been released.
@Hoxbro Datashader is at 0.14.4 no?
Mistyped the version. It is now updated.