Skip to content

Test failure with antimeridian 0.4.0 #479

@avalentino

Description

@avalentino

Describe the bug
After the update to antimeridian 0.4.0 three tests fail

To reproduce
Steps to reproduce the behavior:

Ex.

  1. Install stactools
python3 -m build --skip-dependency-check --no-isolation --wheel

All dependencies have been installed manually via apt package manager

  1. Run scripts/test
python3 -m pytest tests
  1. See error

Expected behavior

All tests pass successfully

Screenshots and shell session dumps

============================= test session starts ==============================
platform linux -- Python 3.12.8, pytest-8.3.4, pluggy-1.5.0
rootdir: /build/stactools-0.5.3/.pybuild/cpython3_3.12/build
configfile: pyproject.toml
plugins: anyio-4.6.2, typeguard-4.4.1
collected 103 items / 8 deselected / 95 selected

tests/cli/commands/test_add.py ...                                       [  3%]
tests/cli/commands/test_add_asset.py ..                                  [  5%]
tests/cli/commands/test_add_raster.py .                                  [  6%]
tests/cli/commands/test_copy.py .......                                  [ 13%]
tests/cli/commands/test_create.py ...                                    [ 16%]
tests/cli/commands/test_info.py ..                                       [ 18%]
tests/cli/commands/test_lint.py .                                        [ 20%]
tests/cli/commands/test_merge.py ....                                    [ 24%]
tests/cli/commands/test_migrate.py ........                              [ 32%]
tests/cli/commands/test_summary.py .                                     [ 33%]
tests/cli/commands/test_update_extent.py .                               [ 34%]
tests/cli/commands/test_update_geometry.py .                             [ 35%]
tests/cli/commands/test_validate.py ..                                   [ 37%]
tests/cli/commands/test_version.py ..                                    [ 40%]
tests/core/test_add_asset.py ........                                    [ 48%]
tests/core/test_add_raster.py ...............                            [ 64%]
tests/core/test_create.py .                                              [ 65%]
tests/core/test_io.py .                                                  [ 66%]
tests/core/test_projection.py .                                          [ 67%]
tests/core/utils/test_antimeridian.py F...F..F                           [ 75%]
tests/core/utils/test_convert.py ...                                     [ 78%]
tests/core/utils/test_raster_footprint.py ..............                 [ 93%]
tests/core/utils/test_round.py .....                                     [ 98%]
tests/testing/test_test_data.py s                                        [100%]

=================================== FAILURES ===================================
___________________________ test_antimeridian_split ____________________________

    def test_antimeridian_split() -> None:
        # From https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.9
        canonical = Polygon(((170, 40), (-170, 40), (-170, 50), (170, 50), (170, 40)))
        with pytest.warns(DeprecationWarning):
            split = antimeridian.split(canonical)
        assert split
        expected = MultiPolygon(
            (
                shapely.geometry.box(170, 40, 180, 50),
                shapely.geometry.box(-180, 40, -170, 50),
            ),
        )
        for actual, expected in zip(split.geoms, expected.geoms):
            assert actual.exterior.is_ccw
>           assert actual.equals(expected)
E           assert False
E            +  where False = equals(<POLYGON ((180 40, 180 50, 170 50, 170 40, 180 40))>)
E            +    where equals = <POLYGON ((180 50.431, 170 50, 170 40, 180 40.432, 180 50.431))>.equals

tests/core/utils/test_antimeridian.py:24: AssertionError
_______________________ test_item_fix_antimeridian_split _______________________

    def test_item_fix_antimeridian_split() -> None:
        canonical = Polygon(((170, 40), (-170, 40), (-170, 50), (170, 50), (170, 40)))
        item = Item(
            "an-id",
            geometry=shapely.geometry.mapping(canonical),
            bbox=canonical.bounds,
            datetime=datetime.datetime.now(),
            properties={},
        )
        fix = antimeridian.fix_item(item, antimeridian.Strategy.SPLIT)
        expected = MultiPolygon(
            (
                shapely.geometry.box(170, 40, 180, 50),
                shapely.geometry.box(-180, 40, -170, 50),
            ),
        )
        for actual, expected in zip(
            shapely.geometry.shape(fix.geometry).geoms,
            expected.geoms,
        ):
>           assert actual.equals(expected)
E           assert False
E            +  where False = equals(<POLYGON ((180 40, 180 50, 170 50, 170 40, 180 40))>)
E            +    where equals = <POLYGON ((180 50.431, 170 50, 170 40, 180 40.432, 180 50.431))>.equals

tests/core/utils/test_antimeridian.py:110: AssertionError
________________________ test_antimeridian_multipolygon ________________________

    def test_antimeridian_multipolygon() -> None:
        multi_polygon = MultiPolygon(
            [
                Polygon(((170, 40), (-170, 40), (-170, 42), (170, 42), (170, 40))),
                Polygon(((170, 48), (-170, 48), (-170, 50), (170, 50), (170, 48))),
            ],
        )
        with pytest.warns(DeprecationWarning):
            split = antimeridian.split_multipolygon(multi_polygon)
        assert split
        expected = MultiPolygon(
            (
                shapely.geometry.box(170, 40, 180, 42),
                shapely.geometry.box(-180, 40, -170, 42),
                shapely.geometry.box(170, 48, 180, 50),
                shapely.geometry.box(-180, 48, -170, 50),
            ),
        )
        for actual, expected in zip(split.geoms, expected.geoms):
            assert actual.exterior.is_ccw
>           assert actual.equals(expected), f"actual={actual}, expected={expected}"
E           AssertionError: actual=POLYGON ((180 42.4364955, 170 42, 170 40, 180 40.4324611, 180 42.4364955)), expected=POLYGON ((180 40, 180 42, 170 42, 170 40, 180 40))
E           assert False
E            +  where False = equals(<POLYGON ((180 40, 180 42, 170 42, 170 40, 180 40))>)
E            +    where equals = <POLYGON ((180 42.436, 170 42, 170 40, 180 40.432, 180 42.436))>.equals

tests/core/utils/test_antimeridian.py:279: AssertionError
=============================== warnings summary ===============================

[CUT]

=========================== short test summary info ============================
FAILED tests/core/utils/test_antimeridian.py::test_antimeridian_split - asser...
FAILED tests/core/utils/test_antimeridian.py::test_item_fix_antimeridian_split
FAILED tests/core/utils/test_antimeridian.py::test_antimeridian_multipolygon
===== 3 failed, 91 passed, 1 skipped, 8 deselected, 13 warnings in 18.00s ======

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions