Skip to content

Commit 82ed5e9

Browse files
committed
🧹 extend tests
1 parent 3d8e3b5 commit 82ed5e9

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

tests/test_figure_resampler.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ def test_fr_object_hf_data(float_series):
885885
assert fig.data[0]["y"].dtype == "float64"
886886

887887

888-
def test_fwr_object_bool_data(bool_series):
888+
def test_fr_object_bool_data(bool_series):
889889
# First try with the original non-object bool series
890890
fig = FigureResampler()
891891
fig.add_trace({"name": "s0"}, hf_y=bool_series)
@@ -902,5 +902,28 @@ def test_fwr_object_bool_data(bool_series):
902902
assert bool_series_o.dtype == object
903903
assert len(fig.hf_data) == 1
904904
assert fig.hf_data[0]["y"].dtype == "bool"
905-
# plotly internally ocnverts this to object
905+
# plotly internally converts this to object
906906
assert fig.data[0]["y"].dtype == "object"
907+
908+
909+
def test_fr_object_binary_data():
910+
binary_series = np.array([0, 1]*20) # as this is << max_n_samples -> limit_to_view
911+
912+
# First try with the original non-object binary series
913+
fig = FigureResampler()
914+
fig.add_trace({"name": "s0"}, hf_y=binary_series, limit_to_view=True)
915+
assert len(fig.hf_data) == 1
916+
assert fig.hf_data[0]["y"].dtype == "int64"
917+
assert fig.data[0]["y"].dtype == "int64"
918+
assert np.all(fig.data[0]["y"] == binary_series)
919+
920+
# Now try with the object binary series
921+
binary_series_o = binary_series.astype(object)
922+
923+
fig = FigureResampler()
924+
fig.add_trace({"name": "s0"}, hf_y=binary_series_o, limit_to_view=True)
925+
assert binary_series_o.dtype == object
926+
assert len(fig.hf_data) == 1
927+
assert fig.hf_data[0]["y"].dtype == "int64"
928+
assert fig.data[0]["y"].dtype == "int64"
929+
assert np.all(fig.data[0]["y"] == binary_series)

tests/test_figurewidget_resampler.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,3 +1773,26 @@ def test_fwr_object_bool_data(bool_series):
17731773
assert fig.hf_data[0]["y"].dtype == "bool"
17741774
# plotly internally ocnverts this to object
17751775
assert fig.data[0]["y"].dtype == "object"
1776+
1777+
1778+
def test_fwr_object_binary_data():
1779+
binary_series = np.array([0, 1]*20) # as this is << max_n_samples -> limit_to_view
1780+
1781+
# First try with the original non-object binary series
1782+
fig = FigureWidgetResampler()
1783+
fig.add_trace({"name": "s0"}, hf_y=binary_series, limit_to_view=True)
1784+
assert len(fig.hf_data) == 1
1785+
assert fig.hf_data[0]["y"].dtype == "int64"
1786+
assert fig.data[0]["y"].dtype == "int64"
1787+
assert np.all(fig.data[0]["y"] == binary_series)
1788+
1789+
# Now try with the object binary series
1790+
binary_series_o = binary_series.astype(object)
1791+
1792+
fig = FigureWidgetResampler()
1793+
fig.add_trace({"name": "s0"}, hf_y=binary_series_o, limit_to_view=True)
1794+
assert binary_series_o.dtype == object
1795+
assert len(fig.hf_data) == 1
1796+
assert fig.hf_data[0]["y"].dtype == "int64"
1797+
assert fig.data[0]["y"].dtype == "int64"
1798+
assert np.all(fig.data[0]["y"] == binary_series)

0 commit comments

Comments
 (0)