[SciPy-user] blitz error
josef.pktd at gmail.com
josef.pktd at gmail.com
Thu Apr 2 15:01:57 EDT 2009
On Wed, Apr 1, 2009 at 7:32 PM, Gideon Simpson <simpson at math.toronto.edu> wrote:
> I tried this little bit of code:
>
> def linear_p(qp_hat, qm_hat, vg, kappa, n1, il, ik):
>
> linp = np.zeros(qp_hat.shape) + 0.j
> expr = "linp = -vg * qp_hat * il + kappa * ik * n1 * qm_hat"
> weave.blitz(expr, check_size=1)
> return linp
>
> and got the following error:
>
> Traceback (most recent call last):
> File "./soliton1_blitz.py", line 185, in <module>
> k1p = filter(k1p) + linop_p(Ep_hat, Em_hat)
> File "./soliton1_blitz.py", line 79, in <lambda>
> vg, kappa, n1, il, ik)
> File "/Users/gideon/Code/CME/CMEops_blitz.py", line 10, in linear_p
> weave.blitz(expr, check_size=1)
> File "/opt/lib/python2.5/site-packages/scipy/weave/blitz_tools.py",
> line 62, in blitz
> **kw)
> File "/opt/lib/python2.5/site-packages/scipy/weave/
> inline_tools.py", line 462, in compile_function
> verbose=verbose, **kw)
> File "/opt/lib/python2.5/site-packages/scipy/weave/ext_tools.py",
> line 367, in compile
> verbose = verbose, **kw)
> File "/opt/lib/python2.5/site-packages/scipy/weave/build_tools.py",
> line 272, in build_extension
> setup(name = module_name, ext_modules = [ext],verbose=verb)
> File "/opt/lib/python2.5/site-packages/numpy/distutils/core.py",
> line 184, in setup
> return old_setup(**new_attr)
> File "/sw/lib/python2.5/distutils/core.py", line 168, in setup
> raise SystemExit, "error: " + str(msg)
> scipy.weave.build_tools.CompileError: error: Command "g++ -fno-strict-
> aliasing -mno-fused-madd -DNDEBUG -g -fwrapv -O3 -Wall -I/opt/lib/
> python2.5/site-packages/scipy/weave -I/opt/lib/python2.5/site-packages/
> scipy/weave/scxx -I/opt/lib/python2.5/site-packages/scipy/weave/blitz -
> I/opt/lib/python2.5/site-packages/numpy/core/include -I/sw/include/
> python2.5 -c /Users/gideon/.python25_compiled/
> sc_24bab5a447df6354e489345507f46f0d2.cpp -o /var/folders/yL/
> yLD5tRJiGWa7oyM6mWJUN++++TI/-Tmp-/gideon/python25_intermediate/
> compiler_eded75b75a17d5bc9afe97cc30cf08c0/Users/
> gideon/.python25_compiled/sc_24bab5a447df6354e489345507f46f0d2.o"
> failed with exit status 1
>
> Could it be because I'm using complex numbers?
>
> -gideon
>
from the test files for weave.blitz (test_blitz_tools.py)
def _check_5point_avg_2d_complex_float(self):
""" Note: THIS TEST is KNOWN TO FAIL ON GCC 3.x. It will not
adversely affect 99.99 percent of weave
result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]
+ b[1:-1,2:] + b[1:-1,:-2]) / 5.
Note: THIS TEST is KNOWN TO FAIL ON GCC 3.x. The reason is that
5. is a double and b is a complex32. blitz doesn't know
how to handle complex32/double. See:
http://www.oonumerics.org/MailArchives/blitz-support/msg00541.php
Unfortunately, the fix isn't trivial. Instead of fixing it, I
prefer to wait until we replace blitz++ with Pat Miller's code
that doesn't rely on blitz..
"""
expr = "result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]" \
"+ b[1:-1,2:] + b[1:-1,:-2]) / 5."
self.generic_2d(expr,complex64)
your script runs if I don't mix complex and float, or switch to
complex128, see below.
I don't know if the results are what you intended or if this is really
the source of your problem.
Josef
---------------------------------
import numpy as np
from scipy import weave
def linear_p(qp_hat, qm_hat, vg, kappa, n1, il, ik):
linp = np.zeros(qp_hat.shape) + 0.j
# in one case I got: TypeError: __neg__() takes exactly 2
arguments (1 given)
expr = "linp = 0.0 - vg * qp_hat * il + kappa * ik * n1 * qm_hat"
weave.blitz(expr, check_size=1)
return linp
qp_hat, qm_hat, vg, kappa, n1, il, ik = np.array([1+ 0.1j,1,1]),1,1,1,1,1,1
#print linear_p(qp_hat, qm_hat, vg, kappa, n1, il, ik)
# results in CompileError: error:
c = 1+ 0.1j
qp_hat, qm_hat, vg, kappa, n1, il, ik = np.array([1+ 0.1j,1,1]),c,c,c,c,c,c
print linear_p(qp_hat, qm_hat, vg, kappa, n1, il, ik)
#[-0.0299+0.097j -0.0499+0.196j -0.0499+0.196j]
c = 1.0
qp_hat, qm_hat, vg, kappa, n1, il, ik = np.array([1+
0.1j,1,1],'complex128'),c,c,c,c,c,c
print linear_p(qp_hat, qm_hat, vg, kappa, n1, il, ik)
#[ 0.-0.1j 0.+0.j 0.+0.j ]
More information about the SciPy-User
mailing list