-
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* :plane: fix for #270 * ✨ add `customdata` to hf_data_container * 💪 adding tests * 💨 linting * 🙈 fix futurewarning * 🧹 formatting * 🙈 fix tests *✈️ ➡️ 🇧🇪 Autosize support (#273) *✈️ 🇧🇪 fix for #259 * 💨 linting * 💨 adding autosize support * ✨ updating action versions * 🙈 skip dtype test on window * 🙏 skip test --------- Co-authored-by: Jeroen Van Der Donckt <[email protected]>
- Loading branch information
Showing
7 changed files
with
456 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import numpy as np | ||
import pandas as pd | ||
import plotly.express as px | ||
|
||
from plotly_resampler import register_plotly_resampler, unregister_plotly_resampler | ||
|
||
|
||
def test_px_hoverlabel_figureResampler(): | ||
labels = list(range(0, 3)) | ||
N = 60_000 | ||
x = np.arange(N) | ||
y = np.random.normal(size=N) | ||
label = np.random.randint(low=labels[0], high=labels[-1] + 1, size=N).astype(str) | ||
description = np.random.randint(low=3, high=5, size=N) | ||
|
||
df = pd.DataFrame.from_dict( | ||
{"x": x, "y": y, "label": label, "description": description} | ||
) | ||
|
||
x_label = "x" | ||
y_label = "y" | ||
label_label = "label" | ||
df = df.sort_values(by=[x_label]) | ||
|
||
# Without resampler, shows correct hover data | ||
fig = px.scatter( | ||
df, | ||
x=x_label, | ||
y=y_label, | ||
color=label_label, | ||
title="Without resampler", | ||
hover_data=["description"], | ||
) | ||
|
||
# With resampler, shows incorrect hover data | ||
register_plotly_resampler(mode="auto", default_n_shown_samples=1000) | ||
fig2 = px.scatter( | ||
df, | ||
x=x_label, | ||
y=y_label, | ||
color=label_label, | ||
title="With resampler", | ||
hover_data=["description"], | ||
) | ||
|
||
# verify whether the selected has the same y and customdata as the original | ||
for idx in range(len(fig.data)): | ||
trc_orig = fig.data[idx] | ||
trc_res = fig2.data[idx] | ||
|
||
agg_indices = np.searchsorted(trc_orig["x"], trc_res["x"]).ravel() | ||
for k in ["customdata", "y"]: | ||
assert all(trc_orig[k].ravel()[agg_indices] == trc_res[k].ravel()) | ||
|
||
unregister_plotly_resampler() |