浏览代码

starpupy: cope with missing numpy module

Samuel Thibault 4 年之前
父节点
当前提交
adb04e69b2
共有 1 个文件被更改,包括 8 次插入4 次删除
  1. 8 4
      starpupy/src/joblib.py

+ 8 - 4
starpupy/src/joblib.py

@@ -1,6 +1,6 @@
 # StarPU --- Runtime system for heterogeneous multicore architectures.
 #
-# Copyright (C) 2020       Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
+# Copyright (C) 2020-2021       Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
 #
 # StarPU is free software; you can redistribute it and/or modify
 # it under the terms of the GNU Lesser General Public License as published by
@@ -24,7 +24,11 @@ import starpu
 import asyncio
 import math
 import functools
-import numpy as np
+try:
+    import numpy as np
+    has_numpy=True
+except:
+    has_numpy=False
 import inspect
 import threading
 
@@ -113,7 +117,7 @@ def future_generator(iterable, n_jobs, dict_task):
 		for i in range(len(args)):
 			args_split.append([])
 			# if the array is an numpy array
-			if type(args[i]) is np.ndarray:
+			if has_numpy and type(args[i]) is np.ndarray:
 				# one-dimension matrix
 				if args[i].ndim==1:
 					# split numpy array
@@ -138,7 +142,7 @@ def future_generator(iterable, n_jobs, dict_task):
 			L_args=[]
 			sizebase=0
 			for j in range(len(args)):
-				if type(args[j]) is np.ndarray or isinstance(args[j],types.GeneratorType):
+				if (has_numpy and type(args[j]) is np.ndarray) or isinstance(args[j],types.GeneratorType):
 					L_args.append(args_split[j][i])
 					if sizebase==0:
 						sizebase=len(args_split[j][i])