Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function returns "NoneType"
#3
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
Reply


Messages In This Thread
Function returns "NoneType" - by eoins - May-22-2019, 08:28 PM
RE: Function returns "NoneType" - by buran - May-22-2019, 08:40 PM
RE: Function returns "NoneType" - by eoins - May-22-2019, 09:34 PM
RE: Function returns "NoneType" - by micseydel - May-22-2019, 10:43 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  function returns dataframe as list harum 2 1,490 Aug-13-2022, 08:27 PM
Last Post: rob101
  function accepts infinite parameters and returns a graph with those values edencthompson 0 890 Jun-10-2022, 03:42 PM
Last Post: edencthompson
  function that returns a list of dictionaries nostradamus64 2 1,805 May-06-2021, 09:58 PM
Last Post: nostradamus64
  Recursive function returns None, when True is expected akar 0 3,434 Sep-07-2020, 07:58 PM
Last Post: akar
  function/nonetype object is not iterable nanok66 5 4,132 May-08-2020, 07:39 PM
Last Post: nanok66
  Python function returns inconsistent results bluethundr 4 3,280 Dec-21-2019, 02:11 AM
Last Post: stullis
  class returns NoneType Object istemihan 0 2,295 Aug-12-2019, 11:47 AM
Last Post: istemihan
  Function returns memory address Joeicam 1 3,857 Feb-10-2019, 02:23 AM
Last Post: Larz60+
  Function returns unaccurate value raulfloresgp 4 3,018 Nov-23-2018, 03:39 AM
Last Post: raulfloresgp
  How to test a function that is supposed to return NoneType? w0mb4rt 1 3,526 Feb-17-2018, 07:38 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020