diff --git a/0001-Mark-tests-that-require-the-network.patch b/0001-Mark-tests-that-require-the-network.patch deleted file mode 100644 index 14bec76..0000000 --- a/0001-Mark-tests-that-require-the-network.patch +++ /dev/null @@ -1,146 +0,0 @@ -From 8d0c4cb04e2f51656886adee46dfe99ddf78b5be Mon Sep 17 00:00:00 2001 -From: Elliott Sales de Andrade -Date: Thu, 5 Mar 2020 03:25:23 -0500 -Subject: [PATCH] Mark tests that require the network. - -Signed-off-by: Elliott Sales de Andrade ---- - tests/conftest.py | 3 +++ - tests/test_ctx.py | 14 ++++++++++++++ - tests/test_providers.py | 1 + - 3 files changed, 18 insertions(+) - create mode 100644 tests/conftest.py - -diff --git a/tests/conftest.py b/tests/conftest.py -new file mode 100644 -index 0000000..f7dcea5 ---- /dev/null -+++ b/tests/conftest.py -@@ -0,0 +1,3 @@ -+def pytest_configure(config): -+ config.addinivalue_line("markers", -+ "network: mark tests that use the network.") -diff --git a/tests/test_ctx.py b/tests/test_ctx.py -index 1cdf943..9ba13ba 100644 ---- a/tests/test_ctx.py -+++ b/tests/test_ctx.py -@@ -5,6 +5,7 @@ import contextily as ctx - import os - import numpy as np - import mercantile as mt -+import pytest - import rasterio as rio - from contextily.tile import _calculate_zoom - from numpy.testing import assert_array_almost_equal -@@ -17,6 +18,7 @@ ADJUST = -3 # To save download size / time - # Tile - - -+@pytest.mark.network - def test_bounds2raster(): - w, s, e, n = ( - -106.6495132446289, -@@ -68,6 +70,7 @@ def test_bounds2raster(): - assert_array_almost_equal(list(rtr.bounds), rtr_bounds) - - -+@pytest.mark.network - def test_bounds2img(): - w, s, e, n = ( - -106.6495132446289, -@@ -89,6 +92,7 @@ def test_bounds2img(): - assert img[200, 100, :].tolist() == [230, 225, 189, 255] - - -+@pytest.mark.network - def test_warp_tiles(): - w, s, e, n = ( - -106.6495132446289, -@@ -114,6 +118,7 @@ def test_warp_tiles(): - assert wimg[200, 100, :].tolist() == [133, 130, 109, 255] - - -+@pytest.mark.network - def test_warp_img_transform(): - w, s, e, n = ext = ( - -106.6495132446289, -@@ -145,6 +150,7 @@ def test_howmany(): - assert got == expected - - -+@pytest.mark.network - def test_ll2wdw(): - w, s, e, n = ( - -106.6495132446289, -@@ -183,6 +189,7 @@ def test_autozoom(): - assert zoom == expected_zoom - - -+@pytest.mark.network - def test_validate_zoom(): - # tiny extent to trigger large calculated zoom - w, s, e, n = (0, 0, 0.001, 0.001) -@@ -208,6 +215,7 @@ def test_validate_zoom(): - # Place - - -+@pytest.mark.network - def test_place(): - expected_bbox = [-105.430545, 39.8549856, -105.110545, 40.1749856] - expected_bbox_map = [ -@@ -239,6 +247,7 @@ def test_place(): - assert_array_almost_equal(loc.bbox_map, ax.images[0].get_extent()) - - -+@pytest.mark.network - def test_plot_map(): - # Place as a search - loc = ctx.Place(SEARCH, zoom_adjust=ADJUST) -@@ -258,6 +267,7 @@ def test_plot_map(): - # Plotting - - -+@pytest.mark.network - def test_add_basemap(): - # Plot boulder bbox as in test_place - x1, x2, y1, y2 = [ -@@ -380,6 +390,8 @@ def test_add_basemap(): - 4891969.810251278, - ] - -+ -+@pytest.mark.network - def test_add_basemap_overlay(): - x1, x2, y1, y2 = [ - -11740727.544603072, -@@ -427,6 +439,7 @@ def test_add_basemap_overlay(): - assert ax.images[1].get_array().sum() == 51551927 - - -+@pytest.mark.network - def test_basemap_attribution(): - extent = (-11945319, -10336026, 2910477, 4438236) - -@@ -478,6 +491,7 @@ def test_attribution(): - assert txt.get_fontfamily() == ["monospace"] - - -+@pytest.mark.network - def test_set_cache_dir(tmpdir): - # set cache directory manually - path = str(tmpdir.mkdir("cache")) -diff --git a/tests/test_providers.py b/tests/test_providers.py -index 40c88cf..2e431f7 100644 ---- a/tests/test_providers.py -+++ b/tests/test_providers.py -@@ -5,6 +5,7 @@ import pytest - from numpy.testing import assert_allclose - - -+@pytest.mark.network - def test_providers(): - # NOTE: only tests they download, does not check pixel values - w, s, e, n = ( --- -2.31.1 - diff --git a/0001-TST-update-tests-to-match-the-return-206.patch b/0001-TST-update-tests-to-match-the-return-206.patch new file mode 100644 index 0000000..0f63b69 --- /dev/null +++ b/0001-TST-update-tests-to-match-the-return-206.patch @@ -0,0 +1,222 @@ +From 7e90cf2f71f166abf6b88b2b5eb60b87ce54cbd9 Mon Sep 17 00:00:00 2001 +From: Martin Fleischmann +Date: Sun, 1 Jan 2023 21:50:32 +0100 +Subject: [PATCH 1/2] TST: update tests to match the return (#206) + +* update tests to match returned tiles + +* change api_key to match xyzeservices update + +Signed-off-by: Elliott Sales de Andrade +--- + tests/test_ctx.py | 100 +++++++++++++++++++++++++--------------- + tests/test_providers.py | 2 +- + 2 files changed, 65 insertions(+), 37 deletions(-) + +diff --git a/tests/test_ctx.py b/tests/test_ctx.py +index 1cdf943..97d78cd 100644 +--- a/tests/test_ctx.py ++++ b/tests/test_ctx.py +@@ -38,9 +38,9 @@ def test_bounds2raster(): + assert img[100, 100, :].tolist() == [230, 229, 188, 255] + assert img[100, 200, :].tolist() == [156, 180, 131, 255] + assert img[200, 100, :].tolist() == [230, 225, 189, 255] +- assert img[:,:,:3].sum() == 36926856 ++ assert img[:, :, :3].sum() == 36926856 + assert img.sum() == 53638536 +- assert_array_almost_equal(img[:,:,:3].mean(), 187.8197021484375) ++ assert_array_almost_equal(img[:, :, :3].mean(), 187.8197021484375) + assert_array_almost_equal(img.mean(), 204.614777) + + # multiple tiles for which result is not square +@@ -209,16 +209,16 @@ def test_validate_zoom(): + + + def test_place(): +- expected_bbox = [-105.430545, 39.8549856, -105.110545, 40.1749856] ++ expected_bbox = [-105.3014509, 39.9643513, -105.1780988, 40.094409] + expected_bbox_map = [ + -11740727.544603072, +- -11662456.027639052, +- 4774562.53480525, +- 4931105.568733288, ++ -11701591.786121061, ++ 4852834.0517692715, ++ 4891969.810251278, + ] +- expected_zoom = 9 ++ expected_zoom = 10 + loc = ctx.Place(SEARCH, zoom_adjust=ADJUST) +- assert loc.im.shape == (512, 256, 4) ++ assert loc.im.shape == (256, 256, 4) + loc # Make sure repr works + + # Check auto picks are correct +@@ -279,9 +279,13 @@ def test_add_basemap(): + + assert ax.images[0].get_array().sum() == 51551927 + assert ax.images[0].get_array().shape == (256, 256, 4) +- assert_array_almost_equal(ax.images[0].get_array()[:,:,:3].mean(), 177.20665995279947) ++ assert_array_almost_equal( ++ ax.images[0].get_array()[:, :, :3].mean(), 177.20665995279947 ++ ) + assert_array_almost_equal(ax.images[0].get_array().mean(), 196.654995) + ++ ++def test_add_basemap_local_source(): + # Test local source + ## Windowed read + subset = ( +@@ -298,12 +302,21 @@ def test_add_basemap(): + ctx.add_basemap(ax, source="./test2.tif", reset_extent=True) + + assert_array_almost_equal(subset, ax.images[0].get_extent()) +- assert ax.images[0].get_array().sum() == 3187219 +- assert ax.images[0].get_array()[:,:,:3].sum() == 2175124 +- assert ax.images[0].get_array().shape == (64, 64, 4) +- assert_array_almost_equal(ax.images[0].get_array()[:,:,:3].mean(), 177.01204427083334) +- assert_array_almost_equal(ax.images[0].get_array().mean(), 194.53240966796875) ++ assert ax.images[0].get_array().sum() == 12489346 ++ assert ax.images[0].get_array()[:, :, :3].sum() == 8440966 ++ assert ax.images[0].get_array().shape == (126, 126, 4) ++ assert_array_almost_equal(ax.images[0].get_array()[:, :, :3].mean(), 177.226967) ++ assert_array_almost_equal(ax.images[0].get_array().mean(), 196.670225) ++ ++ ++def test_add_basemap_full_read(): + ## Full read ++ x1, x2, y1, y2 = [ ++ -11740727.544603072, ++ -11701591.786121061, ++ 4852834.0517692715, ++ 4891969.810251278, ++ ] + f, ax = matplotlib.pyplot.subplots(1) + ax.set_xlim(x1, x2) + ax.set_ylim(y1, y2) +@@ -311,19 +324,27 @@ def test_add_basemap(): + ctx.add_basemap(ax, source="./test2.tif", reset_extent=False) + + raster_extent = ( +- -11740880.418659642, +- -11662608.901695622, +- 4774715.408861821, +- 4931258.442789858, ++ -11740803.981631, ++ -11701668.223149, ++ 4852910.488798, ++ 4892046.24728, + ) + assert_array_almost_equal(raster_extent, ax.images[0].get_extent()) +- assert ax.images[0].get_array()[:,:,:3].sum() == 76248416 +- assert ax.images[0].get_array().sum() == 109671776 +- assert ax.images[0].get_array().shape == (512, 256, 4) +- assert_array_almost_equal(ax.images[0].get_array()[:,:,:3].mean(), 193.90974934895834) +- assert_array_almost_equal(ax.images[0].get_array().mean(), 209.18231201171875) ++ assert ax.images[0].get_array()[:, :, :3].sum() == 34840247 ++ assert ax.images[0].get_array().sum() == 51551927 ++ assert ax.images[0].get_array().shape == (256, 256, 4) ++ assert_array_almost_equal(ax.images[0].get_array()[:, :, :3].mean(), 177.20666) ++ assert_array_almost_equal(ax.images[0].get_array().mean(), 196.654995) ++ + ++def test_add_basemap_auto_zoom(): + # Test with auto-zoom ++ x1, x2, y1, y2 = [ ++ -11740727.544603072, ++ -11701591.786121061, ++ 4852834.0517692715, ++ 4891969.810251278, ++ ] + f, ax = matplotlib.pyplot.subplots(1) + ax.set_xlim(x1, x2) + ax.set_ylim(y1, y2) +@@ -336,12 +357,16 @@ def test_add_basemap(): + 4891969.810251278, + ) + assert_array_almost_equal(ax_extent, ax.images[0].get_extent()) +- assert ax.images[0].get_array()[:,:,:3].sum() == 563185119 ++ assert ax.images[0].get_array()[:, :, :3].sum() == 563185119 + assert ax.images[0].get_array().sum() == 830571999 + assert ax.images[0].get_array().shape == (1024, 1024, 4) +- assert_array_almost_equal(ax.images[0].get_array()[:,:,:3].mean(), 179.03172779083252) ++ assert_array_almost_equal( ++ ax.images[0].get_array()[:, :, :3].mean(), 179.03172779083252 ++ ) + assert_array_almost_equal(ax.images[0].get_array().mean(), 198.023796) + ++ ++def test_add_basemap_warping(): + # Test on-th-fly warping + x1, x2 = -105.5, -105.00 + y1, y2 = 39.56, 40.13 +@@ -351,11 +376,18 @@ def test_add_basemap(): + ctx.add_basemap(ax, crs={"init": "epsg:4326"}, attribution=None) + assert ax.get_xlim() == (x1, x2) + assert ax.get_ylim() == (y1, y2) +- assert ax.images[0].get_array()[:,:,:3].sum() == 724238693 ++ assert ax.images[0].get_array()[:, :, :3].sum() == 724238693 + assert ax.images[0].get_array().shape == (1135, 1183, 4) +- assert_array_almost_equal(ax.images[0].get_array()[:,:,:3].mean(), 179.79593258881636) ++ assert_array_almost_equal( ++ ax.images[0].get_array()[:, :, :3].mean(), 179.79593258881636 ++ ) + assert_array_almost_equal(ax.images[0].get_array().mean(), 198.596949) ++ ++ ++def test_add_basemap_warping_local(): + # Test local source warping ++ x1, x2 = -105.5, -105.00 ++ y1, y2 = 39.56, 40.13 + _ = ctx.bounds2raster(x1, y1, x2, y2, "./test2.tif", ll=True) + f, ax = matplotlib.pyplot.subplots(1) + ax.set_xlim(x1, x2) +@@ -366,19 +398,13 @@ def test_add_basemap(): + assert ax.get_xlim() == (x1, x2) + assert ax.get_ylim() == (y1, y2) + +- assert ax.images[0].get_array()[:,:,:3].sum() == 464536503 ++ assert ax.images[0].get_array()[:, :, :3].sum() == 464536503 + assert ax.images[0].get_array().shape == (980, 862, 4) +- assert_array_almost_equal(ax.images[0].get_array()[:,:,:3].mean(), 183.301175) ++ assert_array_almost_equal(ax.images[0].get_array()[:, :, :3].mean(), 183.301175) + + assert ax.images[0].get_array().sum() == 678981558 + assert_array_almost_equal(ax.images[0].get_array().mean(), 200.939189) + +- x1, x2, y1, y2 = [ +- -11740727.544603072, +- -11701591.786121061, +- 4852834.0517692715, +- 4891969.810251278, +- ] + + def test_add_basemap_overlay(): + x1, x2, y1, y2 = [ +@@ -404,7 +430,9 @@ def test_add_basemap_overlay(): + assert ax.images[0].get_array()[:, :, :3].sum() == 34840247 + assert ax.images[0].get_array().sum() == 51551927 + assert ax.images[0].get_array().shape == (256, 256, 4) +- assert_array_almost_equal(ax.images[0].get_array()[:, :, :3].mean(), 177.20665995279947) ++ assert_array_almost_equal( ++ ax.images[0].get_array()[:, :, :3].mean(), 177.20665995279947 ++ ) + assert_array_almost_equal(ax.images[0].get_array().mean(), 196.654995) + + # check totals on overaly (mostly transparent labels) layer +diff --git a/tests/test_providers.py b/tests/test_providers.py +index 40c88cf..ce26b39 100644 +--- a/tests/test_providers.py ++++ b/tests/test_providers.py +@@ -29,7 +29,7 @@ def test_providers_callable(): + assert "url" in updated_provider + assert updated_provider["apikey"] == "mykey" + # check that original provider dict is not modified +- assert ctx.providers.GeoportailFrance.plan["apikey"] == "choisirgeoportail" ++ assert ctx.providers.GeoportailFrance.plan["apikey"] == "essentiels" + + + def test_invalid_provider(): +-- +2.38.1 + diff --git a/0002-Mark-tests-that-require-the-network.patch b/0002-Mark-tests-that-require-the-network.patch new file mode 100644 index 0000000..970f492 --- /dev/null +++ b/0002-Mark-tests-that-require-the-network.patch @@ -0,0 +1,186 @@ +From 4f36c038b8ca7b6adf7923c79cd04c3d79fe3d97 Mon Sep 17 00:00:00 2001 +From: Elliott Sales de Andrade +Date: Thu, 5 Mar 2020 03:25:23 -0500 +Subject: [PATCH 2/2] Mark tests that require the network. + +Signed-off-by: Elliott Sales de Andrade +--- + tests/conftest.py | 3 +++ + tests/test_ctx.py | 19 +++++++++++++++++++ + tests/test_providers.py | 1 + + 3 files changed, 23 insertions(+) + create mode 100644 tests/conftest.py + +diff --git a/tests/conftest.py b/tests/conftest.py +new file mode 100644 +index 0000000..f7dcea5 +--- /dev/null ++++ b/tests/conftest.py +@@ -0,0 +1,3 @@ ++def pytest_configure(config): ++ config.addinivalue_line("markers", ++ "network: mark tests that use the network.") +diff --git a/tests/test_ctx.py b/tests/test_ctx.py +index 97d78cd..02b4d5b 100644 +--- a/tests/test_ctx.py ++++ b/tests/test_ctx.py +@@ -5,6 +5,7 @@ import contextily as ctx + import os + import numpy as np + import mercantile as mt ++import pytest + import rasterio as rio + from contextily.tile import _calculate_zoom + from numpy.testing import assert_array_almost_equal +@@ -17,6 +18,7 @@ ADJUST = -3 # To save download size / time + # Tile + + ++@pytest.mark.network + def test_bounds2raster(): + w, s, e, n = ( + -106.6495132446289, +@@ -68,6 +70,7 @@ def test_bounds2raster(): + assert_array_almost_equal(list(rtr.bounds), rtr_bounds) + + ++@pytest.mark.network + def test_bounds2img(): + w, s, e, n = ( + -106.6495132446289, +@@ -89,6 +92,7 @@ def test_bounds2img(): + assert img[200, 100, :].tolist() == [230, 225, 189, 255] + + ++@pytest.mark.network + def test_warp_tiles(): + w, s, e, n = ( + -106.6495132446289, +@@ -114,6 +118,7 @@ def test_warp_tiles(): + assert wimg[200, 100, :].tolist() == [133, 130, 109, 255] + + ++@pytest.mark.network + def test_warp_img_transform(): + w, s, e, n = ext = ( + -106.6495132446289, +@@ -145,6 +150,7 @@ def test_howmany(): + assert got == expected + + ++@pytest.mark.network + def test_ll2wdw(): + w, s, e, n = ( + -106.6495132446289, +@@ -183,6 +189,7 @@ def test_autozoom(): + assert zoom == expected_zoom + + ++@pytest.mark.network + def test_validate_zoom(): + # tiny extent to trigger large calculated zoom + w, s, e, n = (0, 0, 0.001, 0.001) +@@ -208,6 +215,7 @@ def test_validate_zoom(): + # Place + + ++@pytest.mark.network + def test_place(): + expected_bbox = [-105.3014509, 39.9643513, -105.1780988, 40.094409] + expected_bbox_map = [ +@@ -239,6 +247,7 @@ def test_place(): + assert_array_almost_equal(loc.bbox_map, ax.images[0].get_extent()) + + ++@pytest.mark.network + def test_plot_map(): + # Place as a search + loc = ctx.Place(SEARCH, zoom_adjust=ADJUST) +@@ -258,6 +267,7 @@ def test_plot_map(): + # Plotting + + ++@pytest.mark.network + def test_add_basemap(): + # Plot boulder bbox as in test_place + x1, x2, y1, y2 = [ +@@ -285,6 +295,7 @@ def test_add_basemap(): + assert_array_almost_equal(ax.images[0].get_array().mean(), 196.654995) + + ++@pytest.mark.network + def test_add_basemap_local_source(): + # Test local source + ## Windowed read +@@ -309,6 +320,7 @@ def test_add_basemap_local_source(): + assert_array_almost_equal(ax.images[0].get_array().mean(), 196.670225) + + ++@pytest.mark.network + def test_add_basemap_full_read(): + ## Full read + x1, x2, y1, y2 = [ +@@ -337,6 +349,7 @@ def test_add_basemap_full_read(): + assert_array_almost_equal(ax.images[0].get_array().mean(), 196.654995) + + ++@pytest.mark.network + def test_add_basemap_auto_zoom(): + # Test with auto-zoom + x1, x2, y1, y2 = [ +@@ -366,6 +379,7 @@ def test_add_basemap_auto_zoom(): + assert_array_almost_equal(ax.images[0].get_array().mean(), 198.023796) + + ++@pytest.mark.network + def test_add_basemap_warping(): + # Test on-th-fly warping + x1, x2 = -105.5, -105.00 +@@ -384,6 +398,7 @@ def test_add_basemap_warping(): + assert_array_almost_equal(ax.images[0].get_array().mean(), 198.596949) + + ++@pytest.mark.network + def test_add_basemap_warping_local(): + # Test local source warping + x1, x2 = -105.5, -105.00 +@@ -406,6 +421,8 @@ def test_add_basemap_warping_local(): + assert_array_almost_equal(ax.images[0].get_array().mean(), 200.939189) + + ++ ++@pytest.mark.network + def test_add_basemap_overlay(): + x1, x2, y1, y2 = [ + -11740727.544603072, +@@ -455,6 +472,7 @@ def test_add_basemap_overlay(): + assert ax.images[1].get_array().sum() == 51551927 + + ++@pytest.mark.network + def test_basemap_attribution(): + extent = (-11945319, -10336026, 2910477, 4438236) + +@@ -506,6 +524,7 @@ def test_attribution(): + assert txt.get_fontfamily() == ["monospace"] + + ++@pytest.mark.network + def test_set_cache_dir(tmpdir): + # set cache directory manually + path = str(tmpdir.mkdir("cache")) +diff --git a/tests/test_providers.py b/tests/test_providers.py +index ce26b39..4814fab 100644 +--- a/tests/test_providers.py ++++ b/tests/test_providers.py +@@ -5,6 +5,7 @@ import pytest + from numpy.testing import assert_allclose + + ++@pytest.mark.network + def test_providers(): + # NOTE: only tests they download, does not check pixel values + w, s, e, n = ( +-- +2.38.1 + diff --git a/python-contextily.spec b/python-contextily.spec index 0fd1259..7124191 100644 --- a/python-contextily.spec +++ b/python-contextily.spec @@ -11,8 +11,10 @@ Summary: Context geo-tiles in Python License: BSD URL: https://github.com/geopandas/contextily Source0: %{url}/archive/v%{version}/%{srcname}-%{version}.tar.gz +# https://github.com/geopandas/contextily/pull/206 +Patch: 0001-TST-update-tests-to-match-the-return-206.patch # https://github.com/geopandas/contextily/pull/124 -Patch0001: 0001-Mark-tests-that-require-the-network.patch +Patch: 0002-Mark-tests-that-require-the-network.patch BuildArch: noarch