← Back to team overview

dolfin team mailing list archive

Re: Work on Expression

 

On Saturday 28 November 2009 10:30:21 Anders Logg wrote:
> On Sat, Nov 28, 2009 at 10:24:43AM -0800, Johan Hake wrote:
> > On Saturday 28 November 2009 00:53:51 Anders Logg wrote:
> > > On Fri, Nov 27, 2009 at 11:59:52PM -0800, Johan Hake wrote:
> > > > Hello!
> > > >
> > > > I have not pushed anything, but Expressions should be up to shape
> > > > now, and I am working on simplifying the logic in other places of
> > > > expression.py
> > > >
> > > > I do not like the implementation of the dim method. It is used to
> > > > read a user defined value dimension and then discarded. I suggest
> > > > that we add a value_shape attribute to the dolfin.Expression class.
> > > > If not set by the user it is by default (), i.e., a scalar
> > > > Expression.
> > > >
> > > >   class MyExpression(Expression):
> > > >       value_shape = (2,)
> > > >       def eval(self, values, x):
> > > >          values[0] = 1
> > > >          values[1] = 1
> > > >
> > > > The dim name is also only making sense for Vector Expressions, where
> > > > I think a value_shape attribute makes sense for all occasions. A
> > > > value_shape for scalar Expression will still be the default.
> > >
> > > I think a dim method makes more sense than adding a variable since it
> > > is consistent with eval: Then all data a subclassed Expression needs
> > > to give is defined by a member function.
> >
> > Ok, but then I think we should keep it and not just pop it from the
> > dictionary, so a user can use it after the class is created.
> 
> I just tried follow your lead. I didn't even consider popping it would
> remove it.

Everything that are in the dict will be the new class's attributes and 
methods. If something is poped it is not there. I pop the __init__ because 
that is not the "real" __init__ method that is used. However it is called in 
the end of the "real" init method.

> > Is it very intuitive that dim stands for value dimension? Should we call
> > it value_dim or value_dimension?
> 
> Maybe not, but dim is nice and short, and it's less formal than
> value_rank and value_dimension. So I'd say it should be named dim.

Ok.

Johan



References