ermongroup / Wifi_Activity_Recognition

Code for IEEE Communication Magazine (A Survey on Behaviour Recognition Using WiFi Channle State Information)
GNU General Public License v3.0
251 stars 78 forks source link

questions about 'data_merge' #43

Closed nnnnmj closed 1 year ago

nnnnmj commented 2 years ago

Hello, thank you for your sharing. I try to run the coding, but there is always an index error that I cannot handle. Could you please help me with that? I would appreciate it.

The error is as follows:

IndexError Traceback (most recent call last) /var/folders/5x/3g67fwns0mb68s__c_3fk4wr0000gn/T/ipykernel_43899/857709293.py in 10 outputfilename2 = "./inputfiles/yy" + str(windowsize) + "" + str(threshold) + "_" + label + ".csv" 11 ---> 12 x, y = dataimport(filepath1, filepath2) 13 with open(outputfilename1, "w") as f: 14 writer = csv.writer(f, lineterminator="\n")

/var/folders/5x/3g67fwns0mb68s__c_3fk4wr0000gn/T/ipykernel_43899/1109332674.py in dataimport(path1, path2) 84 y[k/slide_size,:] = np.array([0,0,0,0,0,0,0,1]) 85 else: ---> 86 y[k/slide_size,:] = np.array([2,0,0,0,0,0,0,0]) 87 k += slide_size 88

IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices

bobvo23 commented 2 years ago

It seems that the author used Python 2, but you are using Python 3 So k/slide_size will yield a float for Python3 which are invalid indices. You may change k/slide_size to k//slide_size to fix the issue.

nnnnmj commented 2 years ago

Thank you so much. That makes sense.