Skip to content

Commit ddbc3f1

Browse files
committed
Remove px tests (duplicates)
1 parent 4932cdb commit ddbc3f1

File tree

1 file changed

+38
-41
lines changed

1 file changed

+38
-41
lines changed

packages/python/plotly/plotly/tests/test_optional/test_px/test_px_input.py

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import unittest.mock as mock
88
from plotly.express._core import build_dataframe
99
from pandas.testing import assert_frame_equal
10+
from plotly.tests.b64 import b64, _b64
1011
import sys
1112
import warnings
1213

@@ -28,8 +29,9 @@ def add_interchange_module_for_old_pandas():
2829

2930
def test_numpy():
3031
fig = px.scatter(x=[1, 2, 3], y=[2, 3, 4], color=[1, 3, 9])
31-
assert np.all(fig.data[0].x == np.array([1, 2, 3]))
32-
assert np.all(fig.data[0].y == np.array([2, 3, 4]))
32+
33+
assert np.all(fig.data[0].x == b64(np.array([1, 2, 3])))
34+
assert np.all(fig.data[0].y == b64(np.array([2, 3, 4])))
3335
assert np.all(fig.data[0].marker.color == np.array([1, 3, 9]))
3436

3537

@@ -101,16 +103,16 @@ def test_several_dataframes():
101103
df = pd.DataFrame(dict(x=[0, 1], y=[3, 4]))
102104
df2 = pd.DataFrame(dict(x=[3, 5], y=[23, 24]))
103105
fig = px.scatter(x=df.y, y=df2.y)
104-
assert np.all(fig.data[0].x == np.array([3, 4]))
105-
assert np.all(fig.data[0].y == np.array([23, 24]))
106+
assert np.all(fig.data[0].x == b64(np.array([3, 4])))
107+
assert np.all(fig.data[0].y == b64(np.array([23, 24])))
106108
assert fig.data[0].hovertemplate == "x=%{x}<br>y=%{y}<extra></extra>"
107109

