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

gv.Points not compatible with holoviews.operation.datashader.inspect_points #619

Open
kanglcn opened this issue Mar 10, 2023 · 2 comments
Open
Assignees

Comments

@kanglcn
Copy link

kanglcn commented Mar 10, 2023

ALL software version info

Name Version Build Channel
bokeh 2.4.3 pyhd8ed1ab_3 conda-forge
holoviews 1.15.4 pyhd8ed1ab_0 conda-forge
datashader 0.14.4 pyh1a96a4e_0 conda-forge
geoviews 1.9.6 pyhd8ed1ab_0 conda-forge
geoviews-core 1.9.6 pyha770c72_0 conda-forge

Description of expected behavior and the observed behavior

holoviews.operation.datashader.inspect_points allows inspecting all vdims in DynamicMap. But when using it with gv.Points, points disappear as soon as the mouse enters the frame. holoviews.Points don't have this issue.

This issue was first found here: https://discourse.holoviz.org/t/one-dimension-missing-on-hover-after-rasterize-point-data/4049

Complete, minimal, self-contained example code that reproduces the issue

import numpy as np
import pandas as pd
#import holoviews as hv
import geoviews as gv
#hv.extension('bokeh')
gv.extension('bokeh')
import holoviews.operation.datashader as hd

lon = np.array([8.75,8.76,8.77])
lat = np.array([46.1,46.2,46.3])
height = np.array([0.0,0.1,0.2])
index = np.array([0,1,2])

df = pd.DataFrame(dict(Longitude=lon,Latitude=lat,Height=height,Index=index))

gvpoints = gv.Points(df, ['Longitude','Latitude'])
#hvpoints = hv.Points(df, ['Longitude', 'Latitude'])

rasterized = hd.dynspread(hd.rasterize(gvpoints).opts(width=300, height=300))
highlight= hd.inspect_points(rasterized)
rasterized * highlight.opts(marker='o',size=10,tools=['hover'])

Stack traceback and/or browser JavaScript console output

Screenshots or screencasts of the bug in action

image

@ahuang11
Copy link
Collaborator

I encountered this traceback:

