[pythran] Re: %matplotlib instruction crashes pythran.magic

  • From: Pierre Navaro <pierre.navaro@xxxxxxxxxxxxxxx>
  • To: "pythran@xxxxxxxxxxxxx" <pythran@xxxxxxxxxxxxx>
  • Date: Fri, 25 Oct 2019 11:14:30 +0200


I made some test and it is an OSX problem only with Python 3.7
It works well with Python 3.6

$ conda create -n pythran python=3.6
$ conda activate pythran
$ conda install -yq ipython matplotlib pythran -c conda-forge
$ ipython
Python 3.6.7 | packaged by conda-forge | (default, Jul  2 2019, 02:07:37)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.8.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: %matplotlib
Using matplotlib backend: MacOSX

In [2]: %load_ext pythran.magic

In [3]: %%pythran
   ...:
   ...: import numpy as np
   ...:
   ...: #pythran export test_pythran(float64[], float64[])
   ...: def test_pythran(x, y):
   ...:     """
   ...:     returns Julia set
   ...:     """
   ...:     z = np.zeros((x.size, y.size), dtype=np.float64)
   ...:
   ...:     #omp parallel for private(z)
   ...:     for j in range(y.size):
   ...:         for i in range(x.size):
   ...:             z[j,i] = x[i] + y[j]
   ...:
   ...:     return z
   ...:

In [4]: import numpy as np

In [5]: x, y = np.ones(10), np.ones(10)

In [6]: test_pythran(x, y)
Out[6]:
array([[2., 2., 2., 2., 2., 2., 2., 2., 2., 2.],
       [2., 2., 2., 2., 2., 2., 2., 2., 2., 2.],
       [2., 2., 2., 2., 2., 2., 2., 2., 2., 2.],
       [2., 2., 2., 2., 2., 2., 2., 2., 2., 2.],
       [2., 2., 2., 2., 2., 2., 2., 2., 2., 2.],
       [2., 2., 2., 2., 2., 2., 2., 2., 2., 2.],
       [2., 2., 2., 2., 2., 2., 2., 2., 2., 2.],
       [2., 2., 2., 2., 2., 2., 2., 2., 2., 2.],
       [2., 2., 2., 2., 2., 2., 2., 2., 2., 2.],
       [2., 2., 2., 2., 2., 2., 2., 2., 2., 2.]])

On 25 Oct 2019, at 10:59, Pierre Navaro <pierre.navaro@xxxxxxxxxxxxxxx> wrote:

Thanks Ashwin

It seems there is a lot of problems on macosx, i just tried with miniconda

$ conda create -n pythran python=3.7
$ conda activate pythran
$ conda install pythran -c conda-forge
$ python
Python 3.7.3 | packaged by conda-forge | (default, Jul  1 2019, 14:38:56)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
import pythran
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File 
"/opt/miniconda3/envs/pythran/lib/python3.7/site-packages/pythran/__init__.py",
 line 40, in <module>
    from pythran.toolchain import (generate_cxx, compile_cxxfile, 
compile_cxxcode,
  File 
"/opt/miniconda3/envs/pythran/lib/python3.7/site-packages/pythran/toolchain.py",
 line 6, in <module>
    from pythran.backend import Cxx, Python
  File 
"/opt/miniconda3/envs/pythran/lib/python3.7/site-packages/pythran/backend.py",
 line 8, in <module>
    from pythran.analyses import LocalNodeDeclarations, GlobalDeclarations, 
Scope
  File 
"/opt/miniconda3/envs/pythran/lib/python3.7/site-packages/pythran/analyses/__init__.py",
 line 12, in <module>
    from .aliases import Aliases, StrictAliases
  File 
"/opt/miniconda3/envs/pythran/lib/python3.7/site-packages/pythran/analyses/aliases.py",
 line 6, in <module>
    from pythran.syntax import PythranSyntaxError
  File 
"/opt/miniconda3/envs/pythran/lib/python3.7/site-packages/pythran/syntax.py", 
line 7, in <module>
    from pythran.tables import MODULES
  File 
"/opt/miniconda3/envs/pythran/lib/python3.7/site-packages/pythran/tables.py", 
line 173, in <module>
    BINARY_UFUNC = {"accumulate": FunctionIntr()}
  File 
"/opt/miniconda3/envs/pythran/lib/python3.7/site-packages/pythran/intrinsic.py",
 line 94, in __init__
    super(FunctionIntr, self).__init__(**kwargs)
  File 
"/opt/miniconda3/envs/pythran/lib/python3.7/site-packages/pythran/intrinsic.py",
 line 58, in __init__
    [to_ast(d) for d in kwargs.get('defaults', [])])
  File 
"/opt/miniconda3/envs/pythran/lib/python3.7/site-packages/gast/gast.py", line 
19, in create_node
    format(Name, nbparam, len(Fields))
AssertionError: Bad argument number for arguments: 6, expecting 7


On 25 Oct 2019, at 10:38, Ashwin Vishnu <avmo@xxxxxx <mailto:avmo@xxxxxx>> 
wrote:

Hi Pierre,

It is a strange error, I don't have a Mac so I am not 100% sure. I followed 
what you did on Linux
with a small variation:

In [1]: %matplotlib
Using matplotlib backend: TkAgg

And it works well. This is not a solution, but could you try a different 
matplotlib backend 
(https://matplotlib.org/tutorials/introductory/usage.html?#backends ;
<https://matplotlib.org/tutorials/introductory/usage.html?#backends>)?

Cheers,
Ashwin

On 10/25/19 10:25 AM, Pierre Navaro wrote:
Using matplotlib backend: MacOSX



Pierre Navaro
Ingénieur CNRS en calcul scientifique
IRMAR, Campus de Beaulieu, bâtiment 22, bureau 112
263 avenue du Général Leclerc, CS 74205
35042  RENNES Cedex
0223234308
https://osm.org/go/eri2d0PNY ;<https://osm.org/go/eri2d0PNY>





Pierre Navaro
Ingénieur CNRS en calcul scientifique
IRMAR, Campus de Beaulieu, bâtiment 22, bureau 112
263 avenue du Général Leclerc, CS 74205
35042  RENNES Cedex
0223234308
https://osm.org/go/eri2d0PNY




Other related posts: