FEniCS / ufl

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

ufl.constantvalue.as_ufl should use the numbers hierarchy #228

Closed dham closed 1 month ago

dham commented 10 months ago

ufl.constantvalue.as_ufl checks values against the intrinsic types float, complex, and int. This breaks for other scalar types, for example entries in numpy arrays. The check should instead be for numbers.Real, numbers.Complex, and numbers.Integral respectively.

https://github.com/FEniCS/ufl/blob/e1e8e5627b0c7db17687bdb32857820ac4ddc072/ufl/constantvalue.py#L488C1-L500C1

dham commented 10 months ago

Obviously any PR will need tests.