← Back to team overview

dolfin team mailing list archive

Re: [HG DOLFIN] Work on consistent handling of output (info/str) and removal of disp() functions.

 

On Monday 10 August 2009 13:51:43 Anders Logg wrote:
> On Mon, Aug 10, 2009 at 01:49:02PM +0200, Johan Hake wrote:
> > On Monday 10 August 2009 13:02:00 Anders Logg wrote:
> > > On Mon, Aug 10, 2009 at 12:27:35PM +0200, Johan Hake wrote:
> > > > On Monday 10 August 2009 00:20:02 DOLFIN wrote:
> > > > > One or more new changesets pushed to the primary dolfin repository.
> > > > > A short summary of the last three changesets is included below.
> > > > >
> > > > > changeset:   6677:978ee2bc8f9f5ee3f383f2268b6d9504b9e1c551
> > > > > tag:         tip
> > > > > user:        Anders Logg <logg@xxxxxxxxx>
> > > > > date:        Mon Aug 10 00:19:52 2009 +0200
> > > > > files:       dolfin/common/Variable.cpp dolfin/common/Variable.h
> > > > > dolfin/log/log.cpp dolfin/log/log.h dolfin/mesh/Mesh.cpp
> > > > > dolfin/mesh/Mesh.h dolfin/mesh/MeshConnectivity.cpp
> > > > > dolfin/mesh/MeshConnectivity.h dolfin/mesh/MeshData.cpp
> > > > > dolfin/mesh/MeshData.h
> > > > > dolfin/mesh/MeshGeometry.cpp dolfin/mesh/MeshGeometry.h
> > > > > dolfin/mesh/MeshTopology.cpp dolfin/mesh/MeshTopology.h
> > > > > dolfin/mesh/UnitSquare.cpp dolfin/parameter/Parameters.cpp
> > > > > dolfin/parameter/Parameters.h dolfin/swig/dolfin_log_post.i
> > > > > dolfin/swig/ignores.i misc/utils/emacs/macros description:
> > > > > Work on consistent handling of output (info/str) and removal of
> > > > > disp() functions. Currently disabled because of problems with
> > > > > Python interface. SWIG wizards can try replacing the info function
> > > > > in log.h/cpp with the commented out version.
> > > >
> > > > I can look into this.
> > >
> > > Great. I've been trying this morning and keep getting things like
> > >
> > > dolfin/swig/cpp_wrap.cc: In function ‘PyObject* _wrap__info(PyObject*,
> > > PyObject*)’: dolfin/swig/cpp_wrap.cc:30801: error: invalid conversion
> > > from ‘int’ to ‘PyObject*’
> > > dolfin/swig/cpp_wrap.cc:30653: error: too many arguments to function
> > > ‘PyObject* _wrap__info__SWIG_0(PyObject*, PyObject*)’
> > > dolfin/swig/cpp_wrap.cc:30801: error: at this point in file
> > > dolfin/swig/cpp_wrap.cc:30804: error: invalid conversion from ‘int’ to
> > > ‘PyObject*’
> > > dolfin/swig/cpp_wrap.cc:30723: error: too many arguments to function
> > > ‘PyObject* _wrap__info__SWIG_1(PyObject*, PyObject*)’
> > > dolfin/swig/cpp_wrap.cc:30804: error: at this point in file
> > >
> > > > It is natural that
> > > >
> > > >   print v
> > > >
> > > > only print the non verbose version of v, right?
> > >
> > > Yes!
> > >
> > > > This means that
> > > >
> > > >   v.__str__()
> > > >
> > > > returns the nonverbose version of v.
> > >
> > > Yes!
> > >
> > > > We should also be able to print the verbose version with
> > > >
> > > >   info(v,True)
> > >
> > > Yes!
> > >
> > > > However I am not sure how we should let the user access the verbose
> > > > string of a variable. Is it enough to let
> > > >
> > > >   v.__str__(True)
> > > >
> > > > do that?
> > >
> > > Yes, that would be enough (and normal for Python).
> >
> > Ok it seems to work now. I noticed that MeshGeometry::str needs to be
> > updated. It now sends the output to cout instead of just returning the
> > string.
>
> Nice.
>
> I will look at the mesh classes. The output probably looks horrible
> since it's untested. It probably needs some work. It says pretty-pring
> after all...
>
> > > Once this works in Python, I can continue to remove all disp() and
> > > friend LogStream stuff from all classes. Each class will then just
> > > have a str() function and both LogStream (dolfin::cout) and info()
> > > should work through that.
> >
> > I will also fix verbose printing for Parameters. Comming soon.

I tried to do the same for the

  dolfin::info(const Parameters& parameters, bool verbose=false);

as I did for the 

  dolfin::info(const Variable& variable, bool verbose=false);

However I got the following annoying error message from gcc

dolfin/swig/cpp_wrap.cc: In function ‘PyObject* 
_wrap__info__SWIG_0__varargs__(PyObject*, PyObject*, PyObject*)’:
dolfin/swig/cpp_wrap.cc:31049: error: ISO C++ says that these are ambiguous, 
even though the worst conversion for the first is better than the worst 
conversion for the second:
./dolfin/log/log.h:40: note: candidate 1: void dolfin::info(const 
dolfin::Parameters&, bool)
./dolfin/log/log.h:31: note: candidate 2: void dolfin::info(std::string, ...)

The line that makes gcc complain is a simple call to info:

  dolfin::info(arg1,arg2);

Here arg1 is a std::string, which should invoke the info defined on log.h:31.

Johan


> ok!
>
> --
> Anders
>
> > Johan
> >
> > > > Johan
> > > >
> > > >
> > > >
> > > >
> > > > However I am not sure how we should treat the verbose versus non
> > > > verbose pretty print of Variables. It is natural that
> > > >
> > > >   print v
> > > >
> > > > should show the non verbose version of v, agree?
> > > >
> > > > > changeset:   6676:8100d370041064966d41b2b8764e5a7e0973c82b
> > > > > user:        Anders Logg <logg@xxxxxxxxx>
> > > > > date:        Sun Aug 09 22:46:45 2009 +0200
> > > > > files:       dolfin/common/utils.cpp dolfin/common/utils.h
> > > > > description:
> > > > > Add function for indenting block of text.
> > > > >
> > > > >
> > > > > changeset:   6675:9dbf316bc72543defc93f980c5ee76a0f7afb878
> > > > > parent:      6673:2f2e897f207eef6bc56117e58e337e0ee377cd67
> > > > > parent:      6674:168c1e3c74fc5a4e352cda28d894e2433023e17d
> > > > > user:        "Garth N. Wells <gnw20@xxxxxxxxx>"
> > > > > date:        Sun Aug 09 13:51:47 2009 +0100
> > > > > files:
> > > > > description:
> > > > > merge.
> > > > >
> > > > > -------------------------------------------------------------------
> > > > >--- For more details, visit http://www.fenics.org/hg/dolfin
> > > > > _______________________________________________
> > > > > DOLFIN-dev mailing list
> > > > > DOLFIN-dev@xxxxxxxxxx
> > > > > http://www.fenics.org/mailman/listinfo/dolfin-dev
> > > >
> > > > _______________________________________________
> > > > DOLFIN-dev mailing list
> > > > DOLFIN-dev@xxxxxxxxxx
> > > > http://www.fenics.org/mailman/listinfo/dolfin-dev




Follow ups

References