473,405 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Help with weave.blitz()

Hello,

I'm a new scipy user, and I'm trying to speed up some array code with
weave. I'm running xp with gcc from cgywin, and scipy.weave.test()
returns an OK status.

I'm trying to speed up the code below. I've found a couple of examples
of weave on the web, and I think it should be straight forward, but I
keep getting the following error when calling weave.blitz(expr). It's
complaining about the variable being assigned, I've tried listing it in
the blitz call with no luck.

Any help is appreciated.

PS I've also posted to scipy.org

Thank you,

Frank
***ERROR***

Traceback (most recent call last):
File "D:/Documents/Homework/MTMG310/Project/hw6r3VectorizeWeave.py",
line 436, in -toplevel-
prof.runcall(main)
File "C:\Python24\Lib\hotshot\__init__.py", line 76, in runcall
return self._prof.runcall(func, args, kw)
File "D:/Documents/Homework/MTMG310/Project/hw6r3VectorizeWeave.py",
line 383, in main
findw(w,wprior,phiprior,uprior,vprior)
File "D:/Documents/Homework/MTMG310/Project/hw6r3VectorizeWeave.py",
line 136, in findw
weave.blitz(expr)
File "C:\Python24\Lib\site-packages\scipy\weave\blitz_tools.py", line
35, in blitz
if check_size and not
size_check.check_expr(expr,local_dict,global_dict) :
File "C:\Python24\Lib\site-packages\scipy\weave\size_check.py", line
51, in check_expr
exec(expr,values)
File "<string>", line 1
wnext[1:grows-1,1:gcols-1] =( alpha * w[1:grows-1,1:gcols-1] + ax *
(w[1:grows-1,0:gcols-2] + w[1:grows-1,2:gcols]) +
^
SyntaxError: invalid syntax
***CODE***

def findw(wnext,wprior,phiprior,uprior,vprior):
#format here is x[i,j] where i's are rows, j's columns, use flipud()
to get the
#print out consistent with the spacial up-down directions

#assign local names that are more
#inline with the class notation
w = wprior
phi = phiprior
u = uprior
v = vprior
#three of the BC are known so just set them
#symetry plane
wnext[0,0:gcols] = 0.0

#upper wall
wnext[gN,0:gcols] = 2.0/gdy**2 * (phi[gN,0:gcols] -
phi[gN-1,0:gcols])

#inlet, off the walls
wnext[1:grows-1,0] = 0.0
upos = where(u>0)
vpos = where(v>0)

Sx = ones_like(u)
Sx[upos] = 0.0
xSx = 1.0 - Sx
Sy = ones_like(v)
Sy[vpos] = 0.0
ySy = 1.0 - Sy

uw = u*w
vw = v*w

ax = gnu*gdt/gdx**2
ay = gnu*gdt/gdy**2
dtdx = gdt/gdx
dtdy = gdt/gdy

alpha = (1.0 - 2.0*ax - 2.0*ay)
#interior nodes
expr = """ \
wnext[1:grows-1,1:gcols-1] =( alpha * w[1:grows-1,1:gcols-1] + ax *
(w[1:grows-1,0:gcols-2] + w[1:grows-1,2:gcols]) +
ay * (w[0:grows-2,1:gcols-1] +
w[2:grows,1:gcols-1]) -
dtdx * (xSx[1:grows-1,1:gcols-1] *
(uw[1:grows-1,1:gcols-1] - uw[1:grows-1,0:gcols-2]) -
Sx[1:grows-1,1:gcols-1] *
(uw[1:grows-1,2:gcols] - uw[1:grows-1,1:gcols-1])) -
dtdy * (ySy[1:grows-1,1:gcols-1] *
(vw[1:grows-1,1:gcols-1] - vw[1:grows-1,0:gcols-2]) -
Sy[1:grows-1,1:gcols-1] *
(vw[1:grows-1,2:gcols] - vw[1:grows-1,1:gcols-1])) )
"""
#weave.inline(expr,['wnext','w','Sx','xSx','Sy','ySy','uw','vw','ax',' ay','dtdx','dtdy','alpha','grows','gcols'])
#weave.inline(expr,['wnext'],compiler='gcc',verbose=2)

#weave.blitz(expr,['wnext','w','Sx','xSx','Sy','ySy','uw','vw','ax',' ay','dtdx','dtdy','alpha','grows','gcols'])
#weave.blitz(expr,size_check=1)
#weave.inline(expr,['wnext'])
weave.blitz(expr)

## for j in range(1,gasizej-1):
## for i in range(1,gasizei-1):
##
## wnext[i,j] =( w[i,j] + gnu*gdt/gdx**2 * (w[i,j-1] -
2.0*w[i,j] + w[i,j+1]) +
## gnu*gdt/gdy**2 * (w[i-1,j] - 2.0*w[i,j] +
w[i+1,j]) -
## (1.0 - Sx[i,j]) * gdt/gdx * (uw[i,j] -
uw[i,j-1]) -
## Sx[i,j] * gdt/gdx * (uw[i,j+1] - uw[i,j]) -
## (1.0 - Sy[i,j]) * gdt/gdy * (vw[i,j] -
vw[i-1,j]) -
## Sy[i,j] * gdt/gdy * (vw[i+1,j] - vw[i,j]) )

## print "***wnext****"
## print "i: ", i, "j: ", j, "wnext[i,j]: ", wnext[i,j]

#final BC at outlet, off walls
wnext[1:grows-1,gM] = wnext[1:grows-1,gM-1]

Dec 11 '06 #1
0 1538

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jacek Generowicz | last post by:
Does anyone happen to have up-to-date summary instructions for installing weave.inline ? I don't want weave.blitz, I don't want Numeric, and I don't want Scipy. According to the documentation,...
3
by: Michael Foord | last post by:
Has anyone had success using weave with gcc for windows (standard windows distribution python)? I have my distutils setup to use gcc (via mingw32) - which it does fine. I've compiled and...
16
by: JustSomeGuy | last post by:
I have a routine that evaluates a polynomial equation that have 3 variables x,y,z of orders 1,2,3 the coefficients of the polynomial are in an array. This routine is quite slow and I'd like to...
4
by: Rex_chaos | last post by:
Hi all, I am looking for a high-performance container(matrix and vector) for numerical computation. Someone recommended the boost::multi_array. After having looked at the documentation, I know...
6
by: Steven T. Hatton | last post by:
I bought Josuttis's book on the repeated recommendations of people in this newsgroup. http://www.josuttis.com/libbook/ One of the first things I looked up was the std::valarray<>. And what I...
0
by: zhuang | last post by:
Hi, I'm having some problems getting weave to work correctly. For now, I'm just testing how to access Numeric arrays under weave. My test code is: from Numeric import * import weave a =...
7
by: Guch Wu | last post by:
Array<unsigned char,2> A(10,10); unsigned char* rawdata; rawdata = new (unsinged char); Can I extract data in A to rawdata without using for loop?
2
by: dss | last post by:
I'm trying to compile some code that I downloaded. The code uses Blitz++ and tvmet to manipulate arrays. I have never worked with either of these, and I am having trouble getting both of these to...
2
by: Soren | last post by:
Hi, I have a strange and very annoying problem when using weave in scipy.. when I run the code below.. the first time it needs to compile.. it says <compilingand then python.exe crashes! and no...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.