From c9322583cbe8c1ecf4d7543fcb29f6cec6c50d18 Mon Sep 17 00:00:00 2001 From: Chaitanya Chintaluri Date: Fri, 23 Nov 2018 16:54:43 +0000 Subject: [PATCH 1/4] separating the numba jit into a separate branch --- .travis.yml | 10 ++++++---- continuous_integration/install.sh | 9 +++++---- kcsd/KCSD.py | 5 +++++ kcsd/basis_functions.py | 19 +++++++++++-------- setup.py | 1 + 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index f93a812d..38ec3cbc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,10 +14,12 @@ env: - DISTRIB="conda" PYTHON_VERSION="2.7" NUMPY_VERSION="1.10.4" SCIPY_VERSION="0.16.1" SIX_VERSION="1.10.0" COVERAGE="true" + NUMBA_VERSION="0.33" - DISTRIB="conda" PYTHON_VERSION="3.5" NUMPY_VERSION="1.10.4" SCIPY_VERSION="0.16.1" SIX_VERSION="1.10.0" COVERAGE="true" - + NUMBA_VERSION="0.33" + # # 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 +28,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" + COVERAGE="true" NUMBA_VERSION="0.33" - DISTRIB="conda_min" PYTHON_VERSION="3.4" SIX_VERSION="1.10.0" NUMPY_VERSION="1.10.4" SCIPY_VERSION="0.16.1" - COVERAGE="true" + COVERAGE="true" NUMBA_VERSION="0.33" # basic Ubuntu build environment # - DISTRIB="ubuntu" PYTHON_VERSION="2.7" @@ -49,5 +51,5 @@ install: source continuous_integration/install.sh # command to run tests script: bash continuous_integration/test_script.sh after_success: -- if [[ "$COVERAGE" == "true" ]]; then coveralls || echo "failed"; fi +- if [[ "$COVERAGE" == "true" ]]; then coveralls --base_dir kcsd || echo "failed"; fi diff --git a/continuous_integration/install.sh b/continuous_integration/install.sh index e403fdaa..7b168da3 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..4b94b87f 100644 --- a/setup.py +++ b/setup.py @@ -40,6 +40,7 @@ def readme(): install_requires=['future>=0.16.0', 'numpy>=1.8.0', 'scipy>=0.14.0', + 'numba>=0.33', 'matplotlib>=2.0'], extras_require={'docs': ['numpydoc>=0.5', 'sphinx>=1.2.2']}, From 9f402b9fd893121320a8dd5c68440dbf4efc6109 Mon Sep 17 00:00:00 2001 From: Chaitanya Chintaluri Date: Fri, 23 Nov 2018 17:02:16 +0000 Subject: [PATCH 2/4] figuring the correct numba compatible version --- .travis.yml | 6 ++---- continuous_integration/install.sh | 10 +++++----- setup.py | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 38ec3cbc..fee22ff3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,11 +14,9 @@ env: - DISTRIB="conda" PYTHON_VERSION="2.7" NUMPY_VERSION="1.10.4" SCIPY_VERSION="0.16.1" SIX_VERSION="1.10.0" COVERAGE="true" - NUMBA_VERSION="0.33" - DISTRIB="conda" PYTHON_VERSION="3.5" NUMPY_VERSION="1.10.4" SCIPY_VERSION="0.16.1" SIX_VERSION="1.10.0" COVERAGE="true" - NUMBA_VERSION="0.33" # # This environment tests conda extras matplotlib # - DISTRIB="conda_extra" PYTHON_VERSION="3.5" @@ -28,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" NUMBA_VERSION="0.33" + COVERAGE="true" - DISTRIB="conda_min" PYTHON_VERSION="3.4" SIX_VERSION="1.10.0" NUMPY_VERSION="1.10.4" SCIPY_VERSION="0.16.1" - COVERAGE="true" NUMBA_VERSION="0.33" + 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 7b168da3..1fda73c4 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 numba=$NUMBA_VERSION + six=$SIX_VERSION numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION numba 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 numba=$NUMBA_VERSION + numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION numba 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 numba=$NUMBA_VERSION + numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION numba source activate testenv pip install scikit-monaco @@ -94,7 +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 numba pip install matplotlib elif [[ "$DISTRIB" == "ubuntu_extra" ]]; then @@ -107,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 numba=$NUMBA_VERSION + pip install numba pip install matplotlib==$MATPLOTLIB_VERSION fi diff --git a/setup.py b/setup.py index 4b94b87f..e87060bf 100644 --- a/setup.py +++ b/setup.py @@ -40,7 +40,7 @@ def readme(): install_requires=['future>=0.16.0', 'numpy>=1.8.0', 'scipy>=0.14.0', - 'numba>=0.33', + 'numba>=0.3', 'matplotlib>=2.0'], extras_require={'docs': ['numpydoc>=0.5', 'sphinx>=1.2.2']}, From d92d466d5b47684bd8a16bc529de13c254f25802 Mon Sep 17 00:00:00 2001 From: Chaitanya Chintaluri Date: Fri, 23 Nov 2018 17:19:25 +0000 Subject: [PATCH 3/4] numba versions --- .travis.yml | 10 +++++----- continuous_integration/install.sh | 10 +++++----- setup.py | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index fee22ff3..06f99005 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,10 +13,10 @@ 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" @@ -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" + NUMBA_VERSION="0.38.0" COVERAGE="true" - DISTRIB="conda_min" PYTHON_VERSION="3.4" 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" @@ -49,5 +49,5 @@ install: source continuous_integration/install.sh # command to run tests script: bash continuous_integration/test_script.sh after_success: -- if [[ "$COVERAGE" == "true" ]]; then coveralls --base_dir kcsd || echo "failed"; fi +- if [[ "$COVERAGE" == "true" ]]; then coveralls || echo "failed"; fi diff --git a/continuous_integration/install.sh b/continuous_integration/install.sh index 1fda73c4..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 numba + 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 numba + 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 numba + numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION numba=$NUMBA_VERSION source activate testenv pip install scikit-monaco @@ -94,7 +94,7 @@ elif [[ "$DISTRIB" == "ubuntu" ]]; then pip install numpy==$NUMPY_VERSION pip install scipy==$SCIPY_VERSION pip install six==$SIX_VERSION - pip install numba + pip install numba==$NUMBA_VERSION pip install matplotlib elif [[ "$DISTRIB" == "ubuntu_extra" ]]; then @@ -107,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 numba + pip install numba===$NUMBA_VERSION pip install matplotlib==$MATPLOTLIB_VERSION fi diff --git a/setup.py b/setup.py index e87060bf..e69015f8 100644 --- a/setup.py +++ b/setup.py @@ -38,9 +38,9 @@ def readme(): # ]}, include_package_data=True, install_requires=['future>=0.16.0', - 'numpy>=1.8.0', - 'scipy>=0.14.0', - 'numba>=0.3', + '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']}, From ef2d6641039dae111bdfee60e0baa85c54ce3183 Mon Sep 17 00:00:00 2001 From: Chaitanya Chintaluri Date: Fri, 23 Nov 2018 17:22:53 +0000 Subject: [PATCH 4/4] py version# --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 06f99005..94dbb209 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ env: - DISTRIB="conda_min" PYTHON_VERSION="2.7" SIX_VERSION="1.10.0" NUMPY_VERSION="1.10.4" SCIPY_VERSION="0.16.1" NUMBA_VERSION="0.38.0" COVERAGE="true" - - DISTRIB="conda_min" PYTHON_VERSION="3.4" + - DISTRIB="conda_min" PYTHON_VERSION="3.5" SIX_VERSION="1.10.0" NUMPY_VERSION="1.10.4" SCIPY_VERSION="0.16.1" NUMBA_VERSION="0.38.0" COVERAGE="true"