From 28de4c44d1172457f9cb1fdd9f256f59c761a3ea Mon Sep 17 00:00:00 2001
From: Kaushik Kulkarni <kaushikcfd@gmail.com>
Date: Sat, 12 Jun 2021 12:50:15 -0500
Subject: [PATCH] force identifier in tree to be of type `Tuple[Union[str,
 int]]`

---
 arraycontext/container/traversal.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/arraycontext/container/traversal.py b/arraycontext/container/traversal.py
index 21599ff..c9ac2d5 100644
--- a/arraycontext/container/traversal.py
+++ b/arraycontext/container/traversal.py
@@ -271,8 +271,17 @@ def _keyed_map_array_container_impl(
         if type(_ary) is leaf_cls:  # type(ary) is never None
             return f(keys, _ary)
         elif is_array_container(_ary):
+            def _tuple_if_not_tuple(x):
+                if not isinstance(x, tuple):
+                    assert isinstance(x, (str, int))
+                    return x,
+                else:
+                    assert all(isinstance(el, (str, int))
+                               for el in x)
+                    return x
+
             return deserialize_container(_ary, [
-                    (key, frec(keys+(key,), subary))
+                    (key, frec(keys+_tuple_if_not_tuple(key), subary))
                     for key, subary in serialize_container(_ary)
                     ])
         else:
-- 
GitLab