@@ -20,44 +20,49 @@ 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 (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
- )])
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
+ )
31
35
fig .show ()
32
36
list_time_elapsed = time .time () - list_start
33
37
34
38
# Test the performance with base64 arrays
35
39
np_start = time .time ()
36
- fig = go .Figure (data = [go .Scatter3d (
37
- x = x ,
38
- y = y ,
39
- z = z ,
40
- marker = dict (color = c ),
41
- mode = "markers" ,
42
- opacity = 0.2 ,
43
- )])
40
+ fig = go .Figure (
41
+ data = [
42
+ go .Scatter3d (
43
+ x = x ,
44
+ y = y ,
45
+ z = z ,
46
+ marker = dict (color = c ),
47
+ mode = "markers" ,
48
+ opacity = 0.2 ,
49
+ )
50
+ ]
51
+ )
44
52
fig .show ()
45
53
np_time_elapsed = time .time () - np_start
46
54
47
55
# np should be faster than lists
48
56
assert (np_time_elapsed / list_time_elapsed ) < 0.5
49
57
58
+
50
59
FLOAT_TEST_CASES = [
51
- (
52
- "float32" , # dtype
53
- 0.45 # difference threshold
54
- ),
55
- (
56
- 'float64' ,
57
- 0.55
58
- )
60
+ ("float32" , 0.45 ), # dtype # difference threshold
61
+ ("float64" , 0.55 ),
59
62
]
60
- @pytest .mark .parametrize ('dtype, expected_size_difference' , FLOAT_TEST_CASES )
63
+
64
+
65
+ @pytest .mark .parametrize ("dtype, expected_size_difference" , FLOAT_TEST_CASES )
61
66
def test_performance_b64_float (dtype , expected_size_difference ):
62
67
np_arr_1 = np .random .random (10000 ).astype (dtype )
63
68
np_arr_2 = np .random .random (10000 ).astype (dtype )
@@ -81,18 +86,14 @@ def test_performance_b64_float(dtype, expected_size_difference):
81
86
82
87
83
88
INT_SIZE_PERFORMANCE_TEST_CASES = [
84
- (
85
- "uint8" , # dtype
86
- 256 , # max_val
87
- 400000 # difference threshold
88
- ),
89
- (
90
- 'uint32' ,
91
- 2 ** 32 ,
92
- 900000
93
- )
89
+ ("uint8" , 256 , 400000 ), # dtype # max_val # difference threshold
90
+ ("uint32" , 2 ** 32 , 900000 ),
94
91
]
95
- @pytest .mark .parametrize ('dtype, max_val, expected_size_difference' , INT_SIZE_PERFORMANCE_TEST_CASES )
92
+
93
+
94
+ @pytest .mark .parametrize (
95
+ "dtype, max_val, expected_size_difference" , INT_SIZE_PERFORMANCE_TEST_CASES
96
+ )
96
97
def test_size_performance_b64_int (dtype , max_val , expected_size_difference ):
97
98
np_arr_1 = (np .random .random (100000 ) * max_val ).astype (dtype )
98
99
np_arr_2 = (np .random .random (100000 ) * max_val ).astype (dtype )
0 commit comments