← Back to team overview

dolfin team mailing list archive

Re: [Question #148576]: Gaussian random numbers

 

Question #148576 on DOLFIN changed:
https://answers.launchpad.net/dolfin/+question/148576

    Status: Open => Answered

Anders Logg proposed the following answer:
On Thu, Mar 10, 2011 at 02:30:39PM -0000, Achim Schroll wrote:
> New question #148576 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/148576
>
> Hi,
>
> has the random number generator changed since 0.9.8 ?
>
> in DOLFIN 0.9.8 the instructions following instructions worked fine
>
> from dolfin import *
> from random import *
>
> # random funtion
> class myrand(Expression):
>     def eval(self, values, x):
>         values[0] = gauss(0,1)
>
> # Create mesh and finite element
> mesh = UnitCircle(60)
> V = FunctionSpace(mesh, "CG", 1)
>
> unoise = Function(V)
> noise = myrand(V=V)
>
> but in the latest version 0.9.10 we get the error:
>
> Calling FFC just-in-time (JIT) compiler, this may take some time.
> Traceback (most recent call last):
>   File "noiser.py", line 23, in <module>
>     noise = myrand(V=V)
>   File "/usr/lib/python2.6/dist-packages/dolfin/function/expression.py", line 146, in __init__
>     raise TypeError, "expected only 'kwargs' from one of "\
> TypeError: expected only 'kwargs' from one of 'element', or 'degree'

It's the V=V that is the problem. Just remove that argument and it
should be fine.

--
Anders

-- 
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.