brendanarnold / py-fortranformat

MIT License
31 stars 7 forks source link

Some tests fail #35

Open dschwoerer opened 4 months ago

dschwoerer commented 4 months ago

The failing tests: test-failures.log.gz

full log: builder-live.log.gz

If I understood you correctly, this is a known issue. In that case feel free to close this as "won't fix".

Just looking at the first 3 failures:


    def test_bn_f_ed_input_128(self):
        vals = [123456789.]
        fmt = '''(BN, F10.0)'''
        result = '''123456792.'''
        eds, rev_eds = _parser(_lexer(fmt))
>       self.assertEqual(result, _output(eds, rev_eds, vals))
E       AssertionError: '123456792.' != '123456789.'
E       - 123456792.
E       ?         -
E       + 123456789.
E       ?        +

tests/autogen/output/ifort/9_1_linux_intel/test_bn-f_output.py:909: AssertionError
____________ BN_FEditDescriptorBatchTestCase.test_bn_f_ed_input_178 ____________

self = <test_bn-f_output.BN_FEditDescriptorBatchTestCase testMethod=test_bn_f_ed_input_178>

    def test_bn_f_ed_input_178(self):
        vals = [-0.01]
        fmt = '''(BN, F2.1)'''
        result = '''.0'''
        eds, rev_eds = _parser(_lexer(fmt))
>       self.assertEqual(result, _output(eds, rev_eds, vals))
E       AssertionError: '.0' != '**'
E       - .0
E       + **

tests/autogen/output/ifort/9_1_linux_intel/test_bn-f_output.py:1259: AssertionError
____________ BN_FEditDescriptorBatchTestCase.test_bn_f_ed_input_180 ____________

self = <test_bn-f_output.BN_FEditDescriptorBatchTestCase testMethod=test_bn_f_ed_input_180>

    def test_bn_f_ed_input_180(self):
        vals = [-0.001]
        fmt = '''(BN, F2.1)'''
        result = '''.0'''
        eds, rev_eds = _parser(_lexer(fmt))
>       self.assertEqual(result, _output(eds, rev_eds, vals))
E       AssertionError: '.0' != '**'
E       - .0

I do not think that is something that should be 'fixed' ...

brendanarnold commented 4 months ago

Yeah - in the first case the test fails because of a limitation in floating point precision and isn't really a fail. Basically the numbers beyond a certain number of decimal places will be random

In the second and third case, I'm not sure but I expect that these are compiler implementation differences - the test data is generated from the Intel ifort compiler, whereas the FortranFormat code is based of the source from gfortran.

The intention of the library was to emulate different compilers using configuration flags but really I think this is a low priority for most. I'm happy for this issue to remain as a bug until those flags are implemented.