MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / test_argument_equality

Function test_argument_equality

python/test/unit/fem/test_function_space.py:199–247  ·  view source on GitHub ↗

Placed this test here because it's mainly about detecting differing function spaces.

(mesh, V, V2, W, W2)

Source from the content-addressed store, hash-verified

197
198
199def test_argument_equality(mesh, V, V2, W, W2):
200 """Placed this test here because it's mainly about detecting differing
201 function spaces.
202 """
203 mesh2 = create_unit_cube(MPI.COMM_WORLD, 8, 8, 8)
204 gdim = mesh2.geometry.dim
205 V3 = functionspace(mesh2, ("Lagrange", 1))
206 W3 = functionspace(mesh2, ("Lagrange", 1, (gdim,)))
207
208 for TF in (TestFunction, TrialFunction):
209 v = TF(V)
210 v2 = TF(V2)
211 v3 = TF(V3)
212 assert v == v2
213 assert v2 == v
214 assert V != V3
215 assert V2 != V3
216 assert not v == v3
217 assert not v2 == v3
218 assert v != v3
219 assert v2 != v3
220 assert v != v3
221 assert v2 != v3
222
223 w = TF(W)
224 w2 = TF(W2)
225 w3 = TF(W3)
226 assert w == w2
227 assert w2 == w
228 assert w != w3
229 assert w2 != w3
230
231 assert v != w
232 assert w != v
233
234 s1 = set((v, w))
235 s2 = set((v2, w2))
236 s3 = set((v, v2, w, w2))
237 assert len(s1) == 2
238 assert len(s2) == 2
239 assert len(s3) == 2
240 assert s1 == s2
241 assert s1 == s3
242 assert s2 == s3
243
244 # Test that the dolfinx implementation of Argument.__eq__ is
245 # triggered when comparing ufl expressions
246 assert grad(v) == grad(v2)
247 assert grad(v) != grad(v3)
248
249
250def test_cell_mismatch(mesh):

Callers

nothing calls this directly

Calls 3

create_unit_cubeFunction · 0.90
functionspaceFunction · 0.90
setFunction · 0.85

Tested by

no test coverage detected