108110
df = pd.DataFrame(dict(x=[0, 1], y=[3, 4]))
109111
df2 = pd.DataFrame(dict(x=[3, 5], y=[23, 24]))
110112
df3 = pd.DataFrame(dict(y=[0.1, 0.2]))
111113
fig = px.scatter(x=df.y, y=df2.y, size=df3.y)
112-
assert np.all(fig.data[0].x == np.array([3, 4]))
113-
assert np.all(fig.data[0].y == np.array([23, 24]))
114+
assert np.all(fig.data[0].x == b64(np.array([3, 4])))
115+
assert np.all(fig.data[0].y == b64(np.array([23, 24])))
114116
assert (
115117
fig.data[0].hovertemplate
116118
== "x=%{x}<br>y=%{y}<br>size=%{marker.size}<extra></extra>"
@@ -120,8 +122,8 @@ def test_several_dataframes():
120122
df2 = pd.DataFrame(dict(x=[3, 5], y=[23, 24]))
121123
df3 = pd.DataFrame(dict(y=[0.1, 0.2]))
122124
fig = px.scatter(x=df.y, y=df2.y, hover_data=[df3.y])
123-
assert np.all(fig.data[0].x == np.array([3, 4]))
124-
assert np.all(fig.data[0].y == np.array([23, 24]))
125+
assert np.all(fig.data[0].x == b64(np.array([3, 4])))
126+
assert np.all(fig.data[0].y == b64(np.array([23, 24])))
125127
assert (
126128
fig.data[0].hovertemplate
127129
== "x=%{x}<br>y=%{y}<br>hover_data_0=%{customdata[0]}<extra></extra>"
@@ -131,8 +133,8 @@ def test_several_dataframes():
131133
def test_name_heuristics():
132134
df = pd.DataFrame(dict(x=[0, 1], y=[3, 4], z=[0.1, 0.2]))
133135
fig = px.scatter(df, x=df.y, y=df.x, size=df.y)
134-
assert np.all(fig.data[0].x == np.array([3, 4]))
135-
assert np.all(fig.data[0].y == np.array([0, 1]))
136+
assert np.all(fig.data[0].x == b64(np.array([3, 4])))
137+
assert np.all(fig.data[0].y == b64(np.array([0, 1])))
136138
assert fig.data[0].hovertemplate == "y=%{marker.size}<br>x=%{y}<extra></extra>"
137139

138140

@@ -405,27 +407,27 @@ def test_splom_case():
405407
assert len(fig.data[0].dimensions) == len(iris.columns)
406408
dic = {"a": [1, 2, 3], "b": [4, 5, 6], "c": [7, 8, 9]}
407409
fig = px.scatter_matrix(dic)
408-
assert np.all(fig.data[0].dimensions[0].values == np.array(dic["a"]))
410+
assert np.all(fig.data[0].dimensions[0].values == b64(np.array(dic["a"])))
409411
ar = np.arange(9).reshape((3, 3))
410412
fig = px.scatter_matrix(ar)
411-
assert np.all(fig.data[0].dimensions[0].values == ar[:, 0])
413+
assert np.all(fig.data[0].dimensions[0].values == b64(ar[:, 0]))
412414

413415

414416
def test_int_col_names():
415417
# DataFrame with int column names
416418
lengths = pd.DataFrame(np.random.random(100))
417419
fig = px.histogram(lengths, x=0)
418-
assert np.all(np.array(lengths).flatten() == fig.data[0].x)
420+
assert np.all(b64(np.array(lengths).flatten()) == fig.data[0].x)
419421
# Numpy array
420422
ar = np.arange(100).reshape((10, 10))
421423
fig = px.scatter(ar, x=2, y=8)
422-
assert np.all(fig.data[0].x == ar[:, 2])
424+
assert np.all(fig.data[0].x == b64(ar[:, 2]))
423425

424426

425427
def test_data_frame_from_dict():
426428
fig = px.scatter({"time": [0, 1], "money": [1, 2]}, x="time", y="money")
427429
assert fig.data[0].hovertemplate == "time=%{x}<br>money=%{y}<extra></extra>"
428-
assert np.all(fig.data[0].x == [0, 1])
430+
assert np.all(fig.data[0].x == _b64([0, 1]))
429431

430432

431433
def test_arguments_not_modified():
@@ -489,13 +491,11 @@ def test_identity_map():
489491

490492
def test_constants():
491493
fig = px.scatter(x=px.Constant(1), y=[1, 2])
492-
assert fig.data[0].x[0] == 1
493-
assert fig.data[0].x[1] == 1
494+
assert fig.data[0].x == _b64([1, 1])
494495
assert "x=" in fig.data[0].hovertemplate
495496

496497
fig = px.scatter(x=px.Constant(1, label="time"), y=[1, 2])
497-
assert fig.data[0].x[0] == 1
498-
assert fig.data[0].x[1] == 1
498+
assert fig.data[0].x == _b64([1, 1])
499499
assert "x=" not in fig.data[0].hovertemplate
500500
assert "time=" in fig.data[0].hovertemplate
501501

@@ -519,15 +519,12 @@ def test_constants():
519519

520520
def test_ranges():
521521
fig = px.scatter(x=px.Range(), y=[1, 2], hover_data=[px.Range()])
522-
assert fig.data[0].x[0] == 0
523-
assert fig.data[0].x[1] == 1
524-
assert fig.data[0].customdata[0][0] == 0
525-
assert fig.data[0].customdata[1][0] == 1
522+
assert fig.data[0].x == _b64([0, 1])
523+
assert fig.data[0].customdata == _b64([[0], [1]])
526524
assert "x=" in fig.data[0].hovertemplate
527525

528526
fig = px.scatter(x=px.Range(label="time"), y=[1, 2])
529-
assert fig.data[0].x[0] == 0
530-
assert fig.data[0].x[1] == 1
527+
assert fig.data[0].x == _b64([0, 1])
531528
assert "x=" not in fig.data[0].hovertemplate
532529
assert "time=" in fig.data[0].hovertemplate
533530

@@ -617,55 +614,55 @@ def test_x_or_y(fn):
617614
categorical_df = pd.DataFrame(dict(col=categorical), index=index)
618615

619616
fig = fn(x=numerical)
620-
assert list(fig.data[0].x) == numerical
621-
assert list(fig.data[0].y) == range_4
617+
assert fig.data[0].x == _b64(numerical)
618+
assert fig.data[0].y == _b64(range_4)
622619
assert fig.data[0].orientation == "h"
623620
fig = fn(y=numerical)
624-
assert list(fig.data[0].x) == range_4
625-
assert list(fig.data[0].y) == numerical
621+
assert fig.data[0].x == _b64(range_4)
622+
assert fig.data[0].y == _b64(numerical)
626623
assert fig.data[0].orientation == "v"
627624
fig = fn(numerical_df, x="col")
628-
assert list(fig.data[0].x) == numerical
629-
assert list(fig.data[0].y) == index
625+
assert fig.data[0].x == _b64(numerical)
626+
assert fig.data[0].y == _b64(index)
630627
assert fig.data[0].orientation == "h"
631628
fig = fn(numerical_df, y="col")
632-
assert list(fig.data[0].x) == index
633-
assert list(fig.data[0].y) == numerical
629+
assert fig.data[0].x == _b64(index)
630+
assert fig.data[0].y == _b64(numerical)
634631
assert fig.data[0].orientation == "v"
635632

636633
if fn != px.bar:
637634
fig = fn(x=categorical)
638635
assert list(fig.data[0].x) == categorical
639-
assert list(fig.data[0].y) == range_4
636+
assert fig.data[0].y == _b64(range_4)
640637
assert fig.data[0].orientation == "h"
641638
fig = fn(y=categorical)
642-
assert list(fig.data[0].x) == range_4
639+
assert fig.data[0].x == _b64(range_4)
643640
assert list(fig.data[0].y) == categorical
644641
assert fig.data[0].orientation == "v"
645642
fig = fn(categorical_df, x="col")
646643
assert list(fig.data[0].x) == categorical
647-
assert list(fig.data[0].y) == index
644+
assert fig.data[0].y == _b64(index)
648645
assert fig.data[0].orientation == "h"
649646
fig = fn(categorical_df, y="col")
650-
assert list(fig.data[0].x) == index
647+
assert fig.data[0].x == _b64(index)
651648
assert list(fig.data[0].y) == categorical
652649
assert fig.data[0].orientation == "v"
653650

654651
else:
655652
fig = fn(x=categorical)
656653
assert list(fig.data[0].x) == categorical
657-
assert list(fig.data[0].y) == constant
654+
assert fig.data[0].y == _b64(constant)
658655
assert fig.data[0].orientation == "v"
659656
fig = fn(y=categorical)
660-
assert list(fig.data[0].x) == constant
657+
assert fig.data[0].x == _b64(constant)
661658
assert list(fig.data[0].y) == categorical
662659
assert fig.data[0].orientation == "h"
663660
fig = fn(categorical_df, x="col")
664661
assert list(fig.data[0].x) == categorical
665-
assert list(fig.data[0].y) == constant
662+
assert fig.data[0].y == _b64(constant)
666663
assert fig.data[0].orientation == "v"
667664
fig = fn(categorical_df, y="col")
668-
assert list(fig.data[0].x) == constant
665+
assert fig.data[0].x == _b64(constant)
669666
assert list(fig.data[0].y) == categorical
670667
assert fig.data[0].orientation == "h"
671668

0 commit comments

Comments
 (0)