From cee9a661c84a3c776c22411677a373ef19e99b1e Mon Sep 17 00:00:00 2001 From: Michael Krayer Date: Fri, 13 Aug 2021 01:25:50 +0200 Subject: [PATCH] jit minmax is now slower than conventional: remove numba dependency --- field.py | 12 ++++-------- jit.py | 13 ------------- 2 files changed, 4 insertions(+), 21 deletions(-) delete mode 100644 jit.py diff --git a/field.py b/field.py index 82af5f9..45e11e1 100644 --- a/field.py +++ b/field.py @@ -893,19 +893,15 @@ class Features3d: # assert coords.ndim==2 and coords.shape[1]==3, "'coords' need to be provided as Nx3 array." from time import time from scipy import spatial - from .jit import minmax # pts = np.random.random((10000,3)) t = time() - # xmin = np.amin(self._points[self._faces[:,1:],0],axis=1) - # xmax = np.amax(self._points[self._faces[:,1:],0],axis=1) - # zmin = np.amin(self._points[self._faces[:,1:],2],axis=1) - # zmax = np.amax(self._points[self._faces[:,1:],2],axis=1) - # print(time()-t) - xmin,xmax = minmax(self._vertices[:,:,0]) - zmin,zmax = minmax(self._vertices[:,:,2]) + xmin = np.amin(self._vertices[:,:,0],axis=1) + xmax = np.amax(self._vertices[:,:,0],axis=1) + zmin = np.amin(self._vertices[:,:,2],axis=1) + zmax = np.amax(self._vertices[:,:,2],axis=1) print(time()-t) # print(xmin.shape,xmin2.shape) # print(np.all(np.isclose(xmin,xmin2))) diff --git a/jit.py b/jit.py deleted file mode 100644 index e7b7514..0000000 --- a/jit.py +++ /dev/null @@ -1,13 +0,0 @@ -import numba -import numpy as np - -@numba.jit(nopython=True) -def minmax(array): - N = array.shape[0] - vmin = np.full((N,), np.inf,dtype=array.dtype) - vmax = np.full((N,),-np.inf,dtype=array.dtype) - for ii in range(N): - for val in array[ii,...].ravel(): - vmin[ii] = min(vmin[ii],val) - vmax[ii] = max(vmax[ii],val) - return vmin,vmax \ No newline at end of file