def collectData(file,arr,index): arr[index, 0] = np.fromfile(file, dtype='uint32', count=1) eSize = arr[index, 0] arr[index, 1] = np.fromfile(file, dtype='uint32', count=1) chan = arr[index, 1] arr[index, 2] = np.fromfile(file, dtype='uint32', count=1) t = arr[index, 2] information = [eSize, chan, t] return information x = [] x += collectData(inputFile,data,spot)Hi, Is there any reason that this function would return "Nonetype". I have tried to add these bit sof information I am pulling from a file (which has worked in the past and is definitely not my problem) but I keep getting that this function is returning "Nonetype" or that "'NoneType' object is not iterable". Any help?
Function returns "NoneType"
Function returns "NoneType"
|
(May-22-2019, 08:28 PM)eoins Wrote: Hi, Is there any reason that this function would return "Nonetype". I have tried to add these bit sof information I am pulling from a file (which has worked in the past and is definitely not my problem) but I keep getting that this function is returning "Nonetype" or that "'NoneType' object is not iterable". Any help? Please post full traceback verbatim, in error tags. Also provide information what inputFile, data and spot are. Best would be if you provide minimal example that reproduce the error.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link Create MCV example Debug small programs
May-22-2019, 09:34 PM
def collectDataMarcath(file,arr,index): arr[index, 0] = np.fromfile(file, dtype='uint32', count=1) #Event Size eventSize = arr[index, 0] arr[index, 1] = np.fromfile(file, dtype='uint32', count=1) #channel channel = arr[index, 1] arr[index, 2] = np.fromfile(file, dtype='uint32', count=1) #time time = arr[index, 2] information = [eventSize, channel, time] return information def collectData(file, arr, index, form): if form == 0: #Standard collectDataStand(file,arr,index) elif form == 1:#DPP-PSD collectDataDpp(file, arr, index) elif form == 2:#find unknown collectDataMarcath(file,arr,index) else: print('Invalid entry. Please enter 0 for standard and 1 for dpp-psd.') dataFile = 'Testfiles/' + str(file) + '/dataFile2' + '.dat' # CHANGE to directory where data is READ #+ str(board) inputFile = open(dataFile) #defines input stream file_Headers = KLINGON*np.ones((int(chunkSize), 3)) info = [] info += collectData(inputFile, file_Headers, pulse, format_type) eventSize = info[0] channel = info[1] time = info[2]This is as much code as I can give, pulse is simply an integer, file_Headers is a matrix initialized to ones, and I am trying to read in binary data from a file into the array file_Headers, which I have done and can do perfectly fine when I change collectDataMarcath to not return anything. But I would like the function to return these pieces of information because I have since realized that I need to use this info separately and I'm unsure as to why I would get a Nonetype error. Heres the error message: TypeError: 'NoneType' object is not iterable
May-22-2019, 10:43 PM
The code you post should be runnable. Yours is missing imports, at the very least. Ideally you would just remove code that uses them and distill the problem into the absolute minimum needed to reproduce, which is likely just 5-10 lines. Also, you only posted part of the stack trace, not the whole thing, which we need (though a stack trace is most useful when we have the exact code that reproduced it).
|
|
Users browsing this thread: 2 Guest(s)