FEniCS / ufl

UFL - Unified Form Language
https://fenicsproject.org
GNU Lesser General Public License v3.0
104 stars 64 forks source link

Make `FiniteElementBase` subscriptable but not iterable #180

Closed conpierce8 closed 1 year ago

conpierce8 commented 1 year ago

Addresses https://github.com/FEniCS/ufl/issues/179. This changes makes FiniteElementBase raise an error when __iter__ is called, so that Python does not treat it as an iterable object.

In addition, it appears that the use of NotImplemented in FiniteElementBase.__getitem__ may be inappropriate since (I think) __getitem__ is not one of the binary operations for which NotImplemented is intended, so it is replaced with a KeyError when an invalid restriction is supplied.