brendanarnold / py-fortranformat

MIT License
31 stars 7 forks source link

'RET_UNWRITTEN_VARS_NONE = True' broken for floats? #8

Closed brendanarnold closed 3 years ago

brendanarnold commented 3 years ago

Version 0.2.5. I would have expected the two zeroes at the end to be None instead.

>>> import fortranformat as ff
>>> 
>>> line = '   1.0000       9.0000       105.09       1.0000                   '
>>> fltfmt = ff.FortranRecordReader('(6g13.5)')
>>> ff.config.RET_UNWRITTEN_VARS_NONE = True
>>> data = fltfmt.read(line)
>>> print(data)
[1.0, 9.0, 105.09, 1.0, 0.0, 0.0]
brendanarnold commented 3 years ago

This is the expected behaviour, blank values are actually interpreted as zero according to the FORTRAN spec. For the RET_UNWRITTEN_VARS_NONE to actually return None the string would have to be 26 characters shorter