Skip to content

Commit 7b57511

Browse files
alexfiklinducer
authored andcommitted
simplify new_like allocation
1 parent 13e9a77 commit 7b57511

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

arraycontext/fake_numpy.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626
import numpy as np
27-
from arraycontext.container import serialize_container, deserialize_container
27+
from arraycontext.container import serialize_container
2828
from arraycontext.container.traversal import (
2929
rec_map_array_container, multimapped_over_array_containers)
3030
from pytools import memoize_in
@@ -187,17 +187,7 @@ def _new_like(self, ary, alloc_like):
187187
# FIXME: what about object arrays nested in an ArrayContainer?
188188
raise NotImplementedError("operation not implemented for object arrays")
189189

190-
def _new_like_container(_ary):
191-
try:
192-
iterable = serialize_container(_ary)
193-
except TypeError:
194-
return alloc_like(_ary)
195-
else:
196-
return deserialize_container(_ary, [
197-
(key, alloc_like(subary)) for key, subary in iterable
198-
])
199-
200-
return _new_like_container(ary)
190+
return rec_map_array_container(alloc_like, ary)
201191

202192
def empty_like(self, ary):
203193
return self._new_like(ary, self._array_context.empty_like)

0 commit comments

Comments
 (0)