Skip to content

Conversation

@hoxbro
Copy link
Member

@hoxbro hoxbro commented Nov 24, 2025

Resolves #6736
Resolves #6739

Mostly factoring out logic in aggregate to also use for geom_aggregate. Not sure if I like the new method name, but just wanted to push this before it was lost in a stash. Know at least one test is failing because of change of NdOverlay to ImageStack.

Summary

import datashader as ds

import holoviews as hv
from holoviews.operation.datashader import rasterize

hv.extension("bokeh")

rects = hv.Rectangles(
    [
        (0, 0, 1, 1, 128, 100, 200),
        (2, 3, 4, 6, 100, 50, 80),
        (0.5, 2, 1.5, 4, 20, 200, 120),
        (2, 1, 3.5, 2.5, 110, 40, 240),
    ],
    kdims=[
        hv.Dimension("x0"),
        hv.Dimension("y0"),
        hv.Dimension("x1"),
        hv.Dimension("y1"),
    ],
    vdims=[
        hv.Dimension("r"),
        hv.Dimension("g"),
        hv.Dimension("b"),
    ],
)
rasterize(
    rects,
    aggregator=ds.summary(
        r=ds.where(ds.max("x0"), "r"),
        g=ds.where(ds.max("x0"), "g"),
        b=ds.where(ds.max("x0"), "b"),
    ),
).opts(tools=["hover"])

Screencast.From.2025-11-24.19-06-59.mp4
Selector

import datashader as ds
import numpy as np
import pandas as pd

import holoviews as hv
from holoviews.operation.datashader import datashade, dynspread, rasterize

hv.extension("bokeh")

# Set default hover tools on various plot types
hv.opts.defaults(tools=["hover"])

rects = hv.Rectangles(
    [(0, 0, 1, 1), (2, 3, 4, 6), (0.5, 2, 1.5, 4), (2, 1, 3.5, 2.5)],
    kdims=[
        hv.Dimension("Time"),
        hv.Dimension("y0"),
        hv.Dimension("x1"),
        hv.Dimension("y1"),
    ],
)

rects = datashade(rects, aggregator=ds.count(), selector=ds.min("Time"))
rects.opts(hover_tooltips=["Time"])
rects

Screencast.From.2025-11-24.19-07-53.mp4
Simple

import datashader as ds

import holoviews as hv
from holoviews.operation.datashader import rasterize

hv.extension("bokeh")

rects = hv.Rectangles(
    [
        (0, 0, 1, 1, 128, 100, 200),
        (2, 3, 4, 6, 100, 50, 80),
        (0.5, 2, 1.5, 4, 20, 200, 120),
        (2, 1, 3.5, 2.5, 110, 40, 240),
    ],
    kdims=[
        hv.Dimension("x0"),
        hv.Dimension("y0"),
        hv.Dimension("x1"),
        hv.Dimension("y1"),
    ],
    vdims=[
        hv.Dimension("r"),
        hv.Dimension("g"),
        hv.Dimension("b"),
    ],
)
rasterize(rects, aggregator=ds.max("x0")).opts(tools=["hover"])

Screencast.From.2025-11-24.19-08-25.mp4

@hoxbro hoxbro changed the title enh: Support selector for geom_aggregator enh: Support selector and ds.summary for geom_aggregator Nov 24, 2025
@codecov
Copy link

codecov bot commented Nov 24, 2025

Codecov Report

❌ Patch coverage is 97.88732% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.21%. Comparing base (ec851b7) to head (8758382).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
holoviews/operation/datashader.py 97.08% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6743      +/-   ##
==========================================
+ Coverage   87.83%   89.21%   +1.37%     
==========================================
  Files         332      332              
  Lines       72010    72063      +53     
==========================================
+ Hits        63250    64291    +1041     
+ Misses       8760     7772     -988     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +845 to +851
if agg_state == AggState.AGG_BY:
params['vdims'] = list(map(str, agg.coords[agg_fn.column].data))
elif agg_state == AggState.AGG_SEL_BY:
params['vdims'] = [d for d in agg.data_vars if d not in agg.attrs["selector_columns"]]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is duplicated, but I think it is OK.

@hoxbro hoxbro force-pushed the enh_support_selector_for_geom_aggregate branch from f80227a to c7d6e9b Compare November 26, 2025 11:08
@hoxbro hoxbro force-pushed the enh_support_selector_for_geom_aggregate branch from b46191b to 54936b9 Compare November 27, 2025 09:37
@hoxbro hoxbro force-pushed the enh_support_selector_for_geom_aggregate branch from 54936b9 to e259826 Compare November 27, 2025 09:37
@hoxbro hoxbro marked this pull request as ready for review November 27, 2025 09:52
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

Successfully merging this pull request may close these issues.

rasterize() does not work with ds.summary() hover_tooltips does broken on datashader Rectangles

2 participants