Skip to content

Commit

Permalink
Merge pull request #102 from brian-rose/numba
Browse files Browse the repository at this point in the history
Always use numba for ConvectiveAdjustment acceleration if it is available

... but remove numba from CI environments, as it is not a required dependency.
  • Loading branch information
brian-rose committed Apr 12, 2019
2 parents fb6b001 + 6d8d3d7 commit 0f7e47d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
26 changes: 19 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,28 @@ These are handled automatically if you install with conda_.

Required
~~~~~~~~~~~~
- Python 2.7, 3.5, 3.6, 3.7 (as of version 0.7.1)
- ``numpy``
- ``scipy``
- ``xarray``
- ``attrdict``
- Python 2.7, 3.6, 3.7
- numpy
- scipy
- xarray
- future
- attrdict


Recommended for full functionality
~~~~~~~~~~~~
- ``numba`` (used for acceleration of some components)
- ``pytest`` (to run the automated tests, important if you are developing new code)
- numba >=0.43.1 (used for acceleration of some components)

*Note that there is a bug in previous numba versions that caused a hanging condition in climlab under Python 3.*


Complete development environment
~~~~~~~~~~~~
To build from source and develop new code you will need some additional pieces

- pip
- gfortran (OSX or linux) or flang (Windows)
- pytest (to run the automated tests, important if you are developing new code)

`Anaconda Python`_ is highly recommended and will provide everything you need.
See "Installing pre-built binaries with conda" above.
Expand Down
2 changes: 1 addition & 1 deletion climlab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
has been documented for a comprehensive understanding and traceability.
'''

__version__ = '0.7.2.dev2'
__version__ = '0.7.2.dev3'

# this should ensure that we can still import constants.py as climlab.constants
from .utils import constants, thermo, legendre
Expand Down
17 changes: 5 additions & 12 deletions climlab/convection/akmaev_adjustment.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,8 @@ def Akmaev_adjustment(theta, q, beta, n_k, theta_k, s_k, t_k):
# which gives at least 10x speedup
# If numba is not available or compilation fails, the code will be executed
# in pure Python. Results should be identical

### ONLY DO THIS IN PYTHON 2!
# Because of a bug in numba for while / break loops that is causing all calls
# to ConvectiveAdjustment to hang forever!
# https://github.com/numba/numba/issues/2273
if sys.version_info < (3,0):
try:
from numba import jit
Akmaev_adjustment = jit(signature_or_function=Akmaev_adjustment)
#print 'Compiling Akmaev_adjustment() with numba.'
except:
pass
try:
from numba import jit
Akmaev_adjustment = jit(signature_or_function=Akmaev_adjustment)
except ImportError:
pass
3 changes: 1 addition & 2 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% set version = "0.7.2.dev2" %}
{% set version = "0.7.2.dev3" %}

package:
name: climlab
Expand Down Expand Up @@ -28,7 +28,6 @@ requirements:
- xarray
- future
- attrdict
- numba # [py2k]

test:
requires:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os, sys
import textwrap

VERSION = '0.7.2.dev2'
VERSION = '0.7.2.dev3'

# BEFORE importing setuptools, remove MANIFEST. Otherwise it may not be
# properly updated when the contents of directories change (true for distutils,
Expand Down

0 comments on commit 0f7e47d

Please sign in to comment.