On Aug 15, 2008, at 1:54 PM, Zhiwen Liang wrote:
Dear Fipy Developers,
Thanks again for solving my problem last time. I ran into some error
when I tried to translate a mesh to another position. Please see the
following lines:
>>> from fipy import *
>>> mesh1=Grid2D(nx=2,ny=2)
>>> mesh2=mesh1+(0,2)
>>> mesh2.getCellCenters()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.5/site-packages/FiPy-2.0a1-py2.5.egg/fipy/
meshes/numMesh/uniformGrid2D.py", line 358, in getCellCenters
return centers.reshape((2, self.numberOfCells), order="FORTRAN")
+ self.origin
ValueError: shape mismatch: objects cannot be broadcast to a single
shape
Hi Zhiwen,
A quick fix is to change the origin you're adding to the mesh. As the
traceback shows, the code is trying to add centers (reshaped into a 2
x N matrix) with the new origin. So thinking in terms of numpy arrays,
you should be adding a 2 x 1 vector to get the correct output. In
other words:
>>> mesh2=mesh1+ array([[0.],[2.]])
This change gives me the expected output. You could argue that FiPy
should coerce `origin` to this format automatically, but then again
such input handling can often lead to annoying and hard to find bugs.
I'm sure the FiPy developers would know better than I do.
Hope that helps.
-Tony
I wonder if anybody has seen this. You might have known it from the
error that the fipy version is 2.0a1 and python version is 2.5. I am
running this on a Mac OS X 10.5.4. And the Scipy version is 0.6.0,
numpy version is 1.0.1.
Thank you in advance for any advice.
Regards,
Zhiwen