When working with matrices in NumPy, it is often necessary to compare them for equality. I’m working on a project in which I have reached this point where I’m in need to check if two matrices have the same dimensions and values or verify if a calculation has produced the expected result. For this purpose, I have written a code according to my knowledge but it’s not very efficient to use.

Here’s a code that I developed:

Can someone provide me with other alternatives solution for this problem?

Hoping for positive answers!