- changed status to resolved
example ex5.py gives different behaviour in python3: needs SLEPc for complex numbers?
I've just released a python3 package of slec4py in Debian. Testing the slepc4py examples, I find some differences between running with python 2.7.13 and python 3.5.3.
Example tests 2, 4, 6 and 9-11 don't run in python3, "'xrange' is not defined". Just a syntax difference in python3, not a great problem.
Tests 1, 3, 7 and 8 give the same results in python2 and python3.
The big problem is ex5.py.
Running under python 2, the results are:
$ python ex5.py
Quadratic Eigenproblem, N=1024 (32x32 grid)
Number of iterations of the method: 27
Solution method: toar
Number of requested eigenvalues: 6
Stopping condition: tol=1e-08, maxit=195
Number of converged approximate eigenpairs: 6
k ||(k^2M+Ck+K)x||/||kx||
-------------------- -------------------------
0.000000+2.825223 j 3.39415e-09
0.000000-2.825223 j 3.39415e-09
0.000000+2.820426 j 1.71365e-09
0.000000-2.820426 j 1.71365e-09
0.000000+2.815620 j 7.37502e-09
0.000000-2.815620 j 7.37502e-09
Running under python3, the results are very different:
$ python3 ex5.py
Quadratic Eigenproblem, N=1024 (32x32 grid)
Number of iterations of the method: 195
Solution method: toar
Number of requested eigenvalues: 6
Stopping condition: tol=1e-08, maxit=195
Number of converged approximate eigenpairs: 4
k ||(k^2M+Ck+K)x||/||kx||
-------------------- -------------------------
-0.018532+2.643139 j 6.23014e-09
-0.018532-2.643139 j 6.23014e-09
0.018532+2.643139 j 4.98851e-09
0.018532-2.643139 j 4.98851e-09
I note that complex numbers are used here. Is that the reason for the difference? I have built slepc4py (and petsc4py) against SLEPc/PETSc configured for real numbers, not complex numbers. If that's the problem, then I guess this Issue is just a request for that to be documented in ex5.py.
Comments (4)
-
-
-
The fix is now in both master and maint. Thanks for reporting.
-
reporter Thanks Jose.
- Log in to comment
Modify some examples to work in both Python2 and Python3
Fixes issue
#28→ <<cset 6fdc10542bf7>>