Skip to content

Commit 3420d9e

Browse files
committed
Update for Clean Code
Update for Clean Code - move 'import' to the top - convert to list comprehension
1 parent e0b184c commit 3420d9e

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

python/variableCommand.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import numpy as _vp_np
2+
import random as _vp_rd
13
"""
24
Search Variables
35
"""
@@ -77,8 +79,6 @@ def _vp_get_profiling_list():
7779

7880
return result
7981

80-
import numpy as _vp_np
81-
import random as _vp_rd
8282
def _vp_sample(data, sample_cnt):
8383
"""
8484
Sampling data
@@ -94,16 +94,13 @@ def _vp_sample(data, sample_cnt):
9494
return data[_vp_np.random.choice(data.shape[0], sample_cnt, replace=False)]
9595
elif dataType == 'list':
9696
return _vp_rd.choices(data, k=sample_cnt)
97+
9798
return data
9899

99100
def _vp_check_module_loaded(fname_list):
100101
"""
101102
Check if this module is loaded
102103
"""
103-
result = []
104-
for fname in fname_list:
105-
if fname in globals():
106-
result.append(True)
107-
else:
108-
result.append(False)
104+
result = [True if fname in globals() else False for fname in fname_list]
105+
109106
return result

0 commit comments

Comments
 (0)