Skip to content
Snippets Groups Projects
Unverified Commit c8269936 authored by Alexandru Fikl's avatar Alexandru Fikl Committed by Alexandru Fikl
Browse files

unflatten: better check that template and ary sizes match

parent 853f5014
No related branches found
No related tags found
No related merge requests found
......@@ -570,7 +570,8 @@ def unflatten(
iterable = serialize_container(template_subary)
except TypeError:
if (offset + template_subary.size) > ary.size:
raise ValueError("'template' and 'ary' sizes do not match")
raise ValueError("'template' and 'ary' sizes do not match: "
"'template' is too large")
if template_subary.dtype != ary.dtype:
raise ValueError("'template' dtype does not match 'ary': "
......@@ -612,7 +613,12 @@ def unflatten(
"only one dimensional arrays can be unflattened: "
f"'ary' has shape {ary.shape}")
return _unflatten(template)
result = _unflatten(template)
if offset != ary.size:
raise ValueError("'template' and 'ary' sizes do not match: "
"'ary' is too large")
return result
# }}}
......
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