← Back to team overview

dolfin team mailing list archive

Re: Item assignment to matrices and vectors

 

Anders Logg skrev den 03/04-2008 følgende:
> On Thu, Apr 03, 2008 at 07:31:52PM +0200, Anders Logg wrote:
> > On Thu, Apr 03, 2008 at 07:28:51PM +0200, Ilmar Wilbers wrote:
> > >  > No I get this error:
> > >  > > Initializing PETSc (ignoring command-line arguments).
> > >  > > Traceback (most recent call last):
> > >  > >    File "demo.py", line 12, in <module>
> > >  > >      A[0, 0] = 4.0
> > >  > > TypeError: 'PETScMatrix' object does not support item assignment
> > > 
> > > In that case, you need to rebuild your swig-wrappers.
> > > 
> > > Ola
> > > 
> > > -------
> > > 
> > > The above is what Ola answered be. Doing a clean worked.
> > > 
> > > ilmar
> > 
> > ok, I'll try. I did a clean as late as this afternoon.
> 
> Still the same after
> 
>   scons -c
>   ./scons.local enableSlepc=no (shouldn't affect assignment)

Someone has renamed set_index in GenericMatrix to set. Due to a bug(?) in SWIG,
overloading methods of base classes removes the non-overloaded versions from
the wrapper interface:

class Foo {
  public:
    Foo();
    virtual void bar();
    virtual void bar(int i);
};

class Bar: public Foo {
  public:
    Bar();
    virtual void bar();
};

Now, in Python:

b = Bar()
b.bar(i) # Error

Hence, I named the method set_index to get around this bug.

Ola

> -- 
> Anders
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/mailman/listinfo/dolfin-dev


References