Skip to content

Commit 74f1d41

Browse files
committed
🍵 add _grid_str to grid tests
1 parent d6ac0f6 commit 74f1d41

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

tests/test_figure_resampler.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -948,54 +948,74 @@ def test_fr_object_binary_data():
948948

949949

950950
def test_fr_copy_grid():
951+
# Checks whether _grid_ref and _grid_str are correctly maintained
952+
951953
f = make_subplots(rows=2, cols=1)
952954
f.add_scatter(y=np.arange(2_000), row=1, col=1)
953955
f.add_scatter(y=np.arange(2_000), row=2, col=1)
954956

955957
## go.Figure
956958
assert isinstance(f, go.Figure)
957959
assert f._grid_ref is not None
960+
assert f._grid_str is not None
958961
fr = FigureResampler(f)
959962
assert fr._grid_ref is not None
960963
assert fr._grid_ref == f._grid_ref
964+
assert fr._grid_str is not None
965+
assert fr._grid_str == f._grid_str
961966

962967
## go.FigureWidget
963968
fw = go.FigureWidget(f)
964969
assert fw._grid_ref is not None
970+
assert fw._grid_str is not None
965971
assert isinstance(fw, go.FigureWidget)
966972
fr = FigureResampler(fw)
967973
assert fr._grid_ref is not None
968974
assert fr._grid_ref == fw._grid_ref
975+
assert fr._grid_str is not None
976+
assert fr._grid_str == fw._grid_str
969977

970978
## FigureResampler
971979
fr_ = FigureResampler(f)
972980
assert fr_._grid_ref is not None
981+
assert fr_._grid_str is not None
973982
assert isinstance(fr_, FigureResampler)
974983
fr = FigureResampler(fr_)
975984
assert fr._grid_ref is not None
976985
assert fr._grid_ref == fr_._grid_ref
986+
assert fr._grid_str is not None
987+
assert fr._grid_str == fr_._grid_str
977988

978989
## FigureWidgetResampler
979990
from plotly_resampler import FigureWidgetResampler
980991
fwr = FigureWidgetResampler(f)
981992
assert fwr._grid_ref is not None
993+
assert fwr._grid_str is not None
982994
assert isinstance(fwr, FigureWidgetResampler)
983995
fr = FigureResampler(fwr)
984996
assert fr._grid_ref is not None
985997
assert fr._grid_ref == fwr._grid_ref
998+
assert fr._grid_str is not None
999+
assert fr._grid_str == fwr._grid_str
9861000

987-
## dict (with no _grid_ref)
1001+
## dict (with no _grid_ref & no _grid_str)
9881002
f_dict = f.to_dict()
9891003
assert isinstance(f_dict, dict)
9901004
assert f_dict.get("_grid_ref") is None
1005+
assert f_dict.get("_grid_str") is None
9911006
fr = FigureResampler(f_dict)
9921007
assert fr._grid_ref is f_dict.get("_grid_ref") # both are None
1008+
assert fr._grid_str is f_dict.get("_grid_str") # both are None
9931009

994-
## dict (with _grid_ref)
1010+
## dict (with _grid_ref & _grid_str)
9951011
f_dict = f.to_dict()
9961012
f_dict["_grid_ref"] = f._grid_ref
1013+
f_dict["_grid_str"] = f._grid_str
9971014
assert isinstance(f_dict, dict)
9981015
assert f_dict.get("_grid_ref") is not None
1016+
assert f_dict.get("_grid_str") is not None
9991017
fr = FigureResampler(f_dict)
10001018
assert fr._grid_ref is not None
10011019
assert fr._grid_ref == f_dict.get("_grid_ref")
1020+
assert fr._grid_str is not None
1021+
assert fr._grid_str == f_dict.get("_grid_str")

tests/test_figurewidget_resampler.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,54 +1819,73 @@ def test_fwr_object_binary_data():
18191819

18201820

18211821
def test_fwr_copy_grid():
1822+
# Checks whether _grid_ref and _grid_str are correctly maintained
1823+
18221824
f = make_subplots(rows=2, cols=1)
18231825
f.add_scatter(y=np.arange(2_000), row=1, col=1)
18241826
f.add_scatter(y=np.arange(2_000), row=2, col=1)
18251827

18261828
## go.Figure
18271829
assert isinstance(f, go.Figure)
18281830
assert f._grid_ref is not None
1831+
assert f._grid_str is not None
18291832
fwr = FigureWidgetResampler(f)
18301833
assert fwr._grid_ref is not None
18311834
assert fwr._grid_ref == f._grid_ref
1835+
assert fwr._grid_str is not None
1836+
assert fwr._grid_str == f._grid_str
18321837

18331838
## go.FigureWidget
18341839
fw = go.FigureWidget(f)
18351840
assert fw._grid_ref is not None
1841+
assert fw._grid_str is not None
18361842
assert isinstance(fw, go.FigureWidget)
18371843
fwr = FigureWidgetResampler(fw)
18381844
assert fwr._grid_ref is not None
18391845
assert fwr._grid_ref == fw._grid_ref
1846+
assert fwr._grid_str is not None
1847+
assert fwr._grid_str == fw._grid_str
18401848

18411849
## FigureWidgetResampler
18421850
fwr_ = FigureWidgetResampler(f)
18431851
assert fwr_._grid_ref is not None
1852+
assert fwr_._grid_str is not None
18441853
assert isinstance(fwr_, FigureWidgetResampler)
18451854
fwr = FigureWidgetResampler(fwr_)
18461855
assert fwr._grid_ref is not None
18471856
assert fwr._grid_ref == fwr_._grid_ref
1857+
assert fwr._grid_str is not None
1858+
assert fwr._grid_str == fwr_._grid_str
18481859

18491860
## FigureResampler
18501861
from plotly_resampler import FigureResampler
18511862
fr = FigureResampler(f)
18521863
assert fr._grid_ref is not None
1864+
assert fr._grid_str is not None
18531865
assert isinstance(fr, FigureResampler)
18541866
fwr = FigureWidgetResampler(fr)
18551867
assert fwr._grid_ref is not None
18561868
assert fwr._grid_ref == fr._grid_ref
1869+
assert fwr._grid_str is not None
1870+
assert fwr._grid_str == fr._grid_str
18571871

1858-
## dict (with no _grid_ref)
1872+
## dict (with no _grid_ref & no _grid_str)
18591873
f_dict = f.to_dict()
18601874
assert isinstance(f_dict, dict)
18611875
assert f_dict.get("_grid_ref") is None
1876+
assert f_dict.get("_grid_str") is None
18621877
fwr = FigureWidgetResampler(f_dict)
18631878
assert fwr._grid_ref is f_dict.get("_grid_ref") # both are None
1879+
assert fwr._grid_str is f_dict.get("_grid_str") # both are None
18641880

1865-
## dict (with _grid_ref)
1881+
## dict (with _grid_ref & _grid_str)
18661882
f_dict = f.to_dict()
18671883
f_dict["_grid_ref"] = f._grid_ref
1884+
f_dict["_grid_str"] = f._grid_str
18681885
assert isinstance(f_dict, dict)
18691886
assert f_dict.get("_grid_ref") is not None
18701887
fwr = FigureWidgetResampler(f_dict)
18711888
assert fwr._grid_ref is not None
18721889
assert fwr._grid_ref == f_dict.get("_grid_ref")
1890+
assert fwr._grid_str is not None
1891+
assert fwr._grid_str == f_dict.get("_grid_str")

0 commit comments

Comments
 (0)