Commit 373471608b4 by Ashwin Vishnu Mohanan

Merge branch 'topic/default/fix_issue32_numpy_fft' into 'branch/default'

Add numpy and scipy subpackages to packages_supported_by_pythran (fix issue #32)

Closes #32

See merge request !70
......@@ -19,3 +19,10 @@ meld_cython:
meld_numba:
meld __numba__ saved__backend__/numba
saved__backend__/%: __%__ FORCE
rsync -aP $< $@
rsync: saved__backend__/pythran saved__backend__/python saved__backend__/cython saved__backend__/numba
FORCE:
import cython
import numpy as np
cimport numpy as np
cpdef test_np_fft(np.ndarray[np.float_t, ndim=1] u)
cpdef test_np_linalg_random(np.ndarray[np.float_t, ndim=2] u)
cpdef test_sp_special(cython.int v, cython.float x)
try:
import cython
except ImportError:
from transonic_cl import cython
from numpy.fft import rfft
from numpy.random import randn
from numpy.linalg import matrix_power
from scipy.special import jv
def test_np_fft(u):
u_fft = rfft(u)
return u_fft
def test_np_linalg_random(u):
(nx, ny) = u.shape
u[:] = randn(nx, ny)
u2 = u.T * u
u4 = matrix_power(u2, 2)
return u4
def test_sp_special(v, x):
return jv(v, x)
__transonic__ = ("0.4.2",)
# __protected__ from numba import njit
from numpy.fft import rfft
from numpy.random import randn
from numpy.linalg import matrix_power
from scipy.special import jv
# __protected__ @njit
def test_np_fft(u):
u_fft = rfft(u)
return u_fft
# __protected__ @njit
def test_np_linalg_random(u):
(nx, ny) = u.shape
u[:] = randn(nx, ny)
u2 = u.T * u
u4 = matrix_power(u2, 2)
return u4
# __protected__ @njit
def test_sp_special(v, x):
return jv(v, x)
__transonic__ = ("0.4.2",)
from numpy.fft import rfft
from numpy.random import randn
from numpy.linalg import matrix_power
from scipy.special import jv
def test_np_fft(u):
u_fft = rfft(u)
return u_fft
def test_np_linalg_random(u):
(nx, ny) = u.shape
u[:] = randn(nx, ny)
u2 = u.T * u
u4 = matrix_power(u2, 2)
return u4
def test_sp_special(v, x):
return jv(v, x)
__transonic__ = ("0.4.2",)
from numpy.fft import rfft
from numpy.random import randn
from numpy.linalg import matrix_power
from scipy.special import jv
def test_np_fft(u):
u_fft = rfft(u)
return u_fft
def test_np_linalg_random(u):
(nx, ny) = u.shape
u[:] = randn(nx, ny)
u2 = u.T * u
u4 = matrix_power(u2, 2)
return u4
def test_sp_special(v, x):
return jv(v, x)
__transonic__ = ("0.4.2",)
export test_np_fft(float64[:])
export test_np_linalg_random(float64[:, :])
export test_sp_special(int, float64)
export __transonic__
from numpy.fft import rfft
from numpy.linalg import matrix_power
from numpy.random import randn
from scipy.special import jv
from transonic import boost
@boost
def test_np_fft(u: "float[]"):
u_fft = rfft(u)
return u_fft
@boost
def test_np_linalg_random(u: "float[:,:]"):
nx, ny = u.shape
u[:] = randn(nx, ny)
u2 = u.T * u
u4 = matrix_power(u2, 2)
return u4
@boost
def test_sp_special(v: int, x: float):
return jv(v, x)
......@@ -33,6 +33,7 @@ test =
pythran
cython
black
scipy
%(mpi)s
doc =
......@@ -88,4 +89,4 @@ directory = .coverage
output = .coverage/coverage.xml
[tool:pytest]
addopts = --doctest-modules
\ No newline at end of file
addopts = --doctest-modules
......@@ -25,6 +25,7 @@ deps =
numpy
mpi4py
black
scipy
numba
pythran: git+https://github.com/serge-sans-paille/pythran#egg=pythran
cython: cython
......
......@@ -180,7 +180,17 @@ def gather_rawcode_comments(node, code_module):
# TODO complete the list
packages_supported_by_pythran = ["numpy", "math", "functools", "cmath", "scipy"]
packages_supported_by_pythran = [
"functools",
"math",
"cmath",
"numpy",
"numpy.fft",
"numpy.linalg",
"numpy.random",
"scipy",
"scipy.special",
]
def find_path(node: object, pathfile: str):
......
......@@ -125,3 +125,11 @@ def test_create_trans_classic():
sys.argv = f"transonic -nc {path_file_pythran}".split()
run()
@pytest.mark.skipif(not path_data_tests.exists(), reason="no data tests")
@pytest.mark.skipif(nb_proc > 1, reason="No commandline in MPI")
def test_create_pythran_subpackages():
path_file = path_data_tests / "subpackages.py"
sys.argv = f"transonic -nc {path_file}".split()
run()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment