Skip to content

Commit ef51cce

Browse files
committed
Add back in other tests and update renderer default
1 parent addfd47 commit ef51cce

File tree

2 files changed

+61
-61
lines changed

2 files changed

+61
-61
lines changed

.circleci/config.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,19 @@ commands:
5252
cd packages/python/plotly-geo
5353
. ../plotly/venv/bin/activate
5454
pip install -e .
55-
# - run:
56-
# name: Test core
57-
# command: |
58-
# cd packages/python/plotly
59-
# . venv/bin/activate
60-
# pytest plotly/tests/test_core
61-
# no_output_timeout: 20m
55+
- run:
56+
name: Test core
57+
command: |
58+
cd packages/python/plotly
59+
. venv/bin/activate
60+
pytest plotly/tests/test_core
61+
no_output_timeout: 20m
6262
- run:
6363
name: Test optional
6464
command: |
6565
cd packages/python/plotly
6666
. venv/bin/activate
67-
pytest plotly/tests/test_optional/test_graph_objs/test_performance.py -v -s
67+
pytest plotly/tests/test_optional
6868
no_output_timeout: 40m
6969
- run:
7070
name: Test utils
@@ -81,7 +81,7 @@ commands:
8181
pytest plotly/tests/test_io
8282
no_output_timeout: 20m
8383
- run:
84-
name: Test dependencdies not imported
84+
name: Test dependencies not imported
8585
command: |
8686
cd packages/python/plotly
8787
. venv/bin/activate
@@ -585,18 +585,18 @@ workflows:
585585

586586
build:
587587
jobs:
588-
# - python_38_core
589-
# - python_39_core
590-
# - python_310_core
591-
# - python_311_core
592-
# - python_312_core
588+
- python_38_core
589+
- python_39_core
590+
- python_310_core
591+
- python_311_core
592+
- python_312_core
593593
- python_38_optional
594594
- python_39_optional
595595
- python_310_optional
596596
- python_311_optional
597597
- python_312_optional
598-
# - python_39_pandas_2_optional
599-
# - python_38_orca
600-
# - python_39_percy
598+
- python_39_pandas_2_optional
599+
- python_38_orca
600+
- python_39_percy
601601
- build-doc
602602

packages/python/plotly/plotly/tests/test_optional/test_graph_objs/test_performance.py

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import pytest
66

77
np.random.seed(1)
8-
8+
pio.renderers.default = 'png'
99

1010
def test_performance_b64_scatter3d():
11-
N = 10000
11+
N = 50000
1212
print(pio.renderers)
1313

1414
x = np.random.randn(N)
@@ -34,7 +34,7 @@ def test_performance_b64_scatter3d():
3434
)
3535
]
3636
)
37-
fig.show(renderer="png", engine="kaleido")
37+
fig.show(engine="kaleido")
3838
list_time_elapsed = time.time() - list_start
3939

4040
# Test the performance with base64 arrays
@@ -51,63 +51,63 @@ def test_performance_b64_scatter3d():
5151
)
5252
]
5353
)
54-
fig.show(renderer="png", engine="kaleido")
54+
fig.show(engine="kaleido")
5555

5656
np_time_elapsed = time.time() - np_start
5757

5858
# np should be faster than lists
5959
assert (np_time_elapsed / list_time_elapsed) < 0.7
6060

6161

62-
# FLOAT_TEST_CASES = [
63-
# ("float32", 100000, 0.35), # dtype # difference threshold
64-
# ("float64", 100000, 0.4),
65-
# ]
62+
FLOAT_TEST_CASES = [
63+
("float32", 100000, 0.9), # dtype # difference threshold
64+
("float64", 100000, 0.9),
65+
]
6666

6767

68-
# @pytest.mark.parametrize("dtype, count, expected_size_difference", FLOAT_TEST_CASES)
69-
# def test_performance_b64_float(dtype, count, expected_size_difference):
70-
# np_arr_1 = np.random.random(count).astype(dtype)
71-
# np_arr_2 = np.random.random(count).astype(dtype)
72-
# list_1 = np_arr_1.tolist()
73-
# list_2 = np_arr_2.tolist()
68+
@pytest.mark.parametrize("dtype, count, expected_size_difference", FLOAT_TEST_CASES)
69+
def test_performance_b64_float(dtype, count, expected_size_difference):
70+
np_arr_1 = np.random.random(count).astype(dtype)
71+
np_arr_2 = np.random.random(count).astype(dtype)
72+
list_1 = np_arr_1.tolist()
73+
list_2 = np_arr_2.tolist()
7474

