Skip to content

Commit 0b83ebd

Browse files
committed
Add back in max_value and parameterize the count
1 parent ddbc3f1 commit 0b83ebd

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

packages/python/plotly/plotly/tests/test_core/test_graph_objs/test_performance.py renamed to packages/python/plotly/plotly/tests/test_optional/test_graph_objs/test_performance.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,19 @@ def test_performance_b64_scatter3d():
5353
np_time_elapsed = time.time() - np_start
5454

5555
# np should be faster than lists
56-
assert (np_time_elapsed / list_time_elapsed) < 0.5
56+
assert (np_time_elapsed / list_time_elapsed) < 0.55
5757

5858

5959
FLOAT_TEST_CASES = [
60-
("float32", 0.45), # dtype # difference threshold
61-
("float64", 0.55),
60+
("float32", 100000, 0.45), # dtype # difference threshold
61+
("float64", 10000, 0.55),
6262
]
6363

6464

65-
@pytest.mark.parametrize("dtype, expected_size_difference", FLOAT_TEST_CASES)
66-
def test_performance_b64_float(dtype, expected_size_difference):
67-
np_arr_1 = np.random.random(10000).astype(dtype)
68-
np_arr_2 = np.random.random(10000).astype(dtype)
65+
@pytest.mark.parametrize("dtype, count, expected_size_difference", FLOAT_TEST_CASES)
66+
def test_performance_b64_float(dtype, count, expected_size_difference):
67+
np_arr_1 = np.random.random(count).astype(dtype)
68+
np_arr_2 = np.random.random(count).astype(dtype)
6969
list_1 = np_arr_1.tolist()
7070
list_2 = np_arr_2.tolist()
7171

@@ -86,17 +86,17 @@ def test_performance_b64_float(dtype, expected_size_difference):
8686

8787

8888
INT_SIZE_PERFORMANCE_TEST_CASES = [
89-
("uint8", 256, 400000), # dtype # max_val # difference threshold
90-
("uint32", 2**32, 900000),
89+
("uint8", 256, 100000, 30000),
90+
("uint32", 2**32, 100000, 100000),
9191
]
9292

9393

9494
@pytest.mark.parametrize(
95-
"dtype, max_val, expected_size_difference", INT_SIZE_PERFORMANCE_TEST_CASES
95+
"dtype, max_value, count, expected_size_difference", INT_SIZE_PERFORMANCE_TEST_CASES
9696
)
97-
def test_size_performance_b64_int(dtype, max_val, expected_size_difference):
98-
np_arr_1 = (np.random.random(100000) * max_val).astype(dtype)
99-
np_arr_2 = (np.random.random(100000) * max_val).astype(dtype)
97+
def test_size_performance_b64_int(dtype, max_value, count, expected_size_difference):
98+
np_arr_1 = (np.random.random(count) * max_value).astype(dtype)
99+
np_arr_2 = (np.random.random(count) * max_value).astype(dtype)
100100

101101
# Measure the size of figures with numpy arrays
102102
fig_np = go.Scatter(x=np_arr_1, y=np_arr_2)

0 commit comments

Comments
 (0)