Skip to content

Commit

Permalink
Merge pull request #78 from pygae/disable_numba
Browse files Browse the repository at this point in the history
Added a test to disable numba if it fails
  • Loading branch information
hugohadfield authored Jan 18, 2019
2 parents edd03c0 + 4c9d98d commit acff284
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ language: python
matrix:
include:
- os: linux
python: '2.7'
env: CONDA=true
python: '3.5'
env: CONDA=false
- os: linux
python: '3.5'
env: CONDA=true
Expand All @@ -22,6 +22,7 @@ before_install:
install:
- if [[ "${CONDA}" == "true" ]]; then
PYTHON_VERSION="$TRAVIS_PYTHON_VERSION" CONDA_INSTALLER_OS="${TRAVIS_OS_NAME:-linux}" source auto_version/travis_install_conda.sh future numpy scipy numba pip nose h5py;
conda install numba==0.40.0;
fi
- pip install coverage
- pip install python-coveralls
Expand Down
26 changes: 26 additions & 0 deletions clifford/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
from numpy import linalg, array,zeros
import numba


from clifford.io import write_ga_file, read_ga_file


Expand All @@ -63,6 +64,31 @@
_eps = 1e-12 # float epsilon for float comparisons
_pretty = True # pretty-print global
_print_precision = 5 # pretty printing precision on floats
TEST_NUMBA = True


def test_numba():
"""
This tests numba to see if it can successfully compile a specific program
https://github.com/numba/numba/issues/3671
"""
@numba.njit(parallel=True)
def play_games():
monte_carlo_cell_visit_frequency = np.zeros(100, dtype=np.int_)
monte_carlo_cell_visit_frequency != 0

play_games()


if TEST_NUMBA:
try:
test_numba()
except:
import os
os.environ['NUMBA_DISABLE_JIT'] = "1"
warn('The version of numba installed suffers from https://github.com/numba/numba/issues/3671. ' +
'It has therefore been disabled. To reenable numba JIT compiliation try installing numba version 0.40.1', Warning)
TEST_NUMBA = False


def get_longest_string(string_array):
Expand Down

0 comments on commit acff284

Please sign in to comment.