TypeError Exception in expressions with escript Data objects

Created by Lutz Gross on on 2009-03-24
Keywords:
numarray expressions
Last updated by:
Lutz Gross on on 2009-03-24

When performing a binary operation such as a+b where a is a numarray.NumArray object and b is an escript.Data object I get the error message

TypeError: UFunc arguments must be numarray, scalars or numeric sequences

What does it mean?

Unfortunatley there is a bug in numarray as binary operations in numarray don't handle non-numarray arguments properly. This stops python from calling an appropriate escript function to handle the problem namely by calling the corresponding add opertaor of the non-numarray argument. The only solution is to avoid any expression starting with a numarray object. Alternatively you can use the add, mult, div, power functions provided by escript. (Remark: python list objects handle type mismatches properly. You can write [1.,1.]+Vector(...) but not numarray.ones((2,))+Vector(...). Nevertheless, add([1.,1.],Vector(...)) and add(numarray.ones((2,)),Vector(...)) will do the job but don't look nice.).