@@ -20,57 +20,67 @@ def test_performance_b64_scatter3d():
20
20
z_list = z .tolist ()
21
21
c_list = c .tolist ()
22
22
list_start = time .time ()
23
- fig = go .Figure (
24
- data = [
25
- go .Scatter3d (
26
- x = x_list ,
27
- y = y_list ,
28
- z = z_list ,
29
- marker = dict (color = c_list ),
30
- mode = "markers" ,
31
- opacity = 0.2 ,
32
- )
33
- ]
34
- )
23
+ fig = go .Figure (data = [go .Scatter3d (
24
+ x = x_list ,
25
+ y = y_list ,
26
+ z = z_list ,
27
+ marker = dict (color = c_list ),
28
+ mode = "markers" ,
29
+ opacity = 0.2 ,
30
+ )])
31
+ fig .show ()
35
32
list_time_elapsed = time .time () - list_start
36
33
37
34
# Test the performance with base64 arrays
38
35
np_start = time .time ()
39
- fig = go .Scatter3d (
36
+ fig = go .Figure ( data = [ go . Scatter3d (
40
37
x = x ,
41
38
y = y ,
42
39
z = z ,
43
40
marker = dict (color = c ),
44
41
mode = "markers" ,
45
42
opacity = 0.2 ,
46
- )
43
+ )])
44
+ fig .show ()
47
45
np_time_elapsed = time .time () - np_start
48
46
49
47
# np should be faster than lists
50
- assert (np_time_elapsed / list_time_elapsed ) < 0.005
51
-
48
+ assert (np_time_elapsed / list_time_elapsed ) < 0.5
52
49
53
- def test_performance_b64_float64 ():
54
- np_arr_1 = np .random .random (10000 )
55
- np_arr_2 = np .random .random (10000 )
50
+ FLOAT_TEST_CASES = [
51
+ (
52
+ "float32" , # dtype
53
+ 0.45 # difference threshold
54
+ ),
55
+ (
56
+ 'float64' ,
57
+ 0.55
58
+ )
59
+ ]
60
+ @pytest .mark .parametrize ('dtype, expected_size_difference' , FLOAT_TEST_CASES )
61
+ def test_performance_b64_float (dtype , expected_size_difference ):
62
+ np_arr_1 = np .random .random (10000 ).astype (dtype )
63
+ np_arr_2 = np .random .random (10000 ).astype (dtype )
56
64
list_1 = np_arr_1 .tolist ()
57
65
list_2 = np_arr_2 .tolist ()
58
66
59
67
# Test the performance of the base64 arrays
60
68
np_start = time .time ()
61
- fig = go .Scatter (x = np_arr_1 , y = np_arr_2 )
69
+ fig = go .Figure (data = [go .Scatter (x = np_arr_1 , y = np_arr_2 )])
70
+ fig .show ()
62
71
np_time_elapsed = time .time () - np_start
63
72
64
73
# Test the performance of the normal lists
65
74
list_start = time .time ()
66
- fig = go .Scatter (x = list_1 , y = list_2 )
75
+ fig = go .Figure (data = [go .Scatter (x = list_1 , y = list_2 )])
76
+ fig .show ()
67
77
list_time_elapsed = time .time () - list_start
68
78
69
79
# np should be faster than lists
70
- assert (np_time_elapsed / list_time_elapsed ) < 0.3
80
+ assert (np_time_elapsed / list_time_elapsed ) < expected_size_difference
71
81
72
82
73
- DTYPE_TEST_CASES = [
83
+ INT_SIZE_PERFORMANCE_TEST_CASES = [
74
84
(
75
85
"uint8" , # dtype
76
86
256 , # max_val
@@ -82,8 +92,8 @@ def test_performance_b64_float64():
82
92
900000
83
93
)
84
94
]
85
- @pytest .mark .parametrize ('dtype, max_val, expected_size_difference' , DTYPE_TEST_CASES )
86
- def test_size_performance_b64_uint8 (dtype , max_val , expected_size_difference ):
95
+ @pytest .mark .parametrize ('dtype, max_val, expected_size_difference' , INT_SIZE_PERFORMANCE_TEST_CASES )
96
+ def test_size_performance_b64_int (dtype , max_val , expected_size_difference ):
87
97
np_arr_1 = (np .random .random (100000 ) * max_val ).astype (dtype )
88
98
np_arr_2 = (np .random .random (100000 ) * max_val ).astype (dtype )
89
99
0 commit comments