← Back to team overview

dolfin team mailing list archive

Re: Fwd: [Branch ~dolfin-core/dolfin/trunk] Rev 7064: Add unit test for float(Function(R)).

 

On Fri, Nov 02, 2012 at 10:29:42AM +0000, Garth N. Wells wrote:
> I has to comment this test out because it breaks the buildbot in parallel.

Wouldn't it be better to just add a check if MPI.num_processes() > 1?
So we test it in serial.

--
Anders


> ---------- Forwarded message ----------
> From:  <noreply@xxxxxxxxxxxxx>
> Date: Thu, Nov 1, 2012 at 9:33 AM
> Subject: [Branch ~dolfin-core/dolfin/trunk] Rev 7064: Add unit test
> for float(Function(R)).
> To: Garth Wells <gnw20@xxxxxxxxx>
>
>
> ------------------------------------------------------------
> revno: 7064
> committer: Martin Sandve Alnæs <martinal@xxxxxxxxx>
> branch nick: work
> timestamp: Thu 2012-11-01 10:32:53 +0100
> message:
>   Add unit test for float(Function(R)).
> modified:
>   test/unit/function/python/Function.py
>
>

> === modified file 'test/unit/function/python/Function.py'
> --- test/unit/function/python/Function.py	2012-08-24 11:33:59 +0000
> +++ test/unit/function/python/Function.py	2012-11-01 09:32:53 +0000
> @@ -24,6 +24,7 @@
>  from dolfin import *
>
>  mesh = UnitCube(8, 8, 8)
> +R = FunctionSpace(mesh, 'R', 0)
>  V = FunctionSpace(mesh, 'CG', 1)
>  W = VectorFunctionSpace(mesh, 'CG', 1)
>
> @@ -50,6 +51,16 @@
>
>          self.assertTrue(all(u_values==1))
>
> +    def test_float_conversion(self):
> +        c = Function(R)
> +        self.assertTrue(float(c) == 0.0)
> +        c.vector()[:] = 1.23
> +        self.assertTrue(float(c) == 1.23)
> +        c.assign(Constant(2.34))
> +        self.assertTrue(float(c) == 2.34)
> +        c = Constant(3.45)
> +        self.assertTrue(float(c) == 3.45)
> +
>  class Interpolate(unittest.TestCase):
>
>      def test_interpolation_mismatch_rank0(self):
> @@ -74,12 +85,12 @@
>          if MPI.num_processes() == 1:
>              mesh1 = UnitSquare(3,3)
>              V1 = FunctionSpace(mesh1, "CG", 1)
> -
> +
>              parameters["allow_extrapolation"] = True
>              f1 = Function(V1)
>              f1.vector()[:] = 1.0
>              self.assertAlmostEqual(f1(0.,-1), 1.0)
> -
> +
>              mesh2 = UnitTriangle()
>              V2 = FunctionSpace(mesh2, "CG", 1)
>
>

> _______________________________________________
> Mailing list: https://launchpad.net/~dolfin
> Post to     : dolfin@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dolfin
> More help   : https://help.launchpad.net/ListHelp



Follow ups

References