weaverba137 / pydl

Library of IDL astronomy routines converted to Python.
BSD 3-Clause "New" or "Revised" License
28 stars 16 forks source link

[1.0.0rc2] test_yanny fails on big endian machines #68

Closed olebole closed 1 year ago

olebole commented 1 year ago

On a Debian system with s90x architecture (IBM zSystems, big endian, 64 bit), we get the following test failure:

_____________________________ TestYanny.test_yanny _____________________________

self = <pydl.pydlutils.tests.test_yanny.TestYanny object at 0x3ff377b37c0>

        def test_yanny(self):
            """Used to test the yanny class.
            """
            #[…]
            for t in par.tables():
>               assert (par.dtype(t) ==
                        self.json2dtype(struct_data[t]['dtype']))
E                       AssertionError: assert dtype([('mag', '>f4', (5,)), ('b', 'S33', (5,)), ('foo', 'S25'), ('c', '>f8'), ('flags', '>i4', (2,)), ('new_flag', 'S5')]) == dtype([('mag', '<f4', (5,)), ('b', 'S33', (5,)), ('foo', 'S25'), ('c', '<f8'), ('flags', '<i4', (2,)), ('new_flag', 'S5')])
E                        +  where dtype([('mag', '>f4', (5,)), ('b', 'S33', (5,)), ('foo', 'S25'), ('c', '>f8'), ('flags', '>i4', (2,)), ('new_flag', 'S5')]) = <bound method yanny.dtype of #%yanny\n# test.par\n#\n# FTCL/Yanny file for testing the perl & python yanny readers.\n#\n# T...ESS 2008-06-22T00:27:33\nSTATUS_UPDATE FAILURE 2008-06-22T01:27:33\n#\nold {1.2 2.3 3.4} hello\nold {4.3 3.2 2.1} { { } }\n>('MYSTRUCT')
E                        +    where <bound method yanny.dtype of #%yanny\n# test.par\n#\n# FTCL/Yanny file for testing the perl & python yanny readers.\n#\n# T...ESS 2008-06-22T00:27:33\nSTATUS_UPDATE FAILURE 2008-06-22T01:27:33\n#\nold {1.2 2.3 3.4} hello\nold {4.3 3.2 2.1} { { } }\n> = #%yanny\n# test.par\n#\n# FTCL/Yanny file for testing the perl & python yanny readers.\n#\n# This file is much more complic...CESS 2008-06-22T00:27:33\nSTATUS_UPDATE FAILURE 2008-06-22T01:27:33\n#\nold {1.2 2.3 3.4} hello\nold {4.3 3.2 2.1} { { } }\n.dtype
E                        +  and   dtype([('mag', '<f4', (5,)), ('b', 'S33', (5,)), ('foo', 'S25'), ('c', '<f8'), ('flags', '<i4', (2,)), ('new_flag', 'S5')]) = <bound method YannyTestCase.json2dtype of <pydl.pydlutils.tests.test_yanny.TestYanny object at 0x3ff377b37c0>>([['mag', '<f4', [5]], ['b', 'S33', [5]], ['foo', 'S25'], ['c', '<f8'], ['flags', '<i4', [2]], ['new_flag', 'S5']])
E                        +    where <bound method YannyTestCase.json2dtype of <pydl.pydlutils.tests.test_yanny.TestYanny object at 0x3ff377b37c0>> = <pydl.pydlutils.tests.test_yanny.TestYanny object at 0x3ff377b37c0>.json2dtype

/usr/lib/python3/dist-packages/pydl/pydlutils/tests/test_yanny.py:300: AssertionError

Full test log here. I think this is a wrong endianness mark somewhere.

weaverba137 commented 1 year ago

Thank you for reporting this. Yes, I believe there are explicit endian marks in the code, so that's not portable.

weaverba137 commented 1 year ago

Note to self: re-implement test by only testing the type (float, int, etc.) and size (4 bytes, 8 bytes, etc.) independently of any endianness.