75-
# # Test the performance of the base64 arrays
76-
# np_start = time.time()
77-
# fig = go.Figure(data=[go.Scattergl(x=np_arr_1, y=np_arr_2)])
78-
# fig.show()
79-
# np_time_elapsed = time.time() - np_start
75+
# Test the performance of the base64 arrays
76+
np_start = time.time()
77+
fig = go.Figure(data=[go.Scattergl(x=np_arr_1, y=np_arr_2)])
78+
fig.show(engine="kaleido")
79+
np_time_elapsed = time.time() - np_start
8080

81-
# # Test the performance of the normal lists
82-
# list_start = time.time()
83-
# fig = go.Figure(data=[go.Scattergl(x=list_1, y=list_2)])
84-
# fig.show()
85-
# list_time_elapsed = time.time() - list_start
81+
# Test the performance of the normal lists
82+
list_start = time.time()
83+
fig = go.Figure(data=[go.Scattergl(x=list_1, y=list_2)])
84+
fig.show(engine="kaleido")
85+
list_time_elapsed = time.time() - list_start
8686

87-
# # np should be faster than lists
88-
# assert (np_time_elapsed / list_time_elapsed) < expected_size_difference
87+
# np should be faster than lists
88+
assert (np_time_elapsed / list_time_elapsed) < expected_size_difference
8989

9090

91-
# INT_SIZE_PERFORMANCE_TEST_CASES = [
92-
# ("uint8", 256, 10500, 30000),
93-
# ("uint32", 2**32, 10500, 100000),
94-
# ]
91+
INT_SIZE_PERFORMANCE_TEST_CASES = [
92+
("uint8", 256, 10500, 30000),
93+
("uint32", 2**32, 10500, 100000),
94+
]
9595

9696

97-
# @pytest.mark.parametrize(
98-
# "dtype, max_value, count, expected_size_difference", INT_SIZE_PERFORMANCE_TEST_CASES
99-
# )
100-
# def test_size_performance_b64_int(dtype, max_value, count, expected_size_difference):
101-
# np_arr_1 = (np.random.random(count) * max_value).astype(dtype)
102-
# np_arr_2 = (np.random.random(count) * max_value).astype(dtype)
97+
@pytest.mark.parametrize(
98+
"dtype, max_value, count, expected_size_difference", INT_SIZE_PERFORMANCE_TEST_CASES
99+
)
100+
def test_size_performance_b64_int(dtype, max_value, count, expected_size_difference):
101+
np_arr_1 = (np.random.random(count) * max_value).astype(dtype)
102+
np_arr_2 = (np.random.random(count) * max_value).astype(dtype)
103103

104-
# # Measure the size of figures with numpy arrays
105-
# fig_np = go.Scatter(x=np_arr_1, y=np_arr_2)
106-
# size_np = fig_np.to_json().__sizeof__()
104+
# Measure the size of figures with numpy arrays
105+
fig_np = go.Scatter(x=np_arr_1, y=np_arr_2)
106+
size_np = fig_np.to_json().__sizeof__()
107107

108-
# # Measure the size of the figure with normal python lists
109-
# fig_list = go.Scatter(x=np_arr_1.tolist(), y=np_arr_2.tolist())
110-
# size_list = fig_list.to_json().__sizeof__()
108+
# Measure the size of the figure with normal python lists
109+
fig_list = go.Scatter(x=np_arr_1.tolist(), y=np_arr_2.tolist())
110+
size_list = fig_list.to_json().__sizeof__()
111111

112-
# # np should be smaller than lists
113-
# assert size_list - size_np > expected_size_difference
112+
# np should be smaller than lists
113+
assert size_list - size_np > expected_size_difference

0 commit comments

Comments
 (0)