Skip to content

Commit

Permalink
Raise NotImplementedError when future areas are created as non-2D shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
djhoese committed Aug 14, 2023
1 parent 379b85b commit 3cb9861
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pyresample/future/geometry/area.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ def __init__(
# FUTURE: Add __slots__
# FUTURE: Convert this to new class that uses a legacy area internally
# Use this to more easily deprecate usage of old properties
if len(shape) != 2:
raise NotImplementedError("Only 2-dimensional areas are supported at this time.")

attrs = attrs or {}
area_id = attrs.get("name", "")
super().__init__(
Expand Down
7 changes: 7 additions & 0 deletions pyresample/test/test_geometry/test_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -2020,3 +2020,10 @@ def test_future_to_legacy_conversion():
assert legacy_area.area_extent == area_def.area_extent
assert legacy_area.crs == area_def.crs
assert legacy_area.area_id == area_def.attrs["name"]


@pytest.mark.parametrize("shape", [(100,), (100, 100, 100)])
def test_non2d_shape_error(shape):
"""Test that non-2D shapes fail."""
with pytest.raises(NotImplementedError):
AreaDefinition("EPSG:4326", shape, (-1000.0, -1000.0, 1000.0, 1000.0))

0 comments on commit 3cb9861

Please sign in to comment.