← Back to team overview

dolfin team mailing list archive

Re: PyDOLFIN and parameter system

 

On Wed, Aug 27, 2008 at 11:27:33AM +0200, Martin Sandve Alnæs wrote:
> 2008/8/27 Garth N. Wells <gnw20@xxxxxxxxx>:
> >
> >
> > Anders Logg wrote:
> >> On Wed, Aug 27, 2008 at 10:03:33AM +0200, Martin Sandve Alnæs wrote:
> >>> 2008/8/27 Garth N. Wells <gnw20@xxxxxxxxx>:
> >>>> How do I set a parameter for an object in PyDOLFIN? I'd like to set
> >>>> Newton solver parameters in demo/nls/nonlinearpoisson/python/demo.py.
> >>>> The code
> >>>>
> >>>>     nonlinear_solver = NewtonSolver()
> >>>>     nonlinear_solver.dolfin_set("Newton maximum iterations", 50)
> >>> foo.dolfin_set is a rather strange name for this, what about
> >>> setParameter or setParam or something?
> >>
> >> It should be just get() and set(). It is in C++.
> >>
> >
> > Why aren't "get" and "set" automatically available for objects? I recall
> > that "global" get and set conflict with reserved names in Python, or
> > something along this line, hence the use of dolfin_get/set.
> >
> > Garth
> 
> Also, "get" and "set" without context is impossible to read
> any meaning from. Not good global names anyway.

I agree. That is why they are either named dolfin_get/dolfin_set (as
global function) or get/set as member functions (when there is a clear
context).

For example, it is obvious what the following code does:

  pde = LinearPDE(...)
  pde.set("Krylov absolute tolerance", 1e-10);

It's not necessary to do

  pde.setParameter("Krylov absolute tolerance", 1e-10);

-- 
Anders

Attachment: signature.asc
Description: Digital signature


Follow ups

References