geopandas icon indicating copy to clipboard operation
geopandas copied to clipboard

BUG: test_to_wkb fails on big-endian systems

Open QuLogic opened this issue 4 years ago • 2 comments

  • [x] I have checked that this issue has not already been reported.
  • [x] I have confirmed this bug exists on the latest version of geopandas.
  • [x] (optional) I have confirmed this bug exists on the master branch of geopandas.

Problem description

Possibly failing because it hard codes the byte representation of multi-byte integers?

__________________________ TestDataFrame.test_to_wkb ___________________________
self = <geopandas.tests.test_geodataframe.TestDataFrame object at 0x3ff75f2d6f0>
    def test_to_wkb(self):
        wkbs0 = [
            (
                b"\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00"
                b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
            ),  # POINT (0 0)
            (
                b"\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00"
                b"\x00\xf0?\x00\x00\x00\x00\x00\x00\xf0?"
            ),  # POINT (1 1)
        ]
        wkbs1 = [
            (
                b"\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00"
                b"\x00\x00@\x00\x00\x00\x00\x00\x00\x00@"
            ),  # POINT (2 2)
            (
                b"\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00"
                b"\x00\x08@\x00\x00\x00\x00\x00\x00\x08@"
            ),  # POINT (3 3)
        ]
        gs0 = GeoSeries.from_wkb(wkbs0)
        gs1 = GeoSeries.from_wkb(wkbs1)
        gdf = GeoDataFrame({"geom_col0": gs0, "geom_col1": gs1})
    
        expected_df = pd.DataFrame({"geom_col0": wkbs0, "geom_col1": wkbs1})
>       assert_frame_equal(expected_df, gdf.to_wkb())
geopandas/tests/test_geodataframe.py:797: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pandas/_libs/testing.pyx:53: in pandas._libs.testing.assert_almost_equal
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
E   AssertionError: DataFrame.iloc[:, 0] (column name="geom_col0") are different
E   
E   DataFrame.iloc[:, 0] (column name="geom_col0") values are different (100.0 %)
E   [index]: [0, 1]
E   [left]:  [b'\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf0?\x00\x00\x00\x00\x00\x00\xf0?']
E   [right]: [b'\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'\x00\x00\x00\x00\x01?\xf0\x00\x00\x00\x00\x00\x00?\xf0\x00\x00\x00\x00\x00\x00']
pandas/_libs/testing.pyx:168: AssertionError

Expected Output

Tests pass.

Versions

Python 3.10.0rc2 geopandas: 0.10.0 pandas: 1.3.0 Fiona: 1.8.20 NumPy: 1.21.1 Shapely: 1.7.1 rtree: 0.9.4 pyproj: 3.2.1 matplotlib: 3.5.0rc1 mapclassify: 2.4.3 geopy: N/A psycopg2: 2.9.1 geoalchemy2: N/A pyarrow: N/A pygeos: N/A

QuLogic avatar Oct 03 '21 21:10 QuLogic

@QuLogic thanks for the report! Yes, I think it is indeed failing because of the reason you mention. In pygeos, there is a byte_order keyword to optionally force a certain byte-order (instead of using the native machine byte order), and this is used in the tests to have them robust for this. But in GeoPandas we currently don't expose that keyword.

Long term we could maybe expose such a keyword in the geopandas version as well. Short term it seems fine to just skip those tests on big-endian systems (since the important aspect about the test is that it is correctly calling shapely/pygeos, and the actual correctness of the WKB is tested by those underlying libraries)

jorisvandenbossche avatar Oct 04 '21 19:10 jorisvandenbossche

Well for now, since geopandas is noarch, I just brute-force retried until I got a builder that wasn't s390x.

QuLogic avatar Oct 04 '21 20:10 QuLogic