better user experience
- no meaningless warnings regarding floating point precision - meaningful error message for invalid header
This commit is contained in:
parent
da46e5ea9a
commit
229f6139c8
|
@ -300,13 +300,16 @@ class Geom:
|
||||||
f = fname
|
f = fname
|
||||||
|
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
header_length,keyword = f.readline().split()[:2]
|
try:
|
||||||
header_length = int(header_length)
|
header_length,keyword = f.readline().split()[:2]
|
||||||
content = f.readlines()
|
header_length = int(header_length)
|
||||||
|
except ValueError:
|
||||||
|
header_length,keyword = (-1, 'invalid')
|
||||||
if not keyword.startswith('head') or header_length < 3:
|
if not keyword.startswith('head') or header_length < 3:
|
||||||
raise TypeError('Header length information missing or invalid')
|
raise TypeError('Header length information missing or invalid')
|
||||||
|
|
||||||
|
content = f.readlines()
|
||||||
|
|
||||||
comments = []
|
comments = []
|
||||||
for i,line in enumerate(content[:header_length]):
|
for i,line in enumerate(content[:header_length]):
|
||||||
items = line.split('#')[0].lower().strip().split()
|
items = line.split('#')[0].lower().strip().split()
|
||||||
|
@ -584,7 +587,7 @@ class Geom:
|
||||||
- ((np.ones(3)-(1./self.grid if np.array(center).dtype in np.sctypes['int'] else 0))*0.5 if periodic else c) # periodic center is always at CoG
|
- ((np.ones(3)-(1./self.grid if np.array(center).dtype in np.sctypes['int'] else 0))*0.5 if periodic else c) # periodic center is always at CoG
|
||||||
coords_rot = R.broadcast_to(tuple(self.grid))@coords
|
coords_rot = R.broadcast_to(tuple(self.grid))@coords
|
||||||
|
|
||||||
with np.errstate(over='ignore',under='ignore'):
|
with np.errstate(over='ignore',under='ignore',invalid='ignore'):
|
||||||
mask = np.where(np.sum(np.power(coords_rot/r,2.0**exponent),axis=-1) <= 1.0,False,True)
|
mask = np.where(np.sum(np.power(coords_rot/r,2.0**exponent),axis=-1) <= 1.0,False,True)
|
||||||
|
|
||||||
if periodic: # translate back to center
|
if periodic: # translate back to center
|
||||||
|
|
Loading…
Reference in New Issue