A = np.array([
[-1, 3],
[3, 2]
], dtype=np.dtype(float))
b = np.array([7, 1], dtype=np.dtype(float))
print(f"Shape of A: {A.shape}")
print(f"Shape of b: {b.shape}")
Gives the following output :
Shape of A: (2, 2)
Shape of b: (2,)
I was expecting shape of b to be (1,2) which is one row and two columns, why is it (2,) ?
Your assumption is incorrect,
bonly has one dimension, not two.To have a 2D array you would have needed an extra set of square brackets:
Similarly for a 3D array:
Note that you can transform your original
binto a 2D array with:Or: