diff --git a/.travis.yml b/.travis.yml index f93a812d..94dbb209 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,11 +13,11 @@ env: # This environment tests the newest supported anaconda env - DISTRIB="conda" PYTHON_VERSION="2.7" NUMPY_VERSION="1.10.4" SCIPY_VERSION="0.16.1" - SIX_VERSION="1.10.0" COVERAGE="true" + SIX_VERSION="1.10.0" NUMBA_VERSION="0.38.0" COVERAGE="true" - DISTRIB="conda" PYTHON_VERSION="3.5" NUMPY_VERSION="1.10.4" SCIPY_VERSION="0.16.1" - SIX_VERSION="1.10.0" COVERAGE="true" - + SIX_VERSION="1.10.0" NUMBA_VERSION="0.38.0" COVERAGE="true" + # # This environment tests conda extras matplotlib # - DISTRIB="conda_extra" PYTHON_VERSION="3.5" # NUMPY_VERSION="1.10.4" SCIPY_VERSION="0.16.1" @@ -26,10 +26,10 @@ env: # This environment tests minimal dependency versions - DISTRIB="conda_min" PYTHON_VERSION="2.7" SIX_VERSION="1.10.0" NUMPY_VERSION="1.10.4" SCIPY_VERSION="0.16.1" - COVERAGE="true" - - DISTRIB="conda_min" PYTHON_VERSION="3.4" + NUMBA_VERSION="0.38.0" COVERAGE="true" + - DISTRIB="conda_min" PYTHON_VERSION="3.5" SIX_VERSION="1.10.0" NUMPY_VERSION="1.10.4" SCIPY_VERSION="0.16.1" - COVERAGE="true" + NUMBA_VERSION="0.38.0" COVERAGE="true" # basic Ubuntu build environment # - DISTRIB="ubuntu" PYTHON_VERSION="2.7" diff --git a/continuous_integration/install.sh b/continuous_integration/install.sh index e403fdaa..124d2138 100644 --- a/continuous_integration/install.sh +++ b/continuous_integration/install.sh @@ -28,7 +28,7 @@ if [[ "$DISTRIB" == "conda_min" ]]; then # Configure the conda environment and put it in the path using the # provided versions conda create -n testenv --yes python=$PYTHON_VERSION pip nose coverage \ - six=$SIX_VERSION numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION + six=$SIX_VERSION numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION numba=$NUMBA_VERSION source activate testenv pip install matplotlib @@ -49,7 +49,7 @@ elif [[ "$DISTRIB" == "conda" ]]; then # Configure the conda environment and put it in the path using the # provided versions conda create -n testenv --yes python=$PYTHON_VERSION pip nose coverage six=$SIX_VERSION \ - numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION + numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION numba=$NUMBA_VERSION source activate testenv if [[ "$COVERAGE" == "true" ]]; then @@ -73,7 +73,7 @@ elif [[ "$DISTRIB" == "conda_extra" ]]; then # Configure the conda environment and put it in the path using the # provided versions conda create -n testenv --yes python=$PYTHON_VERSION pip nose coverage six=$SIX_VERSION \ - numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION + numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION numba=$NUMBA_VERSION source activate testenv pip install scikit-monaco @@ -94,6 +94,7 @@ elif [[ "$DISTRIB" == "ubuntu" ]]; then pip install numpy==$NUMPY_VERSION pip install scipy==$SCIPY_VERSION pip install six==$SIX_VERSION + pip install numba==$NUMBA_VERSION pip install matplotlib elif [[ "$DISTRIB" == "ubuntu_extra" ]]; then @@ -106,7 +107,7 @@ elif [[ "$DISTRIB" == "ubuntu_extra" ]]; then pip install numpy==$NUMPY_VERSION pip install scipy==$SCIPY_VERSION pip install six==$SIX_VERSION - pip install scikit-monaco==$SKMONACO_VERSION + pip install numba===$NUMBA_VERSION pip install matplotlib==$MATPLOTLIB_VERSION fi diff --git a/kcsd/KCSD.py b/kcsd/KCSD.py index 195330b2..82be9b19 100644 --- a/kcsd/KCSD.py +++ b/kcsd/KCSD.py @@ -12,6 +12,7 @@ from __future__ import division, print_function, absolute_import import numpy as np +from numba import jit from numpy.linalg import LinAlgError, svd from scipy import special, integrate, interpolate from scipy.spatial import distance @@ -570,6 +571,7 @@ def forward_model(self, x, R, h, sigma, src_type): pot *= 1./(2.0*sigma) return pot + @jit def int_pot_1D(self, xp, x, R, h, basis_func): """FWD model function. Returns contribution of a point xp,yp, belonging to a basis source @@ -747,6 +749,7 @@ def forward_model(self, x, R, h, sigma, src_type): pot *= 1./(2.0*np.pi*sigma) # Potential basis functions bi_x_y return pot + @jit def int_pot_2D(self, xp, yp, x, R, h, basis_func): """FWD model function. Returns contribution of a point xp,yp, belonging to a basis source @@ -869,6 +872,7 @@ def forward_model(self, x, R, h, sigma, src_type): pot *= 1./(2.0*np.pi*sigma) return pot + @jit def int_pot_2D_moi(self, xp, yp, x, R, h, basis_func): """FWD model function. Incorporates the Method of Images. Returns contribution of a point xp,yp, belonging to a basis source @@ -1092,6 +1096,7 @@ def forward_model(self, x, R, h, sigma, src_type): pot *= 1./(4.0*np.pi*sigma) return pot + @jit def int_pot_3D(self, xp, yp, zp, x, R, h, basis_func): """FWD model function. Returns contribution of a point xp,yp, belonging to a basis source diff --git a/kcsd/basis_functions.py b/kcsd/basis_functions.py index 79621180..4ddaaa75 100644 --- a/kcsd/basis_functions.py +++ b/kcsd/basis_functions.py @@ -13,8 +13,9 @@ """ from __future__ import division, print_function, absolute_import import numpy as np +from numba import jit - +@jit(nopython=True) def gauss(d, stdev, dim): """Gaussian function Parameters @@ -33,7 +34,7 @@ def gauss(d, stdev, dim): Z = np.exp(-(d**2) / (2*stdev**2)) / (np.sqrt(2*np.pi)*stdev)**dim return Z - +@jit(nopython=True) def step_1D(d, R): """Returns normalized 1D step function. Parameters @@ -50,6 +51,7 @@ def step_1D(d, R): s = s / R #normalize with width return s +@jit(nopython=True) def gauss_1D(d, three_stdev): """Returns normalized gaussian 2D scale function Parameters @@ -66,7 +68,7 @@ def gauss_1D(d, three_stdev): Z = gauss(d, stdev, 1) return Z - +@jit(nopython=True) def gauss_lim_1D(d, three_stdev): """Returns gausian 2D function cut off after 3 standard deviations. Parameters @@ -84,7 +86,7 @@ def gauss_lim_1D(d, three_stdev): Z *= (d < three_stdev) return Z - +@jit(nopython=True) def step_2D(d, R): """Returns normalized 2D step function. Parameters @@ -101,6 +103,7 @@ def step_2D(d, R): s = (d <= R) / (np.pi*(R**2)) return s +@jit(nopython=True) def gauss_2D(d, three_stdev): """Returns normalized gaussian 2D scale function Parameters @@ -118,7 +121,7 @@ def gauss_2D(d, three_stdev): Z = gauss(d, stdev, 2) return Z - +@jit(nopython=True) def gauss_lim_2D(d, three_stdev): """Returns gausian 2D function cut off after 3 standard deviations. Parameters @@ -135,7 +138,7 @@ def gauss_lim_2D(d, three_stdev): Z = (d <= three_stdev)*gauss_2D(d, three_stdev) return Z - +@jit(nopython=True) def gauss_3D(d, three_stdev): """Returns normalized gaussian 3D scale function Parameters @@ -153,7 +156,7 @@ def gauss_3D(d, three_stdev): Z = gauss(d, stdev, 3) return Z - +@jit(nopython=True) def gauss_lim_3D(d, three_stdev): """Returns normalized gaussian 3D scale function cut off after 3stdev Parameters @@ -171,7 +174,7 @@ def gauss_lim_3D(d, three_stdev): Z = Z * (d < (three_stdev)) return Z - +@jit(nopython=True) def step_3D(d, R): """Returns normalized 3D step function. Parameters diff --git a/setup.py b/setup.py index daf7576b..e69015f8 100644 --- a/setup.py +++ b/setup.py @@ -38,8 +38,9 @@ def readme(): # ]}, include_package_data=True, install_requires=['future>=0.16.0', - 'numpy>=1.8.0', - 'scipy>=0.14.0', + 'numpy>=1.10.4', + 'scipy>=0.16.1', + 'numba>=0.38.0', 'matplotlib>=2.0'], extras_require={'docs': ['numpydoc>=0.5', 'sphinx>=1.2.2']},