TypeError in expressions with escript Data objects

Asked by Lutz Gross

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?

Question information

Language:
English Edit question
Status:
Solved
For:
esys-escript Edit question
Assignee:
No assignee Edit question
Solved by:
Lutz Gross
Solved:
Last query:
Last reply:
Revision history for this message
Lutz Gross (l-gross) said :
#1

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 operator 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.

Revision history for this message
Lutz Gross (l-gross) said :
#2

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 operator 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.

Revision history for this message
Lutz Gross (l-gross) said :
#3

Lutz Gross suggests this article as an answer to your question:
FAQ #450: “TypeError in expressions with escript Data objects”.