I have the code snippet below that searches each row/column in an array to see if all values are either ascending or descending. Ideally, this code would ignore zeros. For example, a row with (5, 0, 3, 1) would come up True for descending. The code below still looks at the zeros. If the masked technique is a dead end, maybe I could create a copy without zeros? I'm very new to Numpy so I would appreciate specific directions. Thanks!
np.ma.masked_equal(grid, 0)
for row in grid:
if np.all(np.diff(row) <= 0) or np.all(np.diff(row) >= 0):
monoScore += .5
for col in np.transpose(grid):
if np.all(np.diff(col) <= 0) or np.all(np.diff(col) >= 0):
monoScore += .5