Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: test_to_wkb fails on big-endian systems #2155

Open
3 tasks done
QuLogic opened this issue Oct 3, 2021 · 2 comments
Open
3 tasks done

BUG: test_to_wkb fails on big-endian systems #2155

QuLogic opened this issue Oct 3, 2021 · 2 comments

Comments

@QuLogic
Copy link
Contributor

QuLogic commented Oct 3, 2021

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of geopandas.
  • (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

@jorisvandenbossche
Copy link
Member

@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)

@QuLogic
Copy link
Contributor Author

QuLogic commented Oct 4, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants