Skip to content

Commit adda002

Browse files
kaushikcfdinducer
authored andcommitted
ArrayContainer fixes for numpy arrays as leaf classes
1 parent ff16029 commit adda002

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

arraycontext/container/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,11 @@ def is_array_container(ary: Any) -> bool:
218218
"cheaper option, see is_array_container_type.",
219219
DeprecationWarning, stacklevel=2)
220220
return (serialize_container.dispatch(ary.__class__)
221-
is not serialize_container.__wrapped__) # type:ignore[attr-defined]
221+
is not serialize_container.__wrapped__ # type:ignore[attr-defined]
222+
# numpy values with scalar elements aren't array containers
223+
and not (isinstance(ary, np.ndarray)
224+
and ary.dtype.kind != "O")
225+
)
222226

223227

224228
@singledispatch

0 commit comments

Comments
 (0)