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

enh(bokeh): Inspect timeseries #6479

Merged
merged 3 commits into from
Mar 20, 2025
Merged

enh(bokeh): Inspect timeseries #6479

merged 3 commits into from
Mar 20, 2025

Conversation

hoxbro
Copy link
Member

@hoxbro hoxbro commented Dec 16, 2024

Disabling the overlay_aggregate fastpath when we have a selector. A bit of formatting in the applies as it was pretty complicated already.

Code
import itertools

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

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

hv.extension("bokeh")

num = 10000
seed = np.random.default_rng(1)


def y(val):
    y = seed.normal(0, 1, num).cumsum()
    if val == 1:
        y[num // 2 : num // 2 + num // 10] = np.nan
    return y + val * 100  # No overlap


dists = [
    pd.DataFrame(
        {
            "x": np.arange(num),
            "y": y(val),
            "val": val,
            "cat": cat,
        }
    )
    for val, cat in [
        (0, "c0"),
        (1, "c1"),
    ]
]

df = pd.concat(dists, ignore_index=True)
curves = hv.Curve(df).groupby("cat").opts(tools=["hover"])
overlay = curves.overlay()


def dynspread_datashade(*args, **kwargs):
    return dynspread(datashade(*args, **kwargs))


def dynspread_rasterize(*args, **kwargs):
    return dynspread(rasterize(*args, **kwargs))


def rasterize_linewidth(*args, **kwargs):
    return rasterize(*args, **dict(kwargs, line_width=10))


def datashade_linewidth(*args, **kwargs):
    return datashade(*args, **dict(kwargs, line_width=10))


ops = (
    rasterize,
    dynspread_rasterize,
    rasterize_linewidth,
    datashade,
    dynspread_datashade,
    datashade_linewidth,
)
aggs = (ds.count(self_intersect=False), ds.by("cat", ds.count(self_intersect=False)))
sels = (None, ds.min("val"))
combinations = itertools.product(ops, aggs, sels)
plots = []
for op, agg, sel in combinations:
    title = f"{op.__name__.replace('_','+')}(agg={type(agg).__name__}, sel={type(sel).__name__ if sel else None})"
    plot = op(overlay, aggregator=agg, selector=sel).opts(
        tools=["hover"], title=title, width=400, height=400
    )
    plots.append(plot)

pn.panel(hv.Layout(plots).cols(4).opts(shared_axes=False)).servable()

image

@hoxbro hoxbro changed the title Inspect timeseries enh: Inspect timeseries Dec 16, 2024
Copy link

codecov bot commented Dec 16, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.82%. Comparing base (02258ce) to head (c0c495a).
Report is 21 commits behind head on main.

Files with missing lines Patch % Lines
holoviews/operation/datashader.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6479      +/-   ##
==========================================
+ Coverage   88.79%   88.82%   +0.02%     
==========================================
  Files         323      324       +1     
  Lines       68940    68990      +50     
==========================================
+ Hits        61216    61278      +62     
+ Misses       7724     7712      -12     

☔ 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.

@hoxbro hoxbro changed the title enh: Inspect timeseries enh(bokeh): Inspect timeseries Dec 18, 2024
@hoxbro hoxbro marked this pull request as ready for review December 19, 2024 15:08
Base automatically changed from inspect to main February 20, 2025 09:56
Copy link
Member

@philippjfr philippjfr left a comment

Choose a reason for hiding this comment

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

Small comment, otherwise happy with this.

@hoxbro hoxbro enabled auto-merge (squash) March 20, 2025 09:53
@hoxbro hoxbro merged commit d029b23 into main Mar 20, 2025
14 checks passed
@hoxbro hoxbro deleted the inspect_ts branch March 20, 2025 10:19
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.

2 participants