Skip to content

Commit d77bead

Browse files
committed
Cleaner check for existence of modules
1 parent 0f38c8b commit d77bead

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

CLUEstering/CLUEstering.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,21 @@
1414
import pandas as pd
1515
from sklearn.datasets import make_blobs
1616
from sklearn.preprocessing import StandardScaler
17-
from os.path import dirname, join
17+
from os.path import dirname, exists, join
1818
path = dirname(__file__)
1919
import sys
2020
sys.path.insert(1, join(path, 'lib'))
2121
import CLUE_Convolutional_Kernels as clue_kernels
2222
import CLUE_CPU_Serial as cpu_serial
23-
tbb_found = False
24-
if len(glob(join(path, 'lib/CLUE_CPU_TBB*.so'))) != 0:
23+
tbb_found = exists(*glob(join(path, 'lib/CLUE_CPU_TBB*.so')))
24+
if tbb_found:
2525
import CLUE_CPU_TBB as cpu_tbb
26-
tbb_found = True
27-
cuda_found = False
28-
if len(glob(join(path, 'lib/CLUE_GPU_CUDA*.so'))) != 0:
26+
cuda_found = exists(*glob(join(path, 'lib/CLUE_CPU_TBB*.so')))
27+
if cuda_found:
2928
import CLUE_GPU_CUDA as gpu_cuda
30-
cuda_found = True
31-
hip_found = False
32-
if len(glob(join(path, 'lib/CLUE_GPU_HIP*.so'))) != 0:
29+
hip_found = exists(*glob(join(path, 'lib/CLUE_CPU_TBB*.so')))
30+
if hip_found:
3331
import CLUE_GPU_HIP as gpu_hip
34-
hip_found = True
3532

3633
def test_blobs(n_samples: int, n_dim: int , n_blobs: int = 4, mean: float = 0,
3734
sigma: float = 0.5, x_max: float = 30, y_max: float = 30) -> pd.DataFrame:

0 commit comments

Comments
 (0)