← Back to team overview

dolfin team mailing list archive

Re: str(), disp()

 

On Fri, May 08, 2009 at 01:41:37PM +0200, Ola Skavhaug wrote:
> On Fri, May 8, 2009 at 11:40 AM, Anders Logg <logg@xxxxxxxxx> wrote:
> > On Fri, May 08, 2009 at 11:19:35AM +0200, Anders Logg wrote:
> >> We currently have two ways to print object data to the screen in
> >> DOLFIN:
> >>
> >>   cout << foo << endl;
> >>
> >>   foo.disp()
> >>
> >> The first of these prints a nicely-formatted one-liner:
> >>
> >>   [Mesh of topological dimension 2 with 121 vertices and 200 cells]
> >>
> >> The second prints more detailed information:
> >>
> >> Mesh data
> >> ---------
> >>
> >>   Mesh topology
> >>   -------------
> >>
> >>     Topological dimension: 2
> >>
> >>     Number of entities:
> >>
> >>       dim = 0: 121
> >>       dim = 1: 0
> >>       dim = 2: 200
> >>
> >>     ...
> >>
> >>     Connectivity:
> >>
> >>         0 1 2
> >>       0 - - -
> >>       1 - - -
> >>       2 x - -
> >>
> >>     Connectivity 2 -- 0:
> >>
> >>       0: 0 1 12
> >>       1: 0 11 12
> >>       2: 1 2 13
> >>       3: 1 12 13
> >>
> >> I'm thinking we could add a method named str() to all classes and then
> >> call str() both from LogStream<< and from __str__ in Python.
> >>
> >> Should the disp() method remain as it is today or should it be renamed
> >> to something else? Maybe print()?
> >
> > Or maybe info() is more logical, since calling foo.info() will result
> > in a string being sent to the info() function.
> >
> 
> I like this idea. Will all dolfin classes inherit a pure virtual base
> class defining the str() method?
> 
> If that's the case, we can, optionally, provide a stream to which the
> info is written, e.g., cerr, cout, or a stringstream from Python.
> 
> Ola

We could do that. The obvious candidate would be the Variable class,
but I'm not sure what implications that has for the Python interface
(wrtshared pointers/Hake).

-- 
Anders

Attachment: signature.asc
Description: Digital signature


References