Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arrayfire/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

try:
import pycuda.autoinit
except:
except ImportError:
pass

from .library import *
Expand Down
2 changes: 1 addition & 1 deletion arrayfire/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ def display(a, precision=4):
st = expr[0].find('(') + 1
en = expr[0].rfind(')')
name = expr[0][st:en]
except:
except IndexError:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This probably can’t happen at all, but I left it for now to be safe.)

pass

safe_call(backend.get().af_print_array_gen(name.encode('utf-8'),
Expand Down
20 changes: 12 additions & 8 deletions arrayfire/interop.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ def _cc_to_af_array(in_ptr, ndim, in_shape, in_dtype, is_device=False, copy = Tr

try:
import numpy as np
except ImportError:
AF_NUMPY_FOUND=False
else:
from numpy import ndarray as NumpyArray
from .data import reorder

Expand Down Expand Up @@ -112,11 +115,12 @@ def np_to_af_array(np_arr, copy=True):
return np_to_af_array(np_arr.copy())

from_ndarray = np_to_af_array
except:
AF_NUMPY_FOUND=False

try:
import pycuda.gpuarray
except ImportError:
AF_PYCUDA_FOUND=False
else:
from pycuda.gpuarray import GPUArray as CudaArray
AF_PYCUDA_FOUND=True

Expand Down Expand Up @@ -154,11 +158,12 @@ def pycuda_to_af_array(pycu_arr, copy=True):
return _cc_to_af_array(in_ptr, pycu_arr.ndim, in_shape, in_dtype, True, copy)
else:
return pycuda_to_af_array(pycu_arr.copy())
except:
AF_PYCUDA_FOUND=False

try:
from pyopencl.array import Array as OpenclArray
except ImportError:
AF_PYOPENCL_FOUND=False
else:
from .opencl import add_device_context as _add_device_context
from .opencl import set_device_context as _set_device_context
from .opencl import get_device_id as _get_device_id
Expand Down Expand Up @@ -221,11 +226,12 @@ def pyopencl_to_af_array(pycl_arr, copy=True):
return _cc_to_af_array(in_ptr, pycl_arr.ndim, in_shape, in_dtype, True, copy)
else:
return pyopencl_to_af_array(pycl_arr.copy())
except:
AF_PYOPENCL_FOUND=False

try:
import numba
except ImportError:
AF_NUMBA_FOUND=False
else:
from numba import cuda
NumbaCudaArray = cuda.cudadrv.devicearray.DeviceNDArray
AF_NUMBA_FOUND=True
Expand Down Expand Up @@ -264,8 +270,6 @@ def numba_to_af_array(nb_arr, copy=True):
return _cc_to_af_array(in_ptr, nb_arr.ndim, in_shape, in_dtype, True, copy)
else:
return numba_to_af_array(nb_arr.copy())
except:
AF_NUMBA_FOUND=False

def to_array(in_array, copy = True):
"""
Expand Down
10 changes: 5 additions & 5 deletions arrayfire/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
from enum import Enum as _Enum
def _Enum_Type(v):
return v
except:
except ImportError:
class _MetaEnum(type):
def __init__(cls, name, bases, attrs):
for attrname, attrvalue in attrs.iteritems():
Expand Down Expand Up @@ -417,15 +417,15 @@ def _setup():

try:
AF_PATH = os.environ['AF_PATH']
except:
except KeyError:
AF_PATH = None
pass

AF_SEARCH_PATH = AF_PATH

try:
CUDA_PATH = os.environ['CUDA_PATH']
except:
except KeyError:
CUDA_PATH= None
pass

Expand Down Expand Up @@ -534,7 +534,7 @@ def __init__(self):
for libname in libnames:
try:
ct.cdll.LoadLibrary(libname)
except:
except OSError:
pass

c_dim4 = c_dim_t*4
Expand All @@ -555,7 +555,7 @@ def __init__(self):
self.__name = __name
clib.af_release_array(out)
break;
except:
except OSError:
pass

if (self.__name is None):
Expand Down
2 changes: 1 addition & 1 deletion arrayfire/tests/simple/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def run(self, name_list=None, verbose=False):
self.print_log = ''
try:
test = self[key]
except:
except KeyError:
print(self.print_str % (key, "NOTFOUND"))
continue

Expand Down
2 changes: 1 addition & 1 deletion examples/benchmarks/bench_blas.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

try:
import numpy as np
except:
except ImportError:
np = None


Expand Down
4 changes: 2 additions & 2 deletions examples/benchmarks/bench_cg.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

try:
import numpy as np
except:
except ImportError:
np = None

try:
from scipy import sparse as sp
from scipy.sparse import linalg
except:
except ImportError:
sp = None


Expand Down
2 changes: 1 addition & 1 deletion examples/benchmarks/bench_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

try:
import numpy as np
except:
except ImportError:
np = None


Expand Down
2 changes: 1 addition & 1 deletion examples/benchmarks/monte_carlo_pi.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

try:
import numpy as np
except:
except ImportError:
np = None

#alias range / xrange because xrange is faster than range in python2
Expand Down