fix: update test assertion for new error message format

The reshape error message was updated to the 3-part educational
pattern, but the integration test was still checking for the old
message text. Updated to use case-insensitive matching.
This commit is contained in:
Vijay Janapa Reddi
2026-01-25 11:35:32 -05:00
parent 8237e31361
commit 6f8efe8a94
2 changed files with 6 additions and 2 deletions

View File

@@ -322,8 +322,12 @@ def reshape(self, *shape):
# Validate total elements match
if np.prod(new_shape) != self.size:
target_size = int(np.prod(new_shape))
raise ValueError(
f"Total elements must match: {self.size} ≠ {int(np.prod(new_shape))}"
f"Cannot reshape {self.shape} to {new_shape}\n"
f" ❌ Element count mismatch: {self.size} elements vs {target_size} elements\n"
f" 💡 Reshape preserves data, so total elements must stay the same\n"
f" 🔧 Use -1 to infer a dimension: reshape(-1, {new_shape[-1] if len(new_shape) > 0 else 1}) lets NumPy calculate"
)
reshaped_data = np.reshape(self.data, new_shape)

View File

@@ -232,7 +232,7 @@ def test_unit_shape_manipulation():
t.reshape(2, 2) # 6 elements can't fit in 2×2=4
assert False, "Should have raised ValueError"
except ValueError as e:
assert "Total elements must match" in str(e)
assert "element count mismatch" in str(e).lower()
print("✅ Shape manipulation works!")