jit minmax is now slower than conventional: remove numba dependency

This commit is contained in:
Michael Krayer 2021-08-13 01:25:50 +02:00
parent 0723c0b769
commit cee9a661c8
2 changed files with 4 additions and 21 deletions

View File

@ -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)))

13
jit.py
View File

@ -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