Skip to content

Commit cedade6

Browse files
Updated Reshaping file with advanced concepts
1 parent 61f18ed commit cedade6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Reshaping and manipulation/reshaping.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,16 @@
3636
# Note:
3737
# Use ravel() when you want performance (and don't need a copy).
3838
# Use flatten() when you need an independent copy of the data.
39+
40+
# ----------------------------------------
41+
# ARRAY COMPATIBILITY CHECK
42+
# ----------------------------------------
43+
44+
# Define three arrays
45+
a = np.array([1, 2, 3]) # Shape: (3,)
46+
b = np.array([4, 5, 6, 0]) # Shape: (4,)
47+
c = np.array([7, 8, 9]) # Shape: (3,)
48+
49+
# Compare shapes of arrays to check compatibility (e.g., for element-wise operations)
50+
print('Compatibility between a and b:', a.shape == b.shape) # False: shape (3,) != (4,)
51+
print('Compatibility between a and c:', a.shape == c.shape) # True: both have shape (3,)

0 commit comments

Comments
 (0)