Subject: [UFL-dev] extract unique elements

From: Kristian Oelgaard <[email-masked]>
Date: Wed, 28 Jan 2009 11:08:47 +0100

Hi,

I've added the following unit test to test/algorithms.py test_elements()

element1 = FiniteElement("CG", triangle, 1)
element2 = FiniteElement("CG", triangle, 1)

v = TestFunction(element1)
u = TrialFunction(element2)

a = u*v*dx
assert (element1, element2) == extract_elements(a)

# OK

assert set([element1]) == extract_unique_elements(a)

# Fails because element1 and element2 are different objects, but I think they
should be treated as identical elements??

Kristian

---

From: Martin Sandve Alnæs <[email-masked]>
Date: Wed, 28 Jan 2009 11:29:27 +0100

Fixed. FiniteElement didn't have __hash__ and __eq__, the default
behaviour just checks the object id.

Martin

On Wed, Jan 28, 2009 at 11:08 AM, Kristian Oelgaard
<[email-masked]> wrote:
> _______________________________________________
> UFL-dev mailing list
> [email-masked]
> http://fenics.org/mailman/listinfo/ufl-dev
>