← Back to team overview

dolfin team mailing list archive

Re: No data.x in overloaded Expression.eval_data

 

On Thursday 17 December 2009 03:13:13 David Beacham wrote:
> Johan Hake wrote:
> > On Wednesday 16 December 2009 10:18:50 David Beacham wrote:
> >> Johan Hake wrote:
> >>> On Wednesday 16 December 2009 09:28:21 David Beacham wrote:
> >>>> Hi,
> >>>>
> >>>> I'm not sure if it's my relative inexperience with python, but I can't
> >>>> find the coordinates x in data, when overloading eval_data in
> >>>> Expression. I'm guessing from doxygen/pydoc that they should be
> >>>> available?
> >>>
> >>> Have you tried:
> >>>
> >>>   x = data.x()
> >>
> >> No, I don't seem to have the Data.x() method either:
> >>
> >> (Pdb) p data.x()
> >> *** AttributeError: AttributeError("'Data' object has no attribute
> >> 'x'",)
> >>
> >> although everything else from the cpp side is showing up and is useable:
> >>
> >> (Pdb) p dir(data)
> >> ['__class__', '__delattr__', '__dict__', '__doc__', '__format__',
> >> '__getattribute__', '__hash__', '__init__', '__module__', '__new__',
> >> '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__',
> >> '__str__', '__subclasshook__', '__swig_destroy__', '__weakref__',
> >> 'cell', 'clear', 'facet', 'geometric_dimension', 'normal', 'on_facet',
> >> 'set', 'this', 'thisown', 'ufc_cell']
> >>
> >> FWIW, I can get Data.x to work in cpp.
> >
> > This should be fixed now.
> >
> > Johan
> 
> Thanks for this, I can now see data.x, but it isn't returning the
> correct information:
> 
> (Pdb) !z = data.x()
> (Pdb) z
> array([], dtype=float64)
> (Pdb) z.shape
> (0,)

David!

Can you run the unit test of function and see if it pass? At line 77 we test 
subclassing of Expression using the eval_data interface. The test pass on my 
computer.

If it pass, can you hand a minimal example that break, either just attach one 
or tweak the unit test.

Johan

> David
> 
> >>> We needed to make the x attribute a method returning the x array in
> >>> Python.
> >>>
> >>> Johan
> >>>
> >>>> David
> >>>>
> >>>> _______________________________________________
> >>>> Mailing list: https://launchpad.net/~dolfin
> >>>> Post to     : dolfin@xxxxxxxxxxxxxxxxxxx
> >>>> Unsubscribe : https://launchpad.net/~dolfin
> >>>> More help   : https://help.launchpad.net/ListHelp
> 



Follow ups

References