WARNING:param.dynamic_operation: Callable raised "ValueError('Supplied Image bounds do not match the coordinates defined in the data. Bounds only have to be declared if no coordinates are supplied, otherwise they must match the data. To change the displayed extents set the range on the x- and y-dimensions.')".
Invoked as dynamic_operation(x=-20037508.342789244, y=20037508.342789248)
Traceback (most recent call last):
  File "/Users/ahuang/repos/holoviews/holoviews/plotting/util.py", line 279, in get_plot_frame
    return map_obj[key]
  File "/Users/ahuang/repos/holoviews/holoviews/core/spaces.py", line 1212, in __getitem__
    val = self._execute_callback(*tuple_key)
  File "/Users/ahuang/repos/holoviews/holoviews/core/spaces.py", line 979, in _execute_callback
    retval = self.callback(*args, **kwargs)
  File "/Users/ahuang/repos/holoviews/holoviews/core/spaces.py", line 549, in __call__
    if not args and not kwargs and not any(kwarg_hash): return self.callable()
  File "/Users/ahuang/repos/holoviews/holoviews/util/__init__.py", line 1024, in dynamic_operation
    key, obj = resolve(key, kwargs)
  File "/Users/ahuang/repos/holoviews/holoviews/util/__init__.py", line 1013, in resolve
    return key, map_obj[key]
  File "/Users/ahuang/repos/holoviews/holoviews/core/spaces.py", line 1212, in __getitem__
    val = self._execute_callback(*tuple_key)
  File "/Users/ahuang/repos/holoviews/holoviews/core/spaces.py", line 979, in _execute_callback
    retval = self.callback(*args, **kwargs)
  File "/Users/ahuang/repos/holoviews/holoviews/core/spaces.py", line 549, in __call__
    if not args and not kwargs and not any(kwarg_hash): return self.callable()
  File "/Users/ahuang/repos/holoviews/holoviews/util/__init__.py", line 1024, in dynamic_operation
    key, obj = resolve(key, kwargs)
  File "/Users/ahuang/repos/holoviews/holoviews/util/__init__.py", line 1013, in resolve
    return key, map_obj[key]
  File "/Users/ahuang/repos/holoviews/holoviews/core/spaces.py", line 1212, in __getitem__
    val = self._execute_callback(*tuple_key)
  File "/Users/ahuang/repos/holoviews/holoviews/core/spaces.py", line 979, in _execute_callback
    retval = self.callback(*args, **kwargs)
  File "/Users/ahuang/repos/holoviews/holoviews/core/spaces.py", line 549, in __call__
    if not args and not kwargs and not any(kwarg_hash): return self.callable()
  File "/Users/ahuang/repos/holoviews/holoviews/core/spaces.py", line 282, in dynamic_mul
    element = self[args]
  File "/Users/ahuang/repos/holoviews/holoviews/core/spaces.py", line 1212, in __getitem__
    val = self._execute_callback(*tuple_key)
  File "/Users/ahuang/repos/holoviews/holoviews/core/spaces.py", line 979, in _execute_callback
    retval = self.callback(*args, **kwargs)
  File "/Users/ahuang/repos/holoviews/holoviews/core/spaces.py", line 549, in __call__
    if not args and not kwargs and not any(kwarg_hash): return self.callable()
  File "/Users/ahuang/repos/holoviews/holoviews/core/spaces.py", line 204, in dynamic_mul
    other_el = other.select(HoloMap, **key_map) if other.kdims else other[()]
  File "/Users/ahuang/repos/holoviews/holoviews/core/spaces.py", line 1212, in __getitem__
    val = self._execute_callback(*tuple_key)
  File "/Users/ahuang/repos/holoviews/holoviews/core/spaces.py", line 979, in _execute_callback
    retval = self.callback(*args, **kwargs)
  File "/Users/ahuang/repos/holoviews/holoviews/core/spaces.py", line 579, in __call__
    ret = self.callable(*args, **kwargs)
  File "/Users/ahuang/repos/holoviews/holoviews/util/__init__.py", line 1025, in dynamic_operation
    return apply(obj, *key, **kwargs)
  File "/Users/ahuang/repos/holoviews/holoviews/util/__init__.py", line 1017, in apply
    processed = self._process(element, key, kwargs)
  File "/Users/ahuang/repos/holoviews/holoviews/util/__init__.py", line 999, in _process
    return self.p.operation.process_element(element, key, **kwargs)
  File "/Users/ahuang/repos/holoviews/holoviews/core/operation.py", line 194, in process_element
    return self._apply(element, key)
  File "/Users/ahuang/repos/holoviews/holoviews/core/operation.py", line 141, in _apply
    ret = self._process(element, key)
  File "/Users/ahuang/repos/holoviews/holoviews/operation/datashader.py", line 1877, in _process
    val = raster[x-xdelta:x+xdelta, y-ydelta:y+ydelta].reduce(function=np.nansum)
  File "/Users/ahuang/repos/holoviews/holoviews/core/data/__init__.py", line 711, in __getitem__
    data = self.select(**selection)
  File "/Users/ahuang/repos/holoviews/holoviews/core/data/__init__.py", line 195, in pipelined_fn
    result = method_fn(*args, **kwargs)
  File "/Users/ahuang/repos/holoviews/holoviews/element/raster.py", line 451, in select
    return self.clone(data, xdensity=self.xdensity, datatype=datatype,
  File "/Users/ahuang/miniconda3/envs/holoviews/lib/python3.10/site-packages/geoviews/element/geo.py", line 118, in clone
    return super().clone(data, shared_data, new_type,
  File "/Users/ahuang/repos/holoviews/holoviews/element/raster.py", line 398, in clone
    return super().clone(data, shared_data, new_type, link,
  File "/Users/ahuang/repos/holoviews/holoviews/core/data/__init__.py", line 1193, in clone
    return super().clone(data, shared_data, new_type, *args, **overrides)
  File "/Users/ahuang/repos/holoviews/holoviews/core/dimension.py", line 564, in clone
    return clone_type(data, *args, **{k:v for k,v in settings.items()
  File "/Users/ahuang/miniconda3/envs/holoviews/lib/python3.10/site-packages/geoviews/element/geo.py", line 111, in __init__
    super().__init__(data, kdims=kdims, vdims=vdims, **kwargs)
  File "/Users/ahuang/repos/holoviews/holoviews/element/raster.py", line 313, in __init__
    self._validate(data_bounds, supplied_bounds)
  File "/Users/ahuang/repos/holoviews/holoviews/element/raster.py", line 379, in _validate
    raise ValueError('Supplied Image bounds do not match the coordinates defined '
ValueError: Supplied Image bounds do not match the coordinates defined in the data. Bounds only have to be declared if no coordinates are supplied, otherwise they must match the data. To change the displayed extents set the range on the x- and y-dimensions.

@ahuang11
Copy link
Collaborator

ahuang11 commented Aug 1, 2024

Interestingly, now I get

WARNING:param.dynamic_operation: Callable raised "OverflowError('Python integer -7139923517 out of bounds for int32')".
Invoked as dynamic_operation(x=974524.1221008855, y=np.float64(5828555.296092956))
WARNING:param.dynamic_operation: Callable raised "OverflowError('Python integer -7139923517 out of bounds for int32')".
Invoked as dynamic_operation(x=974524.1221008855, y=np.float64(5828555.296092956))
Traceback (most recent call last):
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/plotting/util.py", line 293, in get_plot_frame
    return map_obj[key]
           ~~~~~~~^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/core/spaces.py", line 1216, in __getitem__
    val = self._execute_callback(*tuple_key)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/core/spaces.py", line 983, in _execute_callback
    retval = self.callback(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/core/spaces.py", line 552, in __call__
    return self.callable()
           ^^^^^^^^^^^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/util/__init__.py", line 1038, in dynamic_operation
    key, obj = resolve(key, kwargs)
               ^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/util/__init__.py", line 1027, in resolve
    return key, map_obj[key]
                ~~~~~~~^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/core/spaces.py", line 1216, in __getitem__
    val = self._execute_callback(*tuple_key)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/core/spaces.py", line 983, in _execute_callback
    retval = self.callback(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/core/spaces.py", line 552, in __call__
    return self.callable()
           ^^^^^^^^^^^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/core/spaces.py", line 202, in dynamic_mul
    other_el = other.select(HoloMap, **key_map) if other.kdims else other[()]
                                                                    ~~~~~^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/core/spaces.py", line 1216, in __getitem__
    val = self._execute_callback(*tuple_key)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/core/spaces.py", line 983, in _execute_callback
    retval = self.callback(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/core/spaces.py", line 581, in __call__
    ret = self.callable(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/util/__init__.py", line 1038, in dynamic_operation
    key, obj = resolve(key, kwargs)
               ^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/util/__init__.py", line 1027, in resolve
    return key, map_obj[key]
                ~~~~~~~^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/core/spaces.py", line 1216, in __getitem__
    val = self._execute_callback(*tuple_key)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/core/spaces.py", line 983, in _execute_callback
    retval = self.callback(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/core/spaces.py", line 581, in __call__
    ret = self.callable(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/util/__init__.py", line 1039, in dynamic_operation
    return apply(obj, *key, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/util/__init__.py", line 1031, in apply
    processed = self._process(element, key, kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/util/__init__.py", line 1013, in _process
    return self.p.operation.process_element(element, key, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/core/operation.py", line 194, in process_element
    return self._apply(element, key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/core/operation.py", line 141, in _apply
    ret = self._process(element, key)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/operation/datashader.py", line 1917, in _process
    val = raster[x-xdelta:x+xdelta, y-ydelta:y+ydelta].reduce(function=np.nansum)
          ~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/core/data/__init__.py", line 715, in __getitem__
    data = self.select(**selection)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/core/data/__init__.py", line 196, in pipelined_fn
    result = method_fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/element/raster.py", line 429, in select
    bounds = compute_slice_bounds(coords, self, shape[:2])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/element/util.py", line 66, in compute_slice_bounds
    slc = Slice(bounds, scs)
          ^^^^^^^^^^^^^^^^^^
  File "/Users/ahuang/miniconda3/envs/geoviews/lib/python3.12/site-packages/holoviews/core/sheetcoords.py", line 368, in __new__
    a = np.asarray(slicespec, dtype=np.int32).view(cls)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OverflowError: Python integer -7139923517 out of bounds for int32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants