Skip to content

Commit 392f8aa

Browse files
committed
♍ adding hf_data_copy tests
1 parent 59d753c commit 392f8aa

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

plotly_resampler/figure_resampler/figure_resampler_interface.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,6 @@ def _copy_hf_data(self, hf_data: dict, adjust_default_values: bool = False) -> d
10811081
The copied (& default values adjusted) output dict.
10821082
10831083
"""
1084-
# TODO: add pass by reference tests for this method
10851084
hf_data_cp = {
10861085
uid: {
10871086
k: hf_dict[k]

tests/test_figure_resampler.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,3 +839,23 @@ def test_fr_list_scatter_add_traces(float_series):
839839
)
840840
assert len(fr_fig.hf_data) == 4
841841
assert len(fr_fig.data) == 5
842+
843+
844+
def test_fr_copy_hf_data(float_series):
845+
fr_fig = FigureResampler(default_n_shown_samples=2000)
846+
traces: List[dict] = [
847+
go.Scattergl({"y": float_series.values + 2, "name": "sp2"}),
848+
go.Scatter({"y": float_series.values, "name": "s"}),
849+
]
850+
fr_fig.add_traces(tuple(traces))
851+
852+
hf_data_cp = FigureResampler()._copy_hf_data(fr_fig._hf_data)
853+
uid = list(hf_data_cp.keys())[0]
854+
855+
hf_data_cp[uid]["x"] = np.arange(1000)
856+
hf_data_cp[uid]["y"] = float_series[:1000]
857+
858+
assert len(fr_fig.hf_data[0]["x"]) == 10_000
859+
assert len(fr_fig.hf_data[0]["y"]) == 10_000
860+
assert len(fr_fig.hf_data[1]["x"]) == 10_000
861+
assert len(fr_fig.hf_data[1]["y"]) == 10_000

0 commit comments

Comments
 (0)