Skip to content
Snippets Groups Projects
Unverified Commit b5b3fec7 authored by Matthias Diener's avatar Matthias Diener Committed by GitHub
Browse files

Merge branch 'main' into pytato

parents 2b49cef0 3938df08
No related branches found
No related tags found
No related merge requests found
......@@ -172,7 +172,16 @@ def _serialize_ndarray_container(ary: np.ndarray) -> Iterable[Tuple[Any, Any]]:
raise ValueError(
f"only object arrays are supported, given dtype '{ary.dtype}'")
return np.ndenumerate(ary)
# special-cased for speed
if ary.ndim == 1:
return [(i, ary[i]) for i in range(ary.shape[0])]
elif ary.ndim == 2:
return [((i, j), ary[i, j])
for i in range(ary.shape[0])
for j in range(ary.shape[1])
]
else:
return np.ndenumerate(ary)
@deserialize_container.register(np.ndarray)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment