Skip to content

Commit

Permalink
Fix autopep8.
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminRodenberg committed Aug 20, 2024
1 parent 98fcd95 commit b04e6c9
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions tests/unit/test_checkpointing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def test_solverstate_basic(self):
"""
n = 1
size = 5
mesh = UnitSquareMesh(size,size)
mesh = UnitSquareMesh(size, size)
V = FunctionSpace(mesh, 'P', 2)
dummy_value = 1
E = Expression("t", t=dummy_value, degree=2)
Expand All @@ -22,24 +22,24 @@ def test_solverstate_basic(self):
# "read checkpoint"
u_cp, t_cp, n_cp = sstate.get_state()

#check values
# check values
self.assertEqual(t_cp, dummy_value)
self.assertEqual(n, n_cp)
#function should be the same everywhere (-> check vector values of the function)
# function should be the same everywhere (-> check vector values of the function)
vec_u = u.vector()
vec_u_cp = u_cp.vector()
for i in range(size*size):
for i in range(size * size):
self.assertAlmostEqual(vec_u[i], vec_u_cp[i])

def test_solverstate_modification_vector(self):
"""
Check if correct values are read from the checkpoint, if the dof vector of the dolfin functions are changed directly
Check if correct values are read from the checkpoint, if the dof vector of the dolfin functions are changed directly
Motivation for this test: Related to https://github.com/precice/fenics-adapter/pull/172 and https://github.com/precice/tutorials/pull/554
"""
n = 1
size = 5
mesh = UnitSquareMesh(size,size)
mesh = UnitSquareMesh(size, size)
V = FunctionSpace(mesh, 'P', 2)
ref_value = 1
E = Expression("t", t=ref_value, degree=2)
Expand All @@ -55,13 +55,12 @@ def test_solverstate_modification_vector(self):
# "read checkpoint"
u_cp, _, _ = sstate.get_state()

#check values
#function should be the same everywhere
#(so the vector values should all be ref_value)
# check values
# function should be the same everywhere
# (so the vector values should all be ref_value)
vec_u_cp = u_cp.vector()
for i in range(size*size):
for i in range(size * size):
self.assertAlmostEqual(ref_value, vec_u_cp[i])


def test_solverstate_modification_assign(self):
"""
Expand All @@ -70,7 +69,7 @@ def test_solverstate_modification_assign(self):
"""
n = 1
size = 5
mesh = UnitSquareMesh(size,size)
mesh = UnitSquareMesh(size, size)
V = FunctionSpace(mesh, 'P', 2)
ref_value = 1
E = Expression("t", t=ref_value, degree=2)
Expand All @@ -83,15 +82,15 @@ def test_solverstate_modification_assign(self):
# "compute" new solution
dummy_value = ref_value + 2
E.t = dummy_value
u2 = interpolate(E,V)
u2 = interpolate(E, V)
u.assign(u2)

# "read checkpoint"
u_cp, _, _ = sstate.get_state()

#check values
#function should be the same everywhere
#(so the vector values should all be ref_value)
# check values
# function should be the same everywhere
# (so the vector values should all be ref_value)
vec_u_cp = u_cp.vector()
for i in range(size*size):
for i in range(size * size):
self.assertAlmostEqual(ref_value, vec_u_cp[i])

0 comments on commit b04e6c9

Please sign in to comment.