[Git][debian-gis-team/python-cartopy][upstream] New upstream version 0.20.2+dfsg
Bas Couwenberg (@sebastic)
gitlab at salsa.debian.org
Thu Jan 13 05:05:13 GMT 2022
Bas Couwenberg pushed to branch upstream at Debian GIS Project / python-cartopy
Commits:
630f543e by Bas Couwenberg at 2022-01-13T05:52:03+01:00
New upstream version 0.20.2+dfsg
- - - - -
17 changed files:
- .git_archival.txt
- .github/workflows/ci-testing.yml
- lib/cartopy/crs.py
- lib/cartopy/io/ogc_clients.py
- lib/cartopy/mpl/geoaxes.py
- lib/cartopy/mpl/geocollection.py
- lib/cartopy/mpl/gridliner.py
- lib/cartopy/tests/crs/test_albers_equal_area.py
- lib/cartopy/tests/crs/test_equidistant_conic.py
- lib/cartopy/tests/mpl/baseline_images/mpl/test_features/natural_earth.png
- lib/cartopy/tests/mpl/test_features.py
- lib/cartopy/tests/mpl/test_mpl_integration.py
- lib/cartopy/tests/mpl/test_pseudo_color.py
- lib/cartopy/tests/test_crs.py
- lib/cartopy/tests/test_line_string.py
- lib/cartopy/tests/test_linear_ring.py
- lib/cartopy/tests/test_polygon.py
Changes:
=====================================
.git_archival.txt
=====================================
@@ -1 +1 @@
-ref-names: tag: v0.20.1, v0.20.x
+ref-names: tag: v0.20.2, v0.20.x
=====================================
.github/workflows/ci-testing.yml
=====================================
@@ -24,18 +24,17 @@ jobs:
channels: conda-forge/label/testing,conda-forge
- name: Minimum packages
- # Only run on macos for now
+ # Only run on Linux for now
# Conda's linux packages don't grab the testing label of matplotlib causing failures due to freetype differences
- if: matrix.python-version == '3.7' && matrix.os == 'macos-latest'
+ if: matrix.python-version == '3.7' && matrix.os == 'ubuntu-latest'
id: minimum-packages
run: |
- echo "PACKAGES=cython=0.28.5 matplotlib=3.1 numpy=1.18 owslib=0.17 pyproj=3.0 proj=8.0 scipy=1.2.0" >> $GITHUB_ENV
- echo "CFLAGS=-stdlib=libc++" >> $GITHUB_ENV
+ echo "PACKAGES=cython=0.28.5 matplotlib=3.1 numpy=1.18 owslib=0.17 pyproj=3.0 proj=8.0 scipy=1.2.0 shapely=1.6.4" >> $GITHUB_ENV
- name: Latest packages
if: steps.minimum-packages.conclusion == 'skipped'
run: |
- echo "PACKAGES=cython fiona matplotlib-base numpy pyproj pykdtree scipy" >> $GITHUB_ENV
+ echo "PACKAGES=cython fiona matplotlib-base numpy pyproj 'proj>=8' pykdtree scipy shapely" >> $GITHUB_ENV
- name: Coverage packages
id: coverage
@@ -51,6 +50,10 @@ jobs:
PACKAGES="$PACKAGES flufl.lock owslib pep8 pillow pyshp pytest"
PACKAGES="$PACKAGES pytest-xdist requests setuptools_scm"
PACKAGES="$PACKAGES setuptools_scm_git_archive shapely"
+ # openssl 3.0 updated the legacy renegotiation default, which causes
+ # failures in NASA's WMTS server. They will need to update their
+ # server before we can use a newer openssl.
+ PACKAGES="$PACKAGES openssl<3"
conda install $PACKAGES
conda info -a
conda list
=====================================
lib/cartopy/crs.py
=====================================
@@ -12,6 +12,7 @@ between them.
from abc import ABCMeta
from collections import OrderedDict
+from functools import lru_cache
import io
import json
import math
@@ -39,8 +40,14 @@ WGS84_SEMIMAJOR_AXIS = 6378137.0
WGS84_SEMIMINOR_AXIS = 6356752.3142
+# Cache the transformer creation method
+ at lru_cache()
+def _get_transformer_from_crs(src_crs, tgt_crs):
+ return Transformer.from_crs(src_crs, tgt_crs, always_xy=True)
+
+
def _safe_pj_transform(src_crs, tgt_crs, x, y, z=None, trap=True):
- transformer = Transformer.from_crs(src_crs, tgt_crs, always_xy=True)
+ transformer = _get_transformer_from_crs(src_crs, tgt_crs)
transformed_coords = transformer.transform(x, y, z, errcheck=trap)
if z is None:
xx, yy = transformed_coords
@@ -822,7 +829,7 @@ class Projection(CRS, metaclass=ABCMeta):
threshold = max(np.abs(self.x_limits + self.y_limits)) * 1e-5
# 2) Simplify the segments where appropriate.
- if len(multi_line_string) > 1:
+ if len(multi_line_string.geoms) > 1:
# Stitch together segments which are close to continuous.
# This is important when:
# 1) The first source point projects into the map and the
@@ -833,7 +840,7 @@ class Projection(CRS, metaclass=ABCMeta):
# 2) The cut ends of segments are too close to reliably
# place into an order along the boundary.
- line_strings = list(multi_line_string)
+ line_strings = list(multi_line_string.geoms)
any_modified = False
i = 0
if debug:
@@ -874,7 +881,7 @@ class Projection(CRS, metaclass=ABCMeta):
# 3) Check for rings that have been created by the projection stage.
rings = []
line_strings = []
- for line in multi_line_string:
+ for line in multi_line_string.geoms:
if len(line.coords) > 3 and np.allclose(line.coords[0],
line.coords[-1],
atol=threshold):
@@ -941,7 +948,7 @@ class Projection(CRS, metaclass=ABCMeta):
p_rings, p_mline = self._project_linear_ring(src_ring, src_crs)
if p_rings:
rings.extend(p_rings)
- if len(p_mline) > 0:
+ if len(p_mline.geoms) > 0:
multi_lines.append(p_mline)
# Convert any lines to rings by attaching them to the boundary.
@@ -979,7 +986,7 @@ class Projection(CRS, metaclass=ABCMeta):
# Squash all the LineStrings into a single list.
line_strings = []
for multi_line_string in multi_line_strings:
- line_strings.extend(multi_line_string)
+ line_strings.extend(multi_line_string.geoms)
# Record the positions of all the segment ends
for i, line_string in enumerate(line_strings):
@@ -1639,6 +1646,9 @@ class Mercator(Projection):
super().__init__(proj4_params, globe=globe)
+ # Need to have x/y limits defined for the initial hash which
+ # gets used within transform_points for caching
+ self._x_limits = self._y_limits = None
# Calculate limits.
minlon, maxlon = self._determine_longitude_bounds(central_longitude)
limits = self.transform_points(self.as_geodetic(),
=====================================
lib/cartopy/io/ogc_clients.py
=====================================
@@ -162,7 +162,7 @@ def _target_extents(extent, requested_projection, available_projection):
# Return the polygons' rectangular bounds as extent tuples.
target_extents = []
- for poly in polys:
+ for poly in polys.geoms:
min_x, min_y, max_x, max_y = poly.bounds
if fudge_mode:
# If we shrunk the request area before, then here we
=====================================
lib/cartopy/mpl/geoaxes.py
=====================================
@@ -1863,10 +1863,6 @@ class GeoAxes(matplotlib.axes.Axes):
cross the boundary of the projection.
"""
t = kwargs.get('transform', None)
- if not (getattr(t, '_wrappable', False) and
- getattr(self.projection, '_wrappable', False)):
- # Nothing to do
- return collection
# Get the quadmesh data coordinates
coords = collection._coordinates
@@ -1902,8 +1898,25 @@ class GeoAxes(matplotlib.axes.Axes):
np.isnan(diagonal1_lengths) |
(diagonal1_lengths > size_limit))
- if not np.any(mask):
- # No wrapping needed
+ # Update the data limits based on the corners of the mesh
+ # in transformed coordinates, ignoring nan values
+ with warnings.catch_warnings():
+ warnings.filterwarnings('ignore', 'All-NaN slice encountered')
+ # If we have all nans, that is OK and will be handled by the
+ # Bbox calculations later, so suppress that warning from the user
+ corners = ((np.nanmin(xs), np.nanmin(ys)),
+ (np.nanmax(xs), np.nanmax(ys)))
+ collection._corners = mtransforms.Bbox(corners)
+ self.update_datalim(collection._corners)
+
+ # We need to keep the transform/projection check after
+ # update_datalim to make sure we are getting the proper
+ # datalims on the returned collection
+ if (not (getattr(t, '_wrappable', False) and
+ getattr(self.projection, '_wrappable', False)) or
+ not np.any(mask)):
+ # If both projections are unwrappable
+ # or if there aren't any points to wrap
return collection
# Wrapping with gouraud shading is error-prone. We will do our best,
=====================================
lib/cartopy/mpl/geocollection.py
=====================================
@@ -52,3 +52,8 @@ class GeoQuadMesh(QuadMesh):
# Update color limits for the rest of the cells.
super().set_clim(vmin, vmax)
+
+ def get_datalim(self, transData):
+ # Return the corners that were calculated in
+ # the pcolormesh routine.
+ return self._corners
=====================================
lib/cartopy/mpl/gridliner.py
=====================================
@@ -839,15 +839,20 @@ class Gridliner:
sgeom.MultiLineString)):
if isinstance(intersection, sgeom.LineString):
intersection = [intersection]
- elif len(intersection) > 4:
+ elif len(intersection.geoms) > 4:
# Gridline and map boundary are parallel and they
# intersect themselves too much it results in a
# multiline string that must be converted to a single
# linestring. This is an empirical workaround for a
# problem that can probably be solved in a cleaner way.
- xy = np.append(intersection[0], intersection[-1],
- axis=0)
+ xy = np.append(
+ intersection.geoms[0].coords,
+ intersection.geoms[-1].coords,
+ axis=0,
+ )
intersection = [sgeom.LineString(xy)]
+ else:
+ intersection = intersection.geoms
tails = []
heads = []
for inter in intersection:
=====================================
lib/cartopy/tests/crs/test_albers_equal_area.py
=====================================
@@ -61,8 +61,11 @@ class TestAlbersEqualArea:
'x_0=0.0', 'y_0=0.0', 'lat_1=20.0', 'lat_2=50.0'}
check_proj_params('aea', aea_offset, other_args)
- assert_array_almost_equal(aea_offset.boundary, aea.boundary,
- decimal=0)
+ assert_array_almost_equal(
+ aea_offset.boundary.coords,
+ aea.boundary.coords,
+ decimal=0,
+ )
def test_standard_parallels(self):
aea = ccrs.AlbersEqualArea(standard_parallels=(13, 37))
=====================================
lib/cartopy/tests/crs/test_equidistant_conic.py
=====================================
@@ -61,8 +61,11 @@ class TestEquidistantConic:
'x_0=0.0', 'y_0=0.0', 'lat_1=20.0', 'lat_2=50.0'}
check_proj_params('eqdc', eqdc_offset, other_args)
- assert_array_almost_equal(eqdc_offset.boundary, eqdc.boundary,
- decimal=0)
+ assert_array_almost_equal(
+ eqdc_offset.boundary.coords,
+ eqdc.boundary.coords,
+ decimal=0,
+ )
def test_standard_parallels(self):
eqdc = ccrs.EquidistantConic(standard_parallels=(13, 37))
=====================================
lib/cartopy/tests/mpl/baseline_images/mpl/test_features/natural_earth.png
=====================================
Binary files a/lib/cartopy/tests/mpl/baseline_images/mpl/test_features/natural_earth.png and b/lib/cartopy/tests/mpl/baseline_images/mpl/test_features/natural_earth.png differ
=====================================
lib/cartopy/tests/mpl/test_features.py
=====================================
@@ -16,7 +16,7 @@ from cartopy.tests.mpl import ImageTesting
@pytest.mark.filterwarnings("ignore:Downloading")
@pytest.mark.natural_earth
- at ImageTesting(['natural_earth'])
+ at ImageTesting(['natural_earth'], tolerance=0.97)
def test_natural_earth():
ax = plt.axes(projection=ccrs.PlateCarree())
ax.add_feature(cfeature.LAND)
=====================================
lib/cartopy/tests/mpl/test_mpl_integration.py
=====================================
@@ -19,7 +19,7 @@ from cartopy.tests.mpl import MPL_VERSION, ImageTesting
# This is due to a change in MPL 3.5 contour line paths changing
# ever so slightly.
-contour_tol = 2.24
+contour_tol = 2.25
@pytest.mark.natural_earth
@ImageTesting(['global_contour_wrap'], style='mpl20',
tolerance=contour_tol)
@@ -257,7 +257,7 @@ def test_cursor_values():
@pytest.mark.natural_earth
- at ImageTesting(['natural_earth_interface'], tolerance=0.21)
+ at ImageTesting(['natural_earth_interface'], tolerance=1.21)
def test_axes_natural_earth_interface():
rob = ccrs.Robinson()
=====================================
lib/cartopy/tests/mpl/test_pseudo_color.py
=====================================
@@ -84,3 +84,46 @@ def test_pcolormesh_arg_interpolation():
[2, 20],
[4, 20]]])
np.testing.assert_array_almost_equal(expected, coll._coordinates)
+
+
+def test_pcolormesh_datalim():
+ # Test that wrapping the coordinates still produces proper data limits
+ x = [359, 1, 3]
+ y = [-10, 10]
+
+ xs, ys = np.meshgrid(x, y)
+ # Z with the same shape as X/Y to force the interpolation
+ z = np.zeros(xs.shape)
+
+ ax = plt.subplot(2, 1, 1, projection=ccrs.PlateCarree())
+ coll = ax.pcolormesh(xs, ys, z, shading='auto',
+ transform=ccrs.PlateCarree())
+
+ coll_bbox = coll.get_datalim(ax.transData)
+ np.testing.assert_array_equal(coll_bbox, [[-2, -20], [4, 20]])
+
+ # Non-wrapped coordinates
+ x = [-80, 0, 80]
+ y = [-10, 10]
+
+ xs, ys = np.meshgrid(x, y)
+ ax = plt.subplot(2, 1, 1, projection=ccrs.PlateCarree())
+ coll = ax.pcolormesh(xs, ys, z, shading='auto',
+ transform=ccrs.PlateCarree())
+
+ coll_bbox = coll.get_datalim(ax.transData)
+ np.testing.assert_array_equal(coll_bbox, [[-120, -20], [120, 20]])
+
+ # A projection that doesn't support wrapping
+ x = [-10, 0, 10]
+ y = [-10, 10]
+
+ xs, ys = np.meshgrid(x, y)
+ ax = plt.subplot(2, 1, 1, projection=ccrs.Orthographic())
+ coll = ax.pcolormesh(xs, ys, z, shading='auto',
+ transform=ccrs.PlateCarree())
+
+ coll_bbox = coll.get_datalim(ax.transData)
+ expected = [[-1650783.327873, -2181451.330891],
+ [1650783.327873, 2181451.330891]]
+ np.testing.assert_array_almost_equal(coll_bbox, expected)
=====================================
lib/cartopy/tests/test_crs.py
=====================================
@@ -207,9 +207,9 @@ class TestCRS:
result = pc_rotated.project_geometry(multi_point, pc)
assert isinstance(result, sgeom.MultiPoint)
- assert len(result) == 2
- assert_arr_almost_eq(result[0].xy, [[-180.], [45.]])
- assert_arr_almost_eq(result[1].xy, [[0], [45.]])
+ assert len(result.geoms) == 2
+ assert_arr_almost_eq(result.geoms[0].xy, [[-180.], [45.]])
+ assert_arr_almost_eq(result.geoms[1].xy, [[0], [45.]])
def test_utm(self):
utm30n = ccrs.UTM(30)
=====================================
lib/cartopy/tests/test_line_string.py
=====================================
@@ -33,7 +33,7 @@ class TestLineString:
expected = 0
else:
expected = 1
- assert len(multi_line_string) == expected, \
+ assert len(multi_line_string.geoms) == expected, \
f'Unexpected line when working from {start} to {end}'
def test_simple_fragment_count(self):
@@ -51,7 +51,7 @@ class TestLineString:
multi_line_string = projection.project_geometry(line_string)
# from cartopy.tests.mpl import show
# show(projection, multi_line_string)
- assert len(multi_line_string) == pieces
+ assert len(multi_line_string.geoms) == pieces
def test_split(self):
projection = ccrs.Robinson(170.5)
@@ -59,7 +59,7 @@ class TestLineString:
multi_line_string = projection.project_geometry(line_string)
# from cartopy.tests.mpl import show
# show(projection, multi_line_string)
- assert len(multi_line_string) == 2
+ assert len(multi_line_string.geoms) == 2
def test_out_of_domain_efficiency(self):
# Check we're efficiently dealing with lines that project
@@ -103,80 +103,80 @@ class TestBisect:
projection = FakeProjection()
line_string = sgeom.LineString([(10, 0), (10, 0)])
multi_line_string = projection.project_geometry(line_string)
- assert len(multi_line_string) == 1
- assert len(multi_line_string[0].coords) == 2
+ assert len(multi_line_string.geoms) == 1
+ assert len(multi_line_string.geoms[0].coords) == 2
def test_interior_repeated_point(self):
projection = FakeProjection()
line_string = sgeom.LineString([(0, 0), (10, 0), (10, 0), (20, 0)])
multi_line_string = projection.project_geometry(line_string)
- assert len(multi_line_string) == 1
- assert len(multi_line_string[0].coords) == 4
+ assert len(multi_line_string.geoms) == 1
+ assert len(multi_line_string.geoms[0].coords) == 4
def test_circular_repeated_point(self):
projection = FakeProjection()
line_string = sgeom.LineString([(0, 0), (360, 0)])
multi_line_string = projection.project_geometry(line_string)
- assert len(multi_line_string) == 1
- assert len(multi_line_string[0].coords) == 2
+ assert len(multi_line_string.geoms) == 1
+ assert len(multi_line_string.geoms[0].coords) == 2
def test_short(self):
projection = FakeProjection()
line_string = sgeom.LineString([(0, 0), (1e-12, 0)])
multi_line_string = projection.project_geometry(line_string)
- assert len(multi_line_string) == 1
- assert len(multi_line_string[0].coords) == 2
+ assert len(multi_line_string.geoms) == 1
+ assert len(multi_line_string.geoms[0].coords) == 2
def test_empty(self):
projection = FakeProjection(right_offset=10)
line_string = sgeom.LineString([(175, 0), (175, 10)])
multi_line_string = projection.project_geometry(line_string)
- assert len(multi_line_string) == 0
+ assert len(multi_line_string.geoms) == 0
def test_simple_run_in(self):
projection = FakeProjection(right_offset=10)
line_string = sgeom.LineString([(160, 0), (175, 0)])
multi_line_string = projection.project_geometry(line_string)
- assert len(multi_line_string) == 1
- assert len(multi_line_string[0].coords) == 2
+ assert len(multi_line_string.geoms) == 1
+ assert len(multi_line_string.geoms[0].coords) == 2
def test_simple_wrap(self):
projection = FakeProjection()
line_string = sgeom.LineString([(160, 0), (-160, 0)])
multi_line_string = projection.project_geometry(line_string)
- assert len(multi_line_string) == 2
- assert len(multi_line_string[0].coords) == 2
- assert len(multi_line_string[1].coords) == 2
+ assert len(multi_line_string.geoms) == 2
+ assert len(multi_line_string.geoms[0].coords) == 2
+ assert len(multi_line_string.geoms[1].coords) == 2
def test_simple_run_out(self):
projection = FakeProjection(left_offset=10)
line_string = sgeom.LineString([(-175, 0), (-160, 0)])
multi_line_string = projection.project_geometry(line_string)
- assert len(multi_line_string) == 1
- assert len(multi_line_string[0].coords) == 2
+ assert len(multi_line_string.geoms) == 1
+ assert len(multi_line_string.geoms[0].coords) == 2
def test_point_on_boundary(self):
projection = FakeProjection()
line_string = sgeom.LineString([(180, 0), (-160, 0)])
multi_line_string = projection.project_geometry(line_string)
- assert len(multi_line_string) == 1
- assert len(multi_line_string[0].coords) == 2
+ assert len(multi_line_string.geoms) == 1
+ assert len(multi_line_string.geoms[0].coords) == 2
# Add a small offset to the left-hand boundary to make things
# even more pathological.
projection = FakeProjection(left_offset=5)
line_string = sgeom.LineString([(180, 0), (-160, 0)])
multi_line_string = projection.project_geometry(line_string)
- assert len(multi_line_string) == 1
- assert len(multi_line_string[0].coords) == 2
+ assert len(multi_line_string.geoms) == 1
+ assert len(multi_line_string.geoms[0].coords) == 2
def test_nan_start(self):
projection = ccrs.TransverseMercator(central_longitude=-90,
approx=False)
line_string = sgeom.LineString([(10, 50), (-10, 30)])
multi_line_string = projection.project_geometry(line_string)
- assert len(multi_line_string) == 1
- for line_string in multi_line_string:
+ assert len(multi_line_string.geoms) == 1
+ for line_string in multi_line_string.geoms:
for coord in line_string.coords:
assert not any(np.isnan(coord)), \
'Unexpected NaN in projected coords.'
@@ -188,8 +188,8 @@ class TestBisect:
multi_line_string = projection.project_geometry(line_string)
# from cartopy.tests.mpl import show
# show(projection, multi_line_string)
- assert len(multi_line_string) == 1
- for line_string in multi_line_string:
+ assert len(multi_line_string.geoms) == 1
+ for line_string in multi_line_string.geoms:
for coord in line_string.coords:
assert not any(np.isnan(coord)), \
'Unexpected NaN in projected coords.'
@@ -203,7 +203,7 @@ class TestMisc:
multi_line_string = projection.project_geometry(line_string)
# from cartopy.tests.mpl import show
# show(projection, multi_line_string)
- for line_string in multi_line_string:
+ for line_string in multi_line_string.geoms:
for coord in line_string.coords:
assert not any(np.isnan(coord)), \
'Unexpected NaN in projected coords.'
@@ -213,8 +213,8 @@ class TestMisc:
pole_latitude=37.5)
line_string = sgeom.LineString([(0, 0), (1e-14, 0)])
multi_line_string = projection.project_geometry(line_string)
- assert len(multi_line_string) == 1
- assert len(multi_line_string[0].coords) == 2
+ assert len(multi_line_string.geoms) == 1
+ assert len(multi_line_string.geoms[0].coords) == 2
def test_global_boundary(self):
linear_ring = sgeom.LineString([(-180, -180), (-180, 180),
@@ -222,11 +222,11 @@ class TestMisc:
pc = ccrs.PlateCarree()
merc = ccrs.Mercator()
multi_line_string = pc.project_geometry(linear_ring, merc)
- assert len(multi_line_string) > 0
+ assert len(multi_line_string.geoms) > 0
# check the identity transform
multi_line_string = merc.project_geometry(linear_ring, merc)
- assert len(multi_line_string) > 0
+ assert len(multi_line_string.geoms) > 0
class TestSymmetry:
@@ -244,9 +244,9 @@ class TestSymmetry:
# Make sure that they generated the same points.
# (Although obviously they will be in the opposite order!)
- assert len(multi_line_string) == 1
- assert len(multi_line_string2) == 1
- coords = multi_line_string[0].coords
- coords2 = multi_line_string2[0].coords
+ assert len(multi_line_string.geoms) == 1
+ assert len(multi_line_string2.geoms) == 1
+ coords = multi_line_string.geoms[0].coords
+ coords2 = multi_line_string2.geoms[0].coords
np.testing.assert_allclose(coords, coords2[::-1],
err_msg='Asymmetric curve generation')
=====================================
lib/cartopy/tests/test_linear_ring.py
=====================================
@@ -20,7 +20,7 @@ class TestBoundary:
rings, multi_line_string = projection.project_geometry(linear_ring)
# The original ring should have been split into multiple pieces.
- assert len(multi_line_string) > 1
+ assert len(multi_line_string.geoms) > 1
assert not rings
def assert_intersection_with_boundary(segment_coords):
@@ -37,7 +37,7 @@ class TestBoundary:
# segment that crosses the boundary when extended to double length.
# (This is important when considering polygon rings which need to be
# attached to the boundary.)
- for line_string in multi_line_string:
+ for line_string in multi_line_string.geoms:
coords = list(line_string.coords)
assert len(coords) >= 2
assert_intersection_with_boundary(coords[1::-1])
@@ -68,7 +68,7 @@ class TestBoundary:
assert rings
assert not mlinestr
else:
- assert len(mlinestr) == expected_n_lines
+ assert len(mlinestr.geoms) == expected_n_lines
if expected_n_lines == 0:
assert mlinestr.is_empty
@@ -86,7 +86,7 @@ class TestMisc:
rings, multi_line_string = projection.project_geometry(linear_ring)
# There should be one, and only one, returned ring.
assert isinstance(multi_line_string, sgeom.MultiLineString)
- assert len(multi_line_string) == 0
+ assert len(multi_line_string.geoms) == 0
assert len(rings) == 1
# from cartopy.tests.mpl import show
@@ -135,13 +135,13 @@ class TestMisc:
linear_ring = sgeom.LinearRing(coords)
rings, mlinestr = target_proj.project_geometry(linear_ring, src_proj)
- assert len(mlinestr) == 1
+ assert len(mlinestr.geoms) == 1
assert len(rings) == 0
# Check the stitch works in either direction.
linear_ring = sgeom.LinearRing(coords[::-1])
rings, mlinestr = target_proj.project_geometry(linear_ring, src_proj)
- assert len(mlinestr) == 1
+ assert len(mlinestr.geoms) == 1
assert len(rings) == 0
def test_at_boundary(self):
@@ -170,7 +170,7 @@ class TestMisc:
rings, mlinestr = tcrs._project_linear_ring(tring, scrs)
# Number of linearstrings
- assert len(mlinestr) == 4
+ assert len(mlinestr.geoms) == 4
assert not rings
# Test area of smallest Polygon that contains all the points in the
=====================================
lib/cartopy/tests/test_polygon.py
=====================================
@@ -21,7 +21,7 @@ class TestBoundary:
polygon = sgeom.Polygon([(-10, 30), (10, 60), (10, 50)])
projection = ccrs.Robinson(170.5)
multi_polygon = projection.project_geometry(polygon)
- for polygon in multi_polygon:
+ for polygon in multi_polygon.geoms:
assert polygon.is_valid
def test_polygon_boundary_attachment(self):
@@ -54,7 +54,7 @@ class TestBoundary:
for coords, expected_polys in polys:
polygon = sgeom.Polygon(coords)
multi_polygon = projection.project_geometry(polygon)
- assert len(multi_polygon) == expected_polys
+ assert len(multi_polygon.geoms) == expected_polys
class TestMisc:
@@ -72,8 +72,8 @@ class TestMisc:
(-179.9173693847652942, -16.5017831356493616),
])
multi_polygon = projection.project_geometry(polygon)
- assert len(multi_polygon) == 1
- assert len(multi_polygon[0].exterior.coords) == 4
+ assert len(multi_polygon.geoms) == 1
+ assert len(multi_polygon.geoms[0].exterior.coords) == 4
def test_former_infloop_case(self):
# test a polygon which used to get stuck in an infinite loop
@@ -174,8 +174,8 @@ class TestMisc:
(200000, -1000)])
multi_polygon = projection.project_geometry(polygon,
ccrs.OSGB(approx=True))
- assert len(multi_polygon) == 1
- assert len(multi_polygon[0].exterior.coords) == 4
+ assert len(multi_polygon.geoms) == 1
+ assert len(multi_polygon.geoms[0].exterior.coords) == 4
def test_self_intersecting_1(self):
# Geometry comes from a matplotlib contourf (see #537)
@@ -298,14 +298,14 @@ class TestQuality:
def test_split(self):
# Start simple ... there should be two projected polygons.
- assert len(self.multi_polygon) == 2
+ assert len(self.multi_polygon.geoms) == 2
def test_repeats(self):
# Make sure we don't have repeated points at the boundary, because
# they mess up the linear extrapolation to the boundary.
# Make sure there aren't any repeated points.
- xy = np.array(self.multi_polygon[0].exterior.coords)
+ xy = np.array(self.multi_polygon.geoms[0].exterior.coords)
same = (xy[1:] == xy[:-1]).all(axis=1)
assert not any(same), 'Repeated points in projected geometry.'
@@ -315,7 +315,7 @@ class TestQuality:
# from the boundary.
# Identify all the contiguous sets of non-boundary points.
- xy = np.array(self.multi_polygon[0].exterior.coords)
+ xy = np.array(self.multi_polygon.geoms[0].exterior.coords)
boundary = np.logical_or(xy[:, 1] == 90, xy[:, 1] == -90)
regions = (boundary[1:] != boundary[:-1]).cumsum()
regions = np.insert(regions, 0, 0)
@@ -347,9 +347,9 @@ class TestWrap(PolygonTests):
poly = sgeom.box(0, 0, 10, 10)
multi_polygon = proj.project_geometry(poly, proj)
# Check the structure
- assert len(multi_polygon) == 1
+ assert len(multi_polygon.geoms) == 1
# Check the rough shape
- polygon = multi_polygon[0]
+ polygon = multi_polygon.geoms[0]
self._assert_bounds(polygon.bounds, 0, 0, 10, 10)
def test_plate_carree_partial_wrap(self):
@@ -357,9 +357,9 @@ class TestWrap(PolygonTests):
poly = sgeom.box(170, 0, 190, 10)
multi_polygon = proj.project_geometry(poly, proj)
# Check the structure
- assert len(multi_polygon) == 2
+ assert len(multi_polygon.geoms) == 2
# Check the rough shape
- poly1, poly2 = multi_polygon
+ poly1, poly2 = multi_polygon.geoms
# The order of these polygons is not guaranteed, so figure out
# which is appropriate
if 170.0 not in poly1.bounds:
@@ -372,9 +372,9 @@ class TestWrap(PolygonTests):
poly = sgeom.box(200, 0, 220, 10)
multi_polygon = proj.project_geometry(poly, proj)
# Check the structure
- assert len(multi_polygon) == 1
+ assert len(multi_polygon.geoms) == 1
# Check the rough shape
- polygon = multi_polygon[0]
+ polygon = multi_polygon.geoms[0]
self._assert_bounds(polygon.bounds, -160, 0, -140, 10)
@@ -390,10 +390,10 @@ class TestHoles(PolygonTests):
[ring(-20, -20, 20, 20, False)])
multi_polygon = proj.project_geometry(poly)
# Check the structure
- assert len(multi_polygon) == 1
- assert len(multi_polygon[0].interiors) == 1
+ assert len(multi_polygon.geoms) == 1
+ assert len(multi_polygon.geoms[0].interiors) == 1
# Check the rough shape
- polygon = multi_polygon[0]
+ polygon = multi_polygon.geoms[0]
self._assert_bounds(polygon.bounds, -40, -47, 40, 47)
self._assert_bounds(polygon.interiors[0].bounds, -20, -21, 20, 21)
@@ -403,9 +403,9 @@ class TestHoles(PolygonTests):
[ring(-20, -20, 20, 20, False)])
multi_polygon = proj.project_geometry(poly)
# Check the structure
- assert len(multi_polygon) == 2
+ assert len(multi_polygon.geoms) == 2
- poly1, poly2 = multi_polygon
+ poly1, poly2 = multi_polygon.geoms
# The order of these polygons is not guaranteed, so figure out
# which is appropriate
if not len(poly1.interiors) == 1:
@@ -424,13 +424,13 @@ class TestHoles(PolygonTests):
[ring(-20, -20, 20, 20, False)])
multi_polygon = proj.project_geometry(poly)
# Check the structure
- assert len(multi_polygon) == 2
- assert len(multi_polygon[0].interiors) == 0
- assert len(multi_polygon[1].interiors) == 0
+ assert len(multi_polygon.geoms) == 2
+ assert len(multi_polygon.geoms[0].interiors) == 0
+ assert len(multi_polygon.geoms[1].interiors) == 0
# Check the rough shape
- polygon = multi_polygon[0]
+ polygon = multi_polygon.geoms[0]
self._assert_bounds(polygon.bounds, 140, -47, 180, 47)
- polygon = multi_polygon[1]
+ polygon = multi_polygon.geoms[1]
self._assert_bounds(polygon.bounds, -180, -47, -140, 47)
def test_inverted_poly_simple_hole(self):
@@ -439,10 +439,10 @@ class TestHoles(PolygonTests):
[[(0, -30), (90, -30), (180, -30), (270, -30)]])
multi_polygon = proj.project_geometry(poly)
# Check the structure
- assert len(multi_polygon) == 1
- assert len(multi_polygon[0].interiors) == 1
+ assert len(multi_polygon.geoms) == 1
+ assert len(multi_polygon.geoms[0].interiors) == 1
# Check the rough shape
- polygon = multi_polygon[0]
+ polygon = multi_polygon.geoms[0]
self._assert_bounds(polygon.bounds, -2.4e7, -2.4e7, 2.4e7, 2.4e7, 1e6)
self._assert_bounds(polygon.interiors[0].bounds,
- 1.2e7, -1.2e7, 1.2e7, 1.2e7, 1e6)
@@ -454,10 +454,10 @@ class TestHoles(PolygonTests):
(45, -60), (135, -60)]])
multi_polygon = proj.project_geometry(poly)
# Check the structure
- assert len(multi_polygon) == 1
- assert len(multi_polygon[0].interiors) == 1
+ assert len(multi_polygon.geoms) == 1
+ assert len(multi_polygon.geoms[0].interiors) == 1
# Check the rough shape
- polygon = multi_polygon[0]
+ polygon = multi_polygon.geoms[0]
self._assert_bounds(polygon.bounds, -5.0e7, -5.0e7, 5.0e7, 5.0e7, 1e6)
self._assert_bounds(polygon.interiors[0].bounds,
- 1.2e7, -1.2e7, 1.2e7, 1.2e7, 1e6)
@@ -470,10 +470,10 @@ class TestHoles(PolygonTests):
(45, -75), (135, -75)]])
multi_polygon = proj.project_geometry(poly)
# Check the structure
- assert len(multi_polygon) == 1
- assert len(multi_polygon[0].interiors) == 1
+ assert len(multi_polygon.geoms) == 1
+ assert len(multi_polygon.geoms[0].interiors) == 1
# Check the rough shape
- polygon = multi_polygon[0]
+ polygon = multi_polygon.geoms[0]
self._assert_bounds(polygon.bounds, -5.0e7, -5.0e7, 5.0e7, 5.0e7, 1e6)
self._assert_bounds(polygon.interiors[0].bounds,
- 1.2e7, -1.2e7, 1.2e7, 1.2e7, 1e6)
@@ -488,4 +488,4 @@ class TestHoles(PolygonTests):
target = ccrs.PlateCarree()
source = ccrs.Geodetic()
- assert len(list(target.project_geometry(poly, source))) == 1
+ assert len(list(target.project_geometry(poly, source).geoms)) == 1
View it on GitLab: https://salsa.debian.org/debian-gis-team/python-cartopy/-/commit/630f543e5c05e9e63ab46b9aee1a5132eec17c62
--
View it on GitLab: https://salsa.debian.org/debian-gis-team/python-cartopy/-/commit/630f543e5c05e9e63ab46b9aee1a5132eec17c62
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20220113/a5b620c3/attachment-0001.htm>
More information about the Pkg-grass-devel
mailing list