Skip to content

Commit 6f8efe8

Browse files
committed
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.
1 parent 8237e31 commit 6f8efe8

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

tinytorch/src/01_tensor/ABOUT.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,12 @@ def reshape(self, *shape):
322322

323323
# Validate total elements match
324324
if np.prod(new_shape) != self.size:
325+
target_size = int(np.prod(new_shape))
325326
raise ValueError(
326-
f"Total elements must match: {self.size}{int(np.prod(new_shape))}"
327+
f"Cannot reshape {self.shape} to {new_shape}\n"
328+
f" ❌ Element count mismatch: {self.size} elements vs {target_size} elements\n"
329+
f" 💡 Reshape preserves data, so total elements must stay the same\n"
330+
f" 🔧 Use -1 to infer a dimension: reshape(-1, {new_shape[-1] if len(new_shape) > 0 else 1}) lets NumPy calculate"
327331
)
328332

329333
reshaped_data = np.reshape(self.data, new_shape)

tinytorch/tests/integration/test_optimizers_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def test_unit_shape_manipulation():
232232
t.reshape(2, 2) # 6 elements can't fit in 2×2=4
233233
assert False, "Should have raised ValueError"
234234
except ValueError as e:
235-
assert "Total elements must match" in str(e)
235+
assert "element count mismatch" in str(e).lower()
236236

237237
print("✅ Shape manipulation works!")
238238

0 commit comments

Comments
 (0)