2010/7/16 Benny Malengier <[email protected]>
>
>
> 2010/7/16 Benny Malengier <[email protected]>
>
>> I hit a much more problematic thing with this numpy.
>>
>> The code
>>
>> from fipy.meshes.numMesh.grid2D import Grid2D
>> mesh = Grid2D(dx=0.1, dy=0.1, nx=10, ny=10)
>> ap = CellVariable(mesh=mesh, value=0.01)
>> coeff = mesh._getFaceAreas() * mesh._getCellDistances() / \
>> ap.getArithmeticFaceValue()
>> print 'coval', type(coeff), type(coeff.getValue())
>>
>> Now fails with:
>> AttributeError: 'MaskedArray' object has no attribute 'getValue'
>>
>> So coeff is a MaskedArray, while on older numpy it is the expected binOp
>>
>> I'm investigating what is causing it.
>>
>
> Note that above fragment is from the stokescavity example. Changing the
> code to:
>
> coeff = 1/ ap.getArithmeticFaceValue() * mesh._getFaceAreas() *
> mesh._getCellDistances()
>
> works around it. It might be a bug in numpy trunk or it is due to new
> features.
>
I'll stop investigating. My guess is that in numpy/ma/core.py the function:
get_data
does not fail, so the wrong operation is done. mesh._getFaceAreas() is a
masked array after all. This can be seen by looking at the code:
try:
data = a._data
except AttributeError:
data = np.array(a, copy=False, subok=subok)
where here a is the ap.getArithmeticFaceValue() , which will work, as the
variable allows downcasting to an np.array.
So the fix would be to not allow casting to array automatically for a
variable. Not idea if that is a problem for fipy.
As some proof for this statement,
see get_data in 1.2.1
http://projects.scipy.org/numpy/browser/tags/1.2.1/numpy/ma/core.py?rev=5972
as opposed to trunk version:
http://projects.scipy.org/numpy/browser/trunk/numpy/ma/core.py
The AttributeError catch is new.
Benny
> Benny
>
>
>
>> Benny
>>
>> 2010/7/15 Jonathan Guyer <[email protected]>
>>
>>
>>>
>>> On Jul 15, 2010, at 3:02 AM, Benny Malengier wrote:
>>>
>>> > It seems ndarray has a dot function now in numpy trunk, updated my
>>> numpy and fipy crashes like ...
>>>
>>> Thanks for the alert
>>>
>>>
>>>
>>>
>>
>