Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
Add numba for #2
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Jan 2, 2021
1 parent 8e57965 commit 98b5160
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
18 changes: 18 additions & 0 deletions _unittests/ut_checks/test_numba.py
@@ -0,0 +1,18 @@
"""
@brief test log(time=1s)
"""

import unittest
from pyquickhelper.pycode import ExtTestCase
from check_python_install.check_numba import check_numba


class TestCartopy(ExtTestCase):

def test_numba(self):
ax = check_numba()
self.assertNotEmpty(ax)


if __name__ == "__main__":
unittest.main()
2 changes: 1 addition & 1 deletion check_python_install/__init__.py
Expand Up @@ -5,7 +5,7 @@
Checks other modules installation on CI.
"""

__version__ = "0.1.45"
__version__ = "0.1.51"
__author__ = "Xavier Dupré"
__github__ = "https://github.com/sdpython/_check_python_install"
__url__ = "http://www.xavierdupre.fr/app/_check_python_install/helpsphinx/index.html"
Expand Down
24 changes: 24 additions & 0 deletions check_python_install/check_numba.py
@@ -0,0 +1,24 @@
"""
@file
@brief Test for :epkg:`cartopy`.
"""
import numpy
import numba


@numba.jit(nopython=True, parallel=True)
def logistic_regression(Y, X, w, iterations):
"Fits a logistic regression."
for _ in range(iterations):
w -= numpy.dot(((1.0 / (1.0 + numpy.exp(-Y * numpy.dot(X, w))) - 1.0) * Y), X)
return w


def check_numba():
"""
Runs a sample with :epkg:`numba`.
"""
Y = numpy.random.rand(10).astype(numpy.double)
X = numpy.random.rand(10, 2).astype(numpy.double)
w = numpy.random.rand(2).astype(numpy.double)
return logistic_regression(Y, X, w, 2)
1 change: 1 addition & 0 deletions requirements.txt
Expand Up @@ -5,6 +5,7 @@ cython
jupyter_sphinx
jyquickhelper
matplotlib
numba
numpy
pandas
pycodestyle
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -154,5 +154,5 @@ def write_version():
packages=packages,
package_dir=package_dir,
package_data=package_data,
requires=['cartopy', 'pyproj', 'shapely', 'scipy'],
requires=['cartopy', 'pyproj', 'shapely', 'scipy', 'numba'],
)

0 comments on commit 98b5160

Please sign in to comment.