Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python "IndexError:"
#4
Dear machael1789,

Thanks for your reply. Here is the segment of the code where problem might arise as in the error message the line number 163 indicates.

# For loop goes to line by line of EIGENVAL file (afer 8th line), and record kpoints and eigenvalues
# depending on how many values are given. If # values are 4, it is for k_point,
# otherwise it is eigen value file.
for i,line in enumerate(lines[7::]): #starts from 8th line
# If the line is for k-point mash
if len(re.findall("[-a-zA-Z0-9.\+]+",line))==4:
temp=re.findall('[-a-zA-Z0-9.\+]+',line)
num_temp=[float(j) for j in temp]
kpoints[kp_counter,:]=num_temp
kp_counter+=1

# If the line is for Eigenvalues
elif len(re.findall("[-a-zA-Z0-9.\+]+",line)) > 0:
temp=re.findall('[-a-zA-Z0-9.\+]+',line)
band_num=int(temp[0])
ei_val_string=temp[1:1+ispin:]
ei_val=[float(k) for k in ei_val_string] #Eigenvlue of current Kpoint
eigenvalues[kp_counter-1,band_num-1,:]=ei_val

in_file.close()

If you would like to see the entire code I can attach here too.

Please let me know where is that index issue here.

Thanking you,

BaidyaS

Thank you. I have just found the problem. It looks like as you said there was space problem in the input file. Now it works.

Thanks.
Reply


Messages In This Thread
Python "IndexError:" - by baidyas - Jan-14-2020, 10:39 PM
RE: Python "IndexError:" - by michael1789 - Jan-15-2020, 05:40 AM
RE: Python "IndexError:" - by buran - Jan-15-2020, 06:56 AM
RE: Python "IndexError:" - by baidyas - Jan-15-2020, 04:44 PM

Forum Jump:

User Panel Messages

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