I am writing a program to check if a matrix is square (The number of rows and columns are equal ex: 2x2, 3x3, etc)
I thought it would be best to count the elements using the built in size function and take the square root. I want to write an if statement where if the square root does not result in a whole number it prints an error statement, but I'm not sure how to specify a whole number in my statement.
here is what I've tried
import numpy as np
A = np.array([[1,2,3],[4,5,6]])
check = A.size
if check**.5 ...
and I don't know what to put in the rest of the statement
x % 1 == 0, but this approach will fail for checking for square arrays. For example, a matrix of size(18, 2)will returnTrueif you check that the square root of its size is an integer.