Skip to content

Commit 482f746

Browse files
prady0tlucascolley
andauthored
ENH: testing: special case 0D-arrays for check_shape=False (#729)
* Fixing check_shape's else condition Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com> * nit --------- Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com> Co-authored-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com> Co-authored-by: Lucas Colley <lucas.colley8@gmail.com>
1 parent d29096d commit 482f746

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/array_api_extra/_lib/_testing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,11 @@ def _check_ns_shape_dtype(
7777
if check_shape:
7878
msg = f"shapes do not match: {actual_shape} != f{desired_shape}"
7979
assert actual_shape == desired_shape, msg
80-
else:
80+
elif desired.ndim > 0:
8181
# Ignore shape, but check flattened size. This is normally done by
8282
# np.testing.assert_array_equal etc even when strict=False, but not for
8383
# non-materializable arrays.
84+
# This check excludes 0d arrays as they are special-cased in NumPy.
8485
actual_size = math.prod(actual_shape) # pyright: ignore[reportUnknownArgumentType]
8586
desired_size = math.prod(desired_shape) # pyright: ignore[reportUnknownArgumentType]
8687
msg = f"sizes do not match: {actual_size} != f{desired_size}"

0 commit comments

Comments
 (0)