In my code, I have loaded data to an array. While looping over the array, everytime the else is executed, the array values of the amat array get changed (only for those i's where the loop is executed).
That is, amat[i] before the for loop does not equal amat[i] after the for loop, for those i's where the else statement is executed.
Here's my code snippet.
amat = np.loadtxt(infl)
for i,yentry in enumerate(amat):
depth = yentry[0]
if depth < dhigh:
if depth >= dlow:
if bint == 1:
mindepth = dlow
matline += yentry
count += 1
else:
avgmat = matline / float(count)
bavg[bint,:] = avgmat
depthfix = round((dlow + dhigh)/2,1)
bavg[bint,0] = depthfix
stringlist.append((' '.join(['%10.6f ']*len(avgmat))+'\n') % tuple(avgmat))
avgmat = yentry
matline = yentry
bint += 1
count = 1
dlow = dhigh
dhigh += step
What could be causing this? As you can see, I have no statements which should affect the value of amat. Yet, something is obviously going on...
I know it's hard to diagnose without the full code, but can anyone think of any issues that might be causing this? How can my array get modified without applying any operations to it?
matlineandavgmatwhich don't seem to be defined before they're used. Can you provide a self-contained, runnable example, including a small data sample, that actually demonstrates the problem?