From e195e163aca8a426766671bf21e5063fb4c65eda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20S=2E=20Dokken?= Date: Tue, 11 Jun 2024 15:24:06 +0200 Subject: [PATCH] Handle numpy metadata (quadrature arrays) without throwing a warning --- ufl/utils/sorting.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ufl/utils/sorting.py b/ufl/utils/sorting.py index 896ca2099..3ac5f1884 100644 --- a/ufl/utils/sorting.py +++ b/ufl/utils/sorting.py @@ -8,6 +8,8 @@ import warnings +import numpy as np + def topological_sorting(nodes, edges): """Return a topologically sorted list of the nodes. @@ -84,6 +86,8 @@ def canonicalize_metadata(metadata): value = str(value) elif hasattr(value, "ufl_signature"): value = value.ufl_signature + elif isinstance(value, np.ndarray): + value = np.array2string(value, separator=" ") else: warnings.warn( f"Applying str() to a metadata value of type {type(value).__name__}, "