Closed cphyc closed 8 years ago
Hi, when I try to read an history file that is only one line long, I get an error at this line https://github.com/NuGrid/NuGridPy/blob/master/mesa.py#L3762:
6 import matplotlib.pyplot as plt 7 ----> 8 his = ms.history_data('.', slname='e_his_30_L20.data') /usr/lib/python2.7/site-packages/mesa.pyc in __init__(self, sldir, slname, clean_starlog, mass, Z) 861 self._read_starlog() 862 else: --> 863 self._read_starlog() 864 865 def __del__(self): /usr/lib/python2.7/site-packages/mesa.pyc in _read_starlog(self) 891 filename=sldir+'/'+slaname 892 --> 893 header_attr,cols,data = _read_mesafile(filename,data_rows=num_cycles) 894 895 self.cols = cols /usr/lib/python2.7/site-packages/mesa.pyc in _read_mesafile(filename, data_rows, only) 3752 for i in range(data_rows): 3753 # writing reading status -> 3754 percent = int(i*100/(data_rows-1)) 3755 if percent >= old_percent + 5: 3756 sys.stdout.flush() ZeroDivisionError: integer division or modulo by zero
There is a very quick hotfix by replacing data_rows-1 by max(1, data_rows-1).
data_rows-1
max(1, data_rows-1)
Hi, when I try to read an history file that is only one line long, I get an error at this line https://github.com/NuGrid/NuGridPy/blob/master/mesa.py#L3762:
There is a very quick hotfix by replacing
data_rows-1
bymax(1, data_rows-1)
.