eyurtsev / fcsparser

A python parser for reading fcs files supporting FCS 2.0, 3.0, 3.1
MIT License
74 stars 45 forks source link

compatibility with numpy>2.0 #74

Open matthewpendleton opened 3 months ago

matthewpendleton commented 3 months ago

numpy >2.0 is not backwards compatible, and specifically fails in the endian/byteorder check. An updated implementation (along with explicitly specifying the proper endianness) that is compliant with the changes made in numpy 2.0 and later would be:

        # Convert to native byte order
        # This is needed for working with pandas data structures
        sys_is_le = sys.byteorder == 'little'
        native_code = '<' if sys_is_le else '>'
        swapped_code = '>' if sys_is_le else '<'
        if endian != native_code:
            # swaps the actual bytes and also the endianness
            # updated to be numpy>= 2.0 compliant
            data = data.view(data.dtype.newbyteorder(swapped_code)).byteswap()
eyurtsev commented 3 months ago

I do not work in the field anymore, but happy to merge a PR and make a package release if you're able to make the necessary changes and include or point out to the relevant unit tests that cover this functionality