def test_scalar_constant(): mesh = UnitCubeMesh(MPI.comm_world, 2, 2, 2) c = Constant(mesh, 1.0) assert c.value.shape == () assert c.value == 1.0 c.value += 1.0 assert c.value == 2.0 c.value = 3.0 assert c.value == 3.0
def test_wrong_dim(): mesh = UnitCubeMesh(MPI.comm_world, 2, 2, 2) c = Constant(mesh, [1.0, 2.0]) assert c.value.shape == (2, ) with pytest.raises(ValueError): c.value = [1.0, 2.0, 3.0]