2008/7/8 Johan Hake <[EMAIL PROTECTED]>: > On Monday 07 July 2008 11:28:40 Martin Sandve Alnæs wrote: > I had a general python-sequence to std::vector<number> typemap laying waiting > to be used. I have added an in-typemap for any python sequence for Array<uin> > and Array<real>. The typemap will take any python sequence and copying it to > either an Array<uint> or an Array<real>. An exception is raised if any of > the elements in the input sequence is not a number. > > The following is now possible: > f = Function(mesh, (1.0, 2.0, 3.0)) > f = Function(mesh, [2,2], numpy.array([1.0, 2.0, 3.0, 4.0])) > > and if one do: > f = Function(mesh, (2,2), (1.0, 2.0, 3.0, "jada")) > > one will get > <type 'exceptions.ValueError'>: *** Error: Sequence elements must be numbers
Perfect! > I have also out-typemaps for the same structures, then returning a numpy > array. But as there could potentially be quite large such arrays, from e.g. > some of the mesh data, and the data is copied, I was not sure of adding this. > On the other hand an out-typemap will sure make the python interface a bit > smoother and coping the underlaying data we ensure that no data is either > lost or leaked. > > Johan Not sure if that is necessary anywhere, we already can get e.g. Vector contents or Mesh coordinates out as numpy arrays. -- Martin _______________________________________________ DOLFIN-dev mailing list [email protected] http://www.fenics.org/mailman/listinfo/dolfin-dev
