jit minmax is now slower than conventional: remove numba dependency
This commit is contained in:
parent
0723c0b769
commit
cee9a661c8
12
field.py
12
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."
|
# assert coords.ndim==2 and coords.shape[1]==3, "'coords' need to be provided as Nx3 array."
|
||||||
from time import time
|
from time import time
|
||||||
from scipy import spatial
|
from scipy import spatial
|
||||||
from .jit import minmax
|
|
||||||
|
|
||||||
# pts = np.random.random((10000,3))
|
# pts = np.random.random((10000,3))
|
||||||
|
|
||||||
t = time()
|
t = time()
|
||||||
|
|
||||||
# xmin = np.amin(self._points[self._faces[:,1:],0],axis=1)
|
xmin = np.amin(self._vertices[:,:,0],axis=1)
|
||||||
# xmax = np.amax(self._points[self._faces[:,1:],0],axis=1)
|
xmax = np.amax(self._vertices[:,:,0],axis=1)
|
||||||
# zmin = np.amin(self._points[self._faces[:,1:],2],axis=1)
|
zmin = np.amin(self._vertices[:,:,2],axis=1)
|
||||||
# zmax = np.amax(self._points[self._faces[:,1:],2],axis=1)
|
zmax = np.amax(self._vertices[:,:,2],axis=1)
|
||||||
# print(time()-t)
|
|
||||||
xmin,xmax = minmax(self._vertices[:,:,0])
|
|
||||||
zmin,zmax = minmax(self._vertices[:,:,2])
|
|
||||||
print(time()-t)
|
print(time()-t)
|
||||||
# print(xmin.shape,xmin2.shape)
|
# print(xmin.shape,xmin2.shape)
|
||||||
# print(np.all(np.isclose(xmin,xmin2)))
|
# print(np.all(np.isclose(xmin,xmin2)))
|
||||||
|
|
|
||||||
13
jit.py
13
jit.py
|
|
@ -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
|
|
||||||
Loading…
Reference in New Issue