ValueError: setting an array element with a sequence

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Saad Bin Ahmed
    New Member
    • Jul 2011
    • 25

    ValueError: setting an array element with a sequence

    I am facing problem while running python code. Following is the program which read files where labels have been declared and add it by following the condition. Labels are not declared as array but I am unable to get why the following error shows.

    Please have a look on it and give suggestions in order to rectify this error.
    This program is too large so I copied here only that portion where labels are in process.

    Code:
    labels = set()
    
    transcriptPath = options.root + options.transcriptFilename ## this is a path from where labels written in file
    
    for line in file(transcriptPath).readlines():
    	if line <> "" and line[0] <> '#' and line[0] <> '.' and line[0] <> '"':
    		labels.add(line[:-1])
    
    labels = list(labels)
    labels.sort()
    print len(labels) , "labels:"
    print labels

    Traceback (most recent call last):
    File "IAM_online.py" , line 284, in <module>
    netcdf_helpers. createNcStrings (ncfile,'labels ',labels,('numL abels','maxLabe lLength'),'targ et labels')
    File "/home/ahmed/Thesis/root/netcdf_helpers. py", line 31, in createNcStrings
    createNcVar(ncf ile,vname,nullS trings,'c',dims ,desc)
    File "/home/ahmed/Thesis/root/netcdf_helpers. py", line 13, in createNcVar
    nc_var.assignVa lue(data)
    ValueError: setting an array element with a sequence
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    According to the traceback, the error occurs with this statement: nc_var.assignVa lue(data)

    What is nc_var and what is data? What does assignValue do?

    Comment

    • dwblas
      Recognized Expert Contributor
      • May 2008
      • 626

      #3
      Do you have more than one program with the same name, perhaps in different directories, and the error messages comes from a different program?

      Comment

      • Saad Bin Ahmed
        New Member
        • Jul 2011
        • 25

        #4
        What is nc_var and what is data? What does assignValue do?

        nc_var is a netcdf varriable and data contains all the labels like A,B,C.... assignValue is a builtin function, it does has a form

        netcdf_variable .assignValue(va lue)

        Actually I am using netcdf library for my program and this error shows in library program. I am unable to sort it out.

        Comment

        • Saad Bin Ahmed
          New Member
          • Jul 2011
          • 25

          #5
          No I have a one program of this name in directory. I am not calling other directory's file in my program so this can not be the case.

          Comment

          Working...