← Back to team overview

dolfin team mailing list archive

Re: Mapping Array to Python

 

On Tuesday 23 February 2010 11:48:05 Anders Logg wrote:
> I thought that Array should be automagically mapped to Numpy arrays in
> Python. This doesn't happen for the new component() function I just
> added to FunctionSpace.
> 
> Test by
> 
>   mesh = UnitSquare(4, 4)
>   V = VectorFunctionSpace(mesh, "CG", 1)
>   print V.sub(0).component()

No they are not. 

I think we landed on doing this on case to case. You can just call 
V.sub(0).component().array(). 

The blueprint on the array typemap is not closed. There still exist some 
questions we need to sort out, including (I think) this one.

I cannot come up with a good example just now why we shouldn't just wrap all 
out Arrays to numpy arrays, but I think it had something to do with ownership 
and possibilities of returning an array that potentially might be resized.

Johan





Follow ups

References