transonic issueshttps://foss.heptapod.net/fluiddyn/transonic/-/issues2020-02-12T22:35:20Zhttps://foss.heptapod.net/fluiddyn/transonic/-/issues/21Bug jit(external_func)2020-02-12T22:35:20ZBitbucket ImporterBug jit(external_func)*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
This should work… but it does not work!
2 files:
1. `util_for_bug.py`
```python
def fib(n: int):...*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
This should work… but it does not work!
2 files:
1. `util_for_bug.py`
```python
def fib(n: int):
"""fibonacci"""
if n < 2:
return n
return fib(n - 1) + fib(n - 2)
```
2\. `main.py`
```python
from transonic import jit
from util_for_bug import fib
fib_jitted = jit(fib)
assert fib(2) == fib_jitted(2)
```
@{5aed8fd1347761310e25811e} Can you please fix this one ? \(and same thing for `boost`\)https://foss.heptapod.net/fluiddyn/transonic/-/issues/22Add njit decorator?2020-02-12T22:35:21ZBitbucket ImporterAdd njit decorator?*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
See [https://bitbucket.org/fluiddyn/transonic/issues/19/change-default-arguments-of-jit-decorator](https:/...*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
See [https://bitbucket.org/fluiddyn/transonic/issues/19/change-default-arguments-of-jit-decorator](https://bitbucket.org/fluiddyn/transonic/issues/19/change-default-arguments-of-jit-decorator)https://foss.heptapod.net/fluiddyn/transonic/-/issues/23Issues with jit and exterior code2021-12-30T11:55:31ZBitbucket ImporterIssues with jit and exterior code*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
@{5aed8fd1347761310e25811e} can you please list them here ?*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
@{5aed8fd1347761310e25811e} can you please list them here ?https://foss.heptapod.net/fluiddyn/transonic/-/issues/24Fresh install in Miniconda, fluidsim-test fails2020-02-12T22:35:21ZBitbucket ImporterFresh install in Miniconda, fluidsim-test fails*Created originally on Bitbucket by [avmo (Ashwin Vishnu)](https://bitbucket.org/%7Bbd72905e-cf99-4847-84c2-998104370f6e%7D/)*
```python
~/s/l/augier_vishnu_lindborg_sw1l (default) ❯❯❯ TRANSONIC_DEBUG=1 fluidsim-test -m solvers.sw1l.on...*Created originally on Bitbucket by [avmo (Ashwin Vishnu)](https://bitbucket.org/%7Bbd72905e-cf99-4847-84c2-998104370f6e%7D/)*
```python
~/s/l/augier_vishnu_lindborg_sw1l (default) ❯❯❯ TRANSONIC_DEBUG=1 fluidsim-test -m solvers.sw1l.onlywaves (augier_etal_2019)
Fluidsim guesses that it is tested so it loads the Agg Matplotlib backend.
Compilation of jit functions disabled.
/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/fluidsim/util/testing.py:222: UserWarning: Assuming you forgot to add fluidsim in front of module name: solvers.sw1l.onlywaves
f"Assuming you forgot to add fluidsim in front of module name: {module_name}"
DEBUG extast.parse
DEBUG compute ancestors and chains
DEBUG compute code dependance
DEBUG {'compute_Frot': '', 'compute_pressure': ''}
DEBUG extast.parse
DEBUG compute ancestors and chains
DEBUG compute code dependance
DEBUG {'_qapamfft_from_uxuyetafft': 'import numpy as np'}
ERROR
======================================================================
ERROR: setUpClass (test_solver.TestSimulSW1LWaves)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/fluidsim/util/testing.py", line 78, in setUpClass
cls.init_params()
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/fluidsim/solvers/sw1l/onlywaves/test_solver.py", line 15, in init_params
super().init_params()
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/fluidsim/util/testing.py", line 56, in init_params
params = cls.params = cls.Simul.create_default_params()
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/fluidsim/base/solvers/base.py", line 95, in create_default_params
cls.info_solver.complete_with_classes()
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/fluidsim/base/solvers/info_base.py", line 119, in complete_with_classes
dict_classes = self.import_classes()
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/fluidsim/base/solvers/info_base.py", line 113, in import_classes
Class = import_class(module_name, class_name)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/fluiddyn/util/util.py", line 35, in import_class
module = import_module(module_name)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/fluidsim/solvers/sw1l/operators.py", line 43, in <module>
rank: int,
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/transonic/justintime.py", line 235, in jit
return decor(func)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/transonic/justintime.py", line 320, in __call__
r"@.*?\sdef\s", "def ", get_source_without_decorator(func)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/transonic/util.py", line 195, in get_source_without_decorator
return strip_typehints(re.sub(r"@.*?\sdef\s", "def ", src))
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/transonic/util.py", line 233, in strip_typehints
striped_code = astunparse.unparse(transformed)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/astunparse/__init__.py", line 13, in unparse
Unparser(tree, file=v)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/astunparse/unparser.py", line 38, in __init__
self.dispatch(tree)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/astunparse/unparser.py", line 66, in dispatch
meth(tree)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/astunparse/unparser.py", line 78, in _Module
self.dispatch(stmt)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/astunparse/unparser.py", line 66, in dispatch
meth(tree)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/astunparse/unparser.py", line 347, in _FunctionDef
self._generic_FunctionDef(t)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/astunparse/unparser.py", line 343, in _generic_FunctionDef
self.dispatch(t.body)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/astunparse/unparser.py", line 63, in dispatch
self.dispatch(t)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/astunparse/unparser.py", line 66, in dispatch
meth(tree)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/astunparse/unparser.py", line 376, in _If
self.dispatch(t.body)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/astunparse/unparser.py", line 63, in dispatch
self.dispatch(t)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/astunparse/unparser.py", line 66, in dispatch
meth(tree)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/astunparse/unparser.py", line 367, in _For
self._generic_For(t)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/astunparse/unparser.py", line 358, in _generic_For
self.dispatch(t.body)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/astunparse/unparser.py", line 63, in dispatch
self.dispatch(t)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/astunparse/unparser.py", line 66, in dispatch
meth(tree)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/astunparse/unparser.py", line 367, in _For
self._generic_For(t)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/astunparse/unparser.py", line 358, in _generic_For
self.dispatch(t.body)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/astunparse/unparser.py", line 63, in dispatch
self.dispatch(t)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/astunparse/unparser.py", line 66, in dispatch
meth(tree)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/astunparse/unparser.py", line 374, in _If
self.dispatch(t.test)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/astunparse/unparser.py", line 66, in dispatch
meth(tree)
File "/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/astunparse/unparser.py", line 683, in _BoolOp
s = " %s " % self.boolops[t.op.__class__]
KeyError: <class 'gast.gast.And'>
----------------------------------------------------------------------
Ran 0 tests in 1.316s
FAILED (errors=1)
~/s/l/augier_vishnu_lindborg_sw1l (default) ❯❯❯ TRANSONIC_DEBUG=1 TRANSONIC_NO_REPLACE=1 fluidsim-test -m solvers.sw1l.onlywaves (augier_etal_2019)
Fluidsim guesses that it is tested so it loads the Agg Matplotlib backend.
Compilation of jit functions disabled.
/home/mech/avmo/scratch/miniconda3/envs/augier_etal_2019/lib/python3.7/site-packages/fluidsim/util/testing.py:222: UserWarning: Assuming you forgot to add fluidsim in front of module name: solvers.sw1l.onlywaves
f"Assuming you forgot to add fluidsim in front of module name: {module_name}"
test_energy_conservation (test_solver.TestSimulSW1LWaves)
Verify that the energy growth rate due to nonlinear tendencies ... ok
test_init_methods (test_solver.TestSimulSW1LWaves) ... ok
test_state_compute (test_solver.TestSimulSW1LWaves) ... ok
test_state_methods (test_solver.TestSimulSW1LWaves) ... ok
----------------------------------------------------------------------
Ran 4 tests in 3.416s
OK
```
It seems to be a transonic issue. I am also attaching the output of `conda env export` so that it may be reproduced.https://foss.heptapod.net/fluiddyn/transonic/-/issues/25Raise error when no signature found for boosted function/methods2020-02-12T22:35:22ZBitbucket ImporterRaise error when no signature found for boosted function/methods*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
```
from transonic import boost
@boost
def func(a, b):
return a + b
```*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
```
from transonic import boost
@boost
def func(a, b):
return a + b
```https://foss.heptapod.net/fluiddyn/transonic/-/issues/26API to specify memoryview or np.ndarray (for Cython)2020-02-12T22:35:23ZBitbucket ImporterAPI to specify memoryview or np.ndarray (for Cython)*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
In Cython memoryviews and np.ndarray are both useful in different cases. A user has to be able to specify ...*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
In Cython memoryviews and np.ndarray are both useful in different cases. A user has to be able to specify this.https://foss.heptapod.net/fluiddyn/transonic/-/issues/27transonic.dataclass for numba.jitclass and cython cdef class2020-02-12T22:35:23ZBitbucket Importertransonic.dataclass for numba.jitclass and cython cdef class*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
```
from transonic import dataclass, boost
@dataclass
class MyStruc:
attr: int
def co...*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
```
from transonic import dataclass, boost
@dataclass
class MyStruc:
attr: int
def compute(self, arg: int):
return self.attr + arg
def modify(self, arg: int):
self.attr = arg
@boost
def func(o: MyStruct, a: int):
o.modify(a)
return o
@boost
def func1(o: MyStruct, a: int):
return o.compute(a)
```
See [https://github.com/serge-sans-paille/pythran/issues/1116](https://github.com/serge-sans-paille/pythran/issues/1116)
and what is done in [https://github.com/ogrisel/pygbm/blob/master/pygbm/splitting.py#L21](https://github.com/ogrisel/pygbm/blob/master/pygbm/splitting.py#L21)https://foss.heptapod.net/fluiddyn/transonic/-/issues/28https://github.com/pyccel/pyccel2020-11-11T09:25:43ZBitbucket Importerhttps://github.com/pyccel/pyccel*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
We could have a backend for pyccel*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
We could have a backend for pyccelhttps://foss.heptapod.net/fluiddyn/transonic/-/issues/29Default parameters2020-02-12T22:35:24ZBitbucket ImporterDefault parameters*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
```
@boost
def func(a: int = 1, b: int = 2):
return a+b
```
In Pythran it should give:
```
# ...*Created originally on Bitbucket by [paugier (Pierre Augier)](https://bitbucket.org/%7Beb327c54-cadd-4fce-9edd-f8fe047a9b93%7D/)*
```
@boost
def func(a: int = 1, b: int = 2):
return a+b
```
In Pythran it should give:
```
# pythran export func()
# pythran export func(int)
# pythran export func(int, int)
```
https://foss.heptapod.net/fluiddyn/transonic/-/issues/30Making sdist of a package using transonic.boost packages __pythran__ directories2020-02-12T22:35:25ZBitbucket ImporterMaking sdist of a package using transonic.boost packages __pythran__ directories*Created originally on Bitbucket by [avmo (Ashwin Vishnu)](https://bitbucket.org/%7Bbd72905e-cf99-4847-84c2-998104370f6e%7D/)*
Even if I clean the package, while running `python setup.py sdist` on fluidsht, it packages the `__pythran__`...*Created originally on Bitbucket by [avmo (Ashwin Vishnu)](https://bitbucket.org/%7Bbd72905e-cf99-4847-84c2-998104370f6e%7D/)*
Even if I clean the package, while running `python setup.py sdist` on fluidsht, it packages the `__pythran__` directory containing:
```
$ make deploy
rm -rf build dist
find fluidsht -name "*.pyc" -delete
find fluidsht -name "__pycache__" -type d | xargs rm -rf
find fluidsht -name "__pythran__" -type d | xargs rm -rf
python setup.py sdist
INFO: Running fluidsht setup.py on platform linux
INFO:
__ _ _ _ _ _
/ _| | (_) | | | | | |
| |_| |_ _ _ __| |___| |__ | |_
| _| | | | | |/ _` / __| '_ \| __|
| | | | |_| | | (_| \__ \ | | | |_
|_| |_|\__,_|_|\__,_|___/_| |_|\__|
v. 0.0.4a0
INFO /home/avmo/src/gfdyn/fluidsht/fluidsht/sht2d/__pythran__/operators.py written
INFO /home/avmo/src/gfdyn/fluidsht/fluidsht/sht2d/__pythran__/operators.pythran written
INFO File /home/avmo/src/gfdyn/fluidsht/fluidsht/sht2d/__pythran__/operators.py updated
WARNING 1 files created or updated needs to be pythranized
INFO: Extension has to be built: fluidsht/sht2d/__pythran__/operators.py -> operators.cpython-37m-x86_64-linux-gnu.so
running sdist
running egg_info
writing fluidsht.egg-info/PKG-INFO
writing dependency_links to fluidsht.egg-info/dependency_links.txt
writing requirements to fluidsht.egg-info/requires.txt
writing top-level names to fluidsht.egg-info/top_level.txt
writing manifest file 'fluidsht.egg-info/SOURCES.txt'
running check
warning: Check: missing required meta-data: url
creating fluidsht-0.0.4a0
creating fluidsht-0.0.4a0/.ci
creating fluidsht-0.0.4a0/doc
creating fluidsht-0.0.4a0/doc/install
creating fluidsht-0.0.4a0/fluidsht
creating fluidsht-0.0.4a0/fluidsht.egg-info
creating fluidsht-0.0.4a0/fluidsht/sht2d
creating fluidsht-0.0.4a0/fluidsht/sht2d/__pythran__
...
copying fluidsht/sht2d/__pythran__/operators.cpp -> fluidsht-0.0.4a0/fluidsht/sht2d/__pythran__
...
```
Should or can transonic avoid building while running sdist?https://foss.heptapod.net/fluiddyn/transonic/-/issues/31Transonic plugin framework2020-11-29T20:43:19ZBitbucket ImporterTransonic plugin framework*Created originally on Bitbucket by [avmo (Ashwin Vishnu)](https://bitbucket.org/%7Bbd72905e-cf99-4847-84c2-998104370f6e%7D/)*
Starting an issue to discuss possible plugin APIs*Created originally on Bitbucket by [avmo (Ashwin Vishnu)](https://bitbucket.org/%7Bbd72905e-cf99-4847-84c2-998104370f6e%7D/)*
Starting an issue to discuss possible plugin APIshttps://foss.heptapod.net/fluiddyn/transonic/-/issues/32numpy.fft sub-package cannot be used2020-06-11T14:12:11ZAshwin V. Mohanannumpy.fft sub-package cannot be usedFound this while trying out: https://github.com/fluiddyn/transonic-demos/pull/1
## Minimal example
```python
import numpy as np
from numpy.fft import fft
from transonic import jit
@jit
def test(u):
u_fft = fft(u)
return u
...Found this while trying out: https://github.com/fluiddyn/transonic-demos/pull/1
## Minimal example
```python
import numpy as np
from numpy.fft import fft
from transonic import jit
@jit
def test(u):
u_fft = fft(u)
return u
print(test(np.exp(2j * np.pi * np.arange(8) / 8)))
```
## Traceback
```python
❯ TRANSONIC_DEBUG=1 python test_fft.py
DEBUG: extast.parse
DEBUG: compute ancestors and chains
DEBUG: compute code dependance
DEBUG: {'test': 'from numpy.fft import fft'}
Traceback (most recent call last):
File "/home/avmo/.pyenv/versions/fluiddyn/lib/python3.8/site-packages/transonic/analyses/util.py", line 387, in get_exterior_code
with open(str(file_path), "r") as file:
FileNotFoundError: [Errno 2] No such file or directory: 'numpy/fft.py'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test_fft.py", line 8, in <module>
def test(u):
File "/home/avmo/.pyenv/versions/fluiddyn/lib/python3.8/site-packages/transonic/justintime.py", line 193, in jit
decor = JIT(frame, backend=backend, native=native, xsimd=xsimd, openmp=openmp)
File "/home/avmo/.pyenv/versions/fluiddyn/lib/python3.8/site-packages/transonic/justintime.py", line 208, in __init__
self.mod = _get_module_jit(backend, frame=frame)
File "/home/avmo/.pyenv/versions/fluiddyn/lib/python3.8/site-packages/transonic/justintime.py", line 185, in _get_module_jit
return ModuleJIT(backend_name=backend_name, frame=frame)
File "/home/avmo/.pyenv/versions/fluiddyn/lib/python3.8/site-packages/transonic/justintime.py", line 115, in __init__
) = analysis_jit(self.get_source(), self.filename, backend_name)
File "/home/avmo/.pyenv/versions/fluiddyn/lib/python3.8/site-packages/transonic/analyses/justintime.py", line 109, in analysis_jit
codes_dependance, code_ext, jitted_dicts, spe = get_exterior_code(
File "/home/avmo/.pyenv/versions/fluiddyn/lib/python3.8/site-packages/transonic/analyses/util.py", line 390, in get_exterior_code
raise NotImplementedError(file_name + " can no be found")
NotImplementedError: numpy.fft can no be found
```Pierre AugierPierre Augierhttps://foss.heptapod.net/fluiddyn/transonic/-/issues/33Regression: run_path broken for python >= 3.82020-06-11T14:12:11ZAshwin V. MohananRegression: run_path broken for python >= 3.8Affects setup.py
```python
In [1]: from runpy import run_path
In [2]: ...Affects setup.py
```python
In [1]: from runpy import run_path
In [2]:
In [2]: from pathlib import Path
In [3]:
In [3]: cd ..
/home/avmo/src/fluiddyn/transonic
In [4]: v = Path("transonic/_version.py")
In [5]: v
Out[5]: PosixPath('transonic/_version.py')
In [6]: run_path(v)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-6-6da5ed68dcf0> in <module>
----> 1 run_path(v)
~/.pyenv/versions/3.8.1/lib/python3.8/runpy.py in run_path(path_name, init_globals, run_name)
260 # Not a valid sys.path entry, so run the code directly
261 # execfile() doesn't help as we want to allow compiled files
--> 262 code, fname = _get_code_from_file(run_name, path_name)
263 return _run_module_code(code, init_globals, run_name,
264 pkg_name=pkg_name, script_name=fname)
~/.pyenv/versions/3.8.1/lib/python3.8/runpy.py in _get_code_from_file(run_name, fname)
230 def _get_code_from_file(run_name, fname):
231 # Check for a compiled file first
--> 232 with io.open_code(fname) as f:
233 code = read_code(f)
234 if code is None:
TypeError: open_code() argument 'path' must be str, not PosixPath
In [7]: import io
In [8]: io.open_code?
Signature: io.open_code(path)
Docstring:
Opens the provided file with the intent to import the contents.
This may perform extra validation beyond open(), but is otherwise interchangeable
with calling open(path, 'rb').
Type: builtin_function_or_method
In [9]: io.open_code(v)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-9-30a090c83748> in <module>
----> 1 io.open_code(v)
TypeError: open_code() argument 'path' must be str, not PosixPath
In [10]:
In [10]: hist
from runpy import run_path
from pathlib import Path
cd ..
v = Path("transonic/_version.py")
v
run_path(v)
import io
io.open_code?
io.open_code(v)
```Ashwin V. MohananAshwin V. Mohananhttps://foss.heptapod.net/fluiddyn/transonic/-/issues/34Alternative to pytest-ipynb2020-10-23T13:57:16ZAshwin V. MohananAlternative to pytest-ipynbI remember there was some issue with pytest-ipynb : https://foss.heptapod.net/fluiddyn/transonic/commit/37bc59df447f793cf24fa1b202528abb72c7f817
https://github.com/computationalmodelling/nbval
Source: https://nitter.snopyta.org/andreaz...I remember there was some issue with pytest-ipynb : https://foss.heptapod.net/fluiddyn/transonic/commit/37bc59df447f793cf24fa1b202528abb72c7f817
https://github.com/computationalmodelling/nbval
Source: https://nitter.snopyta.org/andreazonca/status/1256031999615102976#mhttps://foss.heptapod.net/fluiddyn/transonic/-/issues/35polymorphic methods supported?2020-05-05T20:41:08ZNeal Beckerpolymorphic methods supported?The following simple test seems to indicate that polymorphic class members are not supported.
It seems only the 2nd overload of __call__ works.
Is there a workaround?
---- constellation.py ---
```import numpy as np
from transonic impor...The following simple test seems to indicate that polymorphic class members are not supported.
It seems only the 2nd overload of __call__ works.
Is there a workaround?
---- constellation.py ---
```import numpy as np
from transonic import boost
A = "complex[:]"
S = "int[:]"
@boost
class constellation:
map: A
def __init__(self, map: A):
self.map = map
@boost
def __call__(self, s: int):
return self.map[s]
@boost
def __call__(self, syms: S):
out = np.empty(len(syms), dtype=complex)
for i in range (len (syms)):
out[i] = self.map[syms[i]]
return out
```
--- test_constellation.py ---
```
from constellation import constellation
import numpy as np
A = np.array
u = A([1+0j, -1+0j])
c = constellation (u)
syms = A ([0,1])
xconst = c(syms)
x = c(0)
```
```
---> 11 x = c(0)
<string> in new_method(self, syms)
TypeError: Invalid call to pythranized function `__for_method__constellation____call__(complex128[:], int)'
Candidates are:
- __for_method__constellation____call__(complex128[:], int[:])
```https://foss.heptapod.net/fluiddyn/transonic/-/issues/36Numpy bool arrays don't work with Pythran backend2020-05-15T20:12:14ZDaniel MouritzenNumpy bool arrays don't work with Pythran backendIt doesn't seem to be possible to pass a bool array to a jit-compiled function with the Pythran backend. I didn't try with other backends. Here's an example:
```python
import numpy as np
from transonic import jit, Array, wait_for_all_ex...It doesn't seem to be possible to pass a bool array to a jit-compiled function with the Pythran backend. I didn't try with other backends. Here's an example:
```python
import numpy as np
from transonic import jit, Array, wait_for_all_extensions, typeof
@jit
def test1(a: Array[bool, "2d"]):
return np.any(a)
@jit
def test2(a: Array[np.bool_, "2d"]):
return np.any(a)
a=np.zeros((3, 3), dtype=bool)
print(typeof(a).dtype) # <class 'numpy.bool_'>
test1(a)
test2(a)
wait_for_all_extensions()
# test1(a) # RuntimeError: Error while compiling code generated by Transonic.
# test2(a) # RuntimeError: Error while compiling code generated by Transonic.
```
Here's the full error:
```
ERROR: Error! File /home/daniel/.transonic/pythran/__jit__/__ipython__2a84652c03a07addf471009730705153/test1_e01fe91fc194dbb64a836622629125ff_39043f4db47a419004b852bfb822da1d.cpython-37m-x86_64-linux-gnu.so has not been created by pythran
Pythran stderr:
CRITICAL: I am in trouble. Your input file does not seem to match Pythran's constraints...
E: Invalid Pythran spec near 'bool_' (line 2)
```https://foss.heptapod.net/fluiddyn/transonic/-/issues/37User-defined types in signatures in comments2020-06-11T14:11:07ZPierre AugierUser-defined types in signatures in comments```
from transonic import boost
T = float
# transonic def func(T)
@boost
def func(a):
return 2 * a
```
leads to
```
Traceback (most recent call last):
File "/home/pierre/.pyenv/versions/3.8.2/bin/transonic", line 11, in <module>
...```
from transonic import boost
T = float
# transonic def func(T)
@boost
def func(a):
return 2 * a
```
leads to
```
Traceback (most recent call last):
File "/home/pierre/.pyenv/versions/3.8.2/bin/transonic", line 11, in <module>
load_entry_point('transonic', 'console_scripts', 'transonic')()
File "/home/pierre/Dev/transonic/transonic/run.py", line 85, in run
backend.make_backend_files(paths, force=args.force)
File "/home/pierre/Dev/transonic/transonic/backends/base.py", line 76, in make_backend_files
path_out = self.make_backend_file(path, analyse, force=force)
File "/home/pierre/Dev/transonic/transonic/backends/base.py", line 131, in make_backend_file
code_backend, codes_ext, code_header = self._make_backend_code(
File "/home/pierre/Dev/transonic/transonic/backends/base.py", line 189, in _make_backend_code
signatures_func = self._make_header_1_function(fdef, annotations)
File "/home/pierre/Dev/transonic/transonic/backends/base.py", line 460, in _make_header_1_function
return self._make_header_from_fdef_annotations(
File "/home/pierre/Dev/transonic/transonic/backends/base.py", line 472, in _make_header_from_fdef_annotations
compute_signatures_from_typeobjects(annot, self.type_formatter)
File "/home/pierre/Dev/transonic/transonic/signatures.py", line 56, in compute_signatures_from_typeobjects
type_ = str2type(type_)
File "/home/pierre/Dev/transonic/transonic/typing.py", line 922, in str2type
raise ValueError(f"Can't determine the Transonic type from '{str_type}'")
ValueError: Can't determine the Transonic type from 'T'
```
It's silly because it works fine with blocs! And it can be very useful! See https://foss.heptapod.net/fluiddyn/fluidsim/merge_requests/156
Pierre AugierPierre Augierhttps://foss.heptapod.net/fluiddyn/transonic/-/issues/38UI/UX using rich: progress bar, logging2020-11-13T18:31:46ZAshwin V. MohananUI/UX using rich: progress bar, loggingWe could add some visual feedback while compiling many extensions. The `rich` library is particularly good. See the [progress bar example](https://github.com/willmcgugan/rich#progress-bars). I think we can add them here: https://foss.hep...We could add some visual feedback while compiling many extensions. The `rich` library is particularly good. See the [progress bar example](https://github.com/willmcgugan/rich#progress-bars). I think we can add them here: https://foss.heptapod.net/fluiddyn/transonic/-/blob/48c5fd9224665d88fba90586edca91309f21961b/transonic/compiler.py#L77-106. Isn't it
Note that `rich` can replace the `colorlog` package as [shown here](https://github.com/willmcgugan/rich#logging-handler).MaintainenceAshwin V. MohananAshwin V. Mohananhttps://foss.heptapod.net/fluiddyn/transonic/-/issues/39Typing improvements: annotations and numpy.typing2021-02-08T09:45:40ZAshwin V. MohananTyping improvements: annotations and numpy.typingThere are two major updates:
- Type hints can be more concise due to two new PEPs. This may be handled by the AST parser, but should be checked.
- Numpy officially supports type-annotations starting v1.20. At some point we should transi...There are two major updates:
- Type hints can be more concise due to two new PEPs. This may be handled by the AST parser, but should be checked.
- Numpy officially supports type-annotations starting v1.20. At some point we should transition `transonic.typing` towards that / support them additionally.
See: https://www.scivision.dev/mypy-pep-585-604/https://foss.heptapod.net/fluiddyn/transonic/-/issues/40Unexpected behavior of @jit and @boost2021-04-16T09:52:58ZJingyang WangUnexpected behavior of @jit and @boostRecently I tested transonic with this simple code:
transonic_test.py
```python
import numpy as np
from transonic import jit,boost
#transonic def norming(float[])
@boost
def norming(np_array):
norm_array = np.linalg.norm(np_array,...Recently I tested transonic with this simple code:
transonic_test.py
```python
import numpy as np
from transonic import jit,boost
#transonic def norming(float[])
@boost
def norming(np_array):
norm_array = np.linalg.norm(np_array, axis=1)
return norm_array
```
I use this command to compile it ahead-of-time:
```bash
transonic transonic_test.py -af "-march=native -DUSE_XSIMD -Ofast"
```
which ran successfully. However, when I execute the following program
transonic_test_main.py
```python
from transonic_test import *
from timeit import default_timer as timer
start_1 = timer()
for i in range(1000):
in_arr = np.random.rand(10000, 3)
norm_arr = norming(in_arr)
end_1 = timer()
print("time spent are {}".format(end_1 - start_1))
```
with python, the output shows:
```
DEBUG Using rich for tracking progress.
WARNING Pythran file does not seem to be up-to-date:
<module '__pythran__.transonic_test_4f3187f787722cc89a00775cc0002503' from '/Users/jw598/Desktop/high_entropy_
alloy/__pythran__/transonic_test_4f3187f787722cc89a00775cc0002503.cpython-37m-darwin.so'>
func: norming
time spent are 0.3765912619999999
```
with the timing almost the same as pure python. This problem is identical to the one reported here:\
https://stackoverflow.com/questions/64857530/transonic-run-python-code-instead-of-pythran
My system configuration is:
OS: MacOS Catalina 10.15.7\
gcc: 10.2.0\
python: 3.7.7\
pythran: 0.9.8.post2\
transonic: 0.4.7.post0
Thanks a lot!
Jingyang Wang