Jul-13-2021, 10:54 AM
The problem is that profile2csv was written 10 years ago, only for python 2, so needs a python 3 version
however if compyle is installed for python 3, there is a fix for that.
Make sure you use python 3 for all (i used 3.9.6)
Here's how I tested (see notes at end for fix)
Note all of this done on Linux-mint 20 using python 3.9.6
All steps are included for clarity - please excuse.
I didn't expand e, but didn't need to, the exercise is to make sure all works
So, my guess is that after you install PySPH, reinstall complye and then try your code.
Hope this works for you
however if compyle is installed for python 3, there is a fix for that.
Make sure you use python 3 for all (i used 3.9.6)
Here's how I tested (see notes at end for fix)
Note all of this done on Linux-mint 20 using python 3.9.6
All steps are included for clarity - please excuse.
- Created a test project:
- Start a terminal session.
- Create directory:
mkdir TestCompyle
- change dir:
cd TestCompyle
- create a virtual environment:
python -m venv venv
- Activate virtual environment:
. ./venv/bin/activate
- install pycompyle:
pip install compyle
- Create 'src' directory:
mkdir src
- add __init__.py to TestCompyle and src directory:
touch __init__.py
touch ./src/__init__.py
- Start a terminal session.
- add this script to src directory name it SimpleExample.py:
from compyle.api import Elementwise, annotate, wrap, get_config import numpy as np @annotate def axpb(i, x, y, a, b): y[i] = a*sin(x[i]) + b x = np.linspace(0, 1, 10000) print(f"x unmodified: {x}") y = np.zeros_like(x) print(f"y unmodified: {y}") a, b = 2.0, 3.0 print(f"a unmodified: {a}, b unmodified: {b}") backend = 'cython' get_config().use_openmp = True x, y = wrap(x, y, backend=backend) print(f"x after wrap: {x}, y after wrap: {y}") e = Elementwise(axpb, backend=backend) e(x, y, a, b) print(f"e: {e}")
- run script:
python src/SimpleExample.py
- results are:
Output:x unmodified: [0.00000000e+00 1.00010001e-04 2.00020002e-04 ... 9.99799980e-01 9.99899990e-01 1.00000000e+00] y unmodified: [0. 0. 0. ... 0. 0. 0.] a unmodified: 2.0, b unmodified: 3.0 x after wrap: [0.00000000e+00 1.00010001e-04 2.00020002e-04 ... 9.99799980e-01 9.99899990e-01 1.00000000e+00], y after wrap: [0. 0. 0. ... 0. 0. 0.] e: <compyle.parallel.Elementwise object at 0x7f6c9ef85eb0>
I didn't expand e, but didn't need to, the exercise is to make sure all works
So, my guess is that after you install PySPH, reinstall complye and then try your code.
Hope this works for you