|
From: Paul B. <peb...@gm...> - 2005-11-02 13:50:27
|
Hi Alexander, I can't duplicate your problem using the patch. It works fine for me. However, I'm using numarray and not numeric. You might want to print out the types of the arrays on the left and right sides and use an astype() method to convert the right side to the type of the left side. -- Paul On 11/1/05, Alexander Mont <ale...@co...> wrote: > > I noticed that the pcolor function uses about twice as much memory as it > needs to. When creating the list of vertices, you first create the lists = X1, > Y1, X2, Y2, X3, Y3, X4, and Y4, and then combine those lists into the > "verts" list. I tried to change it to make it not waste memory by changin= g > the lines between the line: > mask =3D ma.getmaskarray(C)[0:Nx-1,0:Ny-1]+xymask > and > C =3D compress(ravel(mask=3D=3D0),ravel(ma.filled(C[0:Nx-1,0:Ny-1]))) > to the following: > > numVertices =3D len(compress(ravel(mask=3D=3D0),ravel(ma.filled(X[0:-1,0:= -1])))) > > verts =3D zeros((numVertices, 4, 2)) > > verts[:, 0, 0] =3D compress(ravel(mask=3D=3D0),ravel(ma.filled(X[0:-1,0:-= 1]))) > > verts[:, 0, 1] =3D compress(ravel(mask=3D=3D0),ravel(ma.filled(Y[0:-1,0:-= 1]))) > > verts[:, 1, 0] =3D compress(ravel(mask=3D=3D0),ravel(ma.filled(X[1:,0:-1]= ))) > > verts[:, 1, 1] =3D compress(ravel(mask=3D=3D0),ravel(ma.filled(Y[1:,0:-1]= ))) > > verts[:, 2, 0] =3D compress(ravel(mask=3D=3D0),ravel(ma.filled(X[1:,1:]))= ) > > verts[:, 2, 1] =3D compress(ravel(mask=3D=3D0),ravel(ma.filled(Y[1:,1:]))= ) > > verts[:, 3, 0] =3D compress(ravel(mask=3D=3D0),ravel(ma.filled(X[0:-1,1:]= ))) > > verts[:, 3, 1] =3D compress(ravel(mask=3D=3D0),ravel(ma.filled(Y[0:-1,1:]= ))) > > However it says that the "array cannot be safely cast to required type" > on the third line (verts[:, 0, 0] =3D ...). I have no idea why this is > happening because both arrays are the same length (numVertices). Does any= one > have any ideas how to fix this problem? > > Also, if I do get this working, is there a way to submit it as a patch? > Having a pcolor function that doesn't use up so much memory might be usef= ul > for lot of people, not just me. > > -Alex Mont > |