Skip to content

Commit f27e176

Browse files
committed
Catching IndexError in project_extents
1 parent 41a5abb commit f27e176

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

geoviews/tests/test_util.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import cartopy.crs as ccrs
2+
import pytest
3+
4+
from geoviews.util import project_extents
5+
6+
7+
8+
def test_outside_extents():
9+
# extents outside bounds of map 32635, see https://epsg.io/32635
10+
extents = (-2036817.4174174175, 577054.6546546547, -1801982.5825825825, 867745.3453453453)
11+
dest_proj = ccrs.Mercator()
12+
src_proj = ccrs.epsg(32635)
13+
14+
msg = (
15+
"Could not project data from .+? projection to .+? projection\. "
16+
"Ensure the coordinate reference system \(crs\) matches your data and the kdims\."
17+
)
18+
with pytest.raises(ValueError, match=msg):
19+
project_extents(extents, src_proj, dest_proj)

geoviews/util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def project_extents(extents, src_proj, dest_proj, tol=1e-6):
9999
geom_in_src_proj = geom_clipped_to_dest_proj
100100
try:
101101
geom_in_crs = dest_proj.project_geometry(geom_in_src_proj, src_proj)
102-
except ValueError:
102+
except (ValueError, IndexError):
103103
src_name =type(src_proj).__name__
104104
dest_name =type(dest_proj).__name__
105105
raise ValueError('Could not project data from %s projection '

0 commit comments

Comments
 (0)