New to coding and to Python. I have this code which for some reason will only go through my first if-statement. I've looked at it for hours and I honestly can't tell why?
for i in range(1, trex.shape[0]-1):
for j in range(1,trex.shape[1]-1):
if shape[i,j] == 0: # for 0 degree angles # ONLY GOES THROUGH THIS
if trex[i,j] < trex[i, j+1] and trex[i,j] < trex[i,j-1]:
trex[i,j] = 0
elif shape[i,j] == 45: # for 45 degree angles # Never comes down here
if trex[i,j] < trex[i-1, j+1] and trex[i,j] < trex[i+1,j-1]:
trex[i,j] = 0
else # for 90 degree angles # Or here
if trex[i,j] < trex[i-1, j] and trex[i,j] < trex[i+1,j]:
trex[i,j] = 0
So basically I want it to run through a 2d array. I have another 2d array called shape (same shape as trex) which has angles 0, 45, 90. First I look at the angle at the point [i,j] and then depending on which angle it has, I want it to look at the value of trex at the neighbours in the point. If the neighbouring points are BOTH lower than the middle point then I do nothing. Else I set the middle point ([i,j]) equal to 0. But when I run my code it only sets those with the angle 0 to 0. So it never goes down to my elif or else statement. I have no clue why :'( Hope it makes sense and any help is greatly appreciated!