Apr-08-2019, 12:45 PM
(This post was last modified: Apr-08-2019, 01:17 PM by ichabod801.)
I want to compare the first column of an array with all the other columns and then break the function if they are all the same.
Outside the function, this code works.
Outside the function, this code works.
import numpy as np comms = np.array([[3, 3, 2, 2], [3, 2, 0, 3], [2, 2, 0, 4], [0, 4, 0, 4], [1, 0, 0, 2]]) M = comms.shape[0] all((comms[i, : ] == comms[0, : ]).all() for i in range(M))However, evaluated inside the function, it fails
def varinfo(comms): M = comms.shape[0] return all((comms[i, : ] == comms[0, : ]).all() for i in range(M))This is very strange. Could someone help?