Skip to content

Commit

Permalink
fix(str): add consistent fixed and free format approach
Browse files Browse the repository at this point in the history
closes #832
  • Loading branch information
jdhughes-usgs committed Mar 30, 2020
1 parent 5dd8e1e commit 3a88368
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion flopy/utils/flopy_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,12 @@ def write_fixed_var(v, length=10, ipos=None, free=False, comment=None):
write_fmt = '{} '
else:
if isinstance(v[n], (float, np.float, np.float32, np.float64)):
ctype = 'g'
width = ipos[n] - 6
vmin, vmax = 10**-width, 10**width
if abs(v[n]) < vmin or abs(v[n]) > vmax:
ctype = 'g'
else:
ctype = '.{}f'.format(width)
elif isinstance(v[n], (int, np.int, np.int32, np.int64)):
ctype = 'd'
else:
Expand Down

0 comments on commit 3a88368

Please sign in to comment.