Skip to content

Commit 45fe659

Browse files
committed
warn rather than fail on plotting invalid data; have xye import fail on error rather that use partial dataset
1 parent e88e61f commit 45fe659

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

GSASII/GSASIIpwdplot.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1990,7 +1990,11 @@ def onPartialConfig(event):
19901990
Ymax = None
19911991
for ip,Pattern in enumerate(PlotList):
19921992
xye = Pattern[1]
1993-
xye = np.nan_to_num(xye)
1993+
try:
1994+
xye = np.nan_to_num(xye)
1995+
except ValueError:
1996+
print('Error in diffraction pattern',ip,'skipping plot')
1997+
continue
19941998
if xye[1] is None: continue
19951999
if Ymax is None: Ymax = max(xye[1])
19962000
Ymax = max(Ymax,max(xye[1]))

GSASII/imports/G2pwd_xye.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,15 @@ def Reader(self,filename, ParentFrame=None, **unused):
180180
y.append(float(vals[1]))
181181
w.append(1.0/float(vals[1]))
182182
except ValueError:
183-
msg = 'Error parsing number in line '+str(i+1)
183+
self.errors = f'Error parsing number in line {i+1}\n{S.strip()}'
184184
if GSASIIpath.GetConfigValue('debug'):
185-
print (msg)
186-
print (S.strip())
187-
break
185+
print (self.errors)
186+
return False
188187
except:
189-
msg = 'Error in line '+str(i+1)
188+
self.errors = f'Error processing line {i+1}\n{S.strip()}'
190189
if GSASIIpath.GetConfigValue('debug'):
191-
print (msg)
192-
print (S.strip())
193-
break
190+
print (self.errors)
191+
return False
194192
N = len(x)
195193
if N == 0: return False
196194
x = np.array(x)

0 commit comments

Comments
 (0)