diff --git a/src/asf_tools/vector.py b/src/asf_tools/vector.py index 831170c..409fb92 100644 --- a/src/asf_tools/vector.py +++ b/src/asf_tools/vector.py @@ -13,14 +13,14 @@ def get_features(vector_path: str | Path) -> list[ogr.Feature]: return [feature for feature in layer] -def get_property_values_for_intersecting_features(geometry: ogr.Geometry, features: Iterator) -> bool: +def get_property_values_for_intersecting_features(geometry: ogr.Geometry, features: list[ogr.Feature]) -> bool: for feature in features: if feature.GetGeometryRef().Intersects(geometry): return True return False -def intersecting_feature_properties(geometry: ogr.Geometry, features: Iterator, feature_property: str) -> list[str]: +def intersecting_feature_properties(geometry: ogr.Geometry, features: list[ogr.Feature], feature_property: str) -> list[str]: property_values = [] for feature in features: if feature.GetGeometryRef().Intersects(geometry): diff --git a/tests/hydrosar/test_flood_map.py b/tests/hydrosar/test_flood_map.py index 72b0198..813ee8c 100644 --- a/tests/hydrosar/test_flood_map.py +++ b/tests/hydrosar/test_flood_map.py @@ -27,7 +27,7 @@ def test_get_waterbody(): def test_logstat(): arr = [10, 100, 1000, 10000, 100000] - logstd = flood_map.logstat(arr) + logstd = flood_map.logstat(arr) # type: ignore[arg-type] assert np.isclose(logstd, 25.95455351947008) diff --git a/tests/test_raster.py b/tests/test_raster.py index 6cdef25..27ece39 100644 --- a/tests/test_raster.py +++ b/tests/test_raster.py @@ -32,9 +32,9 @@ def test_convert_scale(): a = np.array([-10, -5, 0, 5, 10]) with pytest.raises(ValueError): - _ = raster.convert_scale(a, 'power', 'foo') + _ = raster.convert_scale(a, 'power', 'foo') # type: ignore[arg-type] with pytest.raises(ValueError): - _ = raster.convert_scale(a, 'bar', 'amplitude') + _ = raster.convert_scale(a, 'bar', 'amplitude') # type: ignore[arg-type] with pytest.warns(UserWarning): assert np.allclose( @@ -50,6 +50,8 @@ def test_convert_scale(): def test_convert_scale_masked_arrays(): masked_array: np.ma.MaskedArray = np.ma.MaskedArray([-1, 0, 1, 4, 9], mask=[False, False, False, False, False]) c = raster.convert_scale(masked_array, 'power', 'db') + + assert isinstance(c, np.ma.MaskedArray) assert np.allclose(c.mask, [True, True, False, False, False]) assert np.allclose( c, @@ -60,6 +62,8 @@ def test_convert_scale_masked_arrays(): ) a = raster.convert_scale(c, 'db', 'power') + + assert isinstance(a, np.ma.MaskedArray) assert np.allclose(a.mask, [True, True, False, False, False]) assert np.allclose(a, np.ma.MaskedArray([-1, 0, 1, 4, 9], mask=[True, True, False, False, False])) diff --git a/tests/test_tile.py b/tests/test_tile.py index 9a8b80a..1cbf02c 100644 --- a/tests/test_tile.py +++ b/tests/test_tile.py @@ -35,7 +35,7 @@ def test_tile_masked_array(): a = np.array([[0, 0, 1, 1], [0, 0, 1, 1], [2, 2, 3, 3], [2, 2, 3, 3]]) with pytest.raises(AttributeError): - _ = tile.tile_array(a, tile_shape=(2, 2)).mask + _ = tile.tile_array(a, tile_shape=(2, 2)).mask # type: ignore[attr-defined] m = np.array( [ @@ -86,6 +86,7 @@ def test_untile_array(): ] ) + assert len(a.shape) == 2 assert np.all(a == tile.untile_array(tile.tile_array(a, tile_shape=(2, 2)), array_shape=a.shape)) assert np.all(a == tile.untile_array(tile.tile_array(a, tile_shape=(4, 4), pad_value=9), array_shape=a.shape)) assert np.all(a == tile.untile_array(tile.tile_array(a, tile_shape=(2, 4), pad_value=9), array_shape=a.shape)) @@ -107,8 +108,9 @@ def test_untile_array(): def test_untile_masked_array(): a = np.array([[0, 0, 1, 1], [0, 0, 1, 1], [2, 2, 3, 3], [2, 2, 3, 3]]) + assert len(a.shape) == 2 with pytest.raises(AttributeError): - _ = tile.untile_array(tile.tile_array(a, tile_shape=(2, 2)), array_shape=a.shape).mask + _ = tile.untile_array(tile.tile_array(a, tile_shape=(2, 2)), array_shape=a.shape).mask # type: ignore[attr-defined] m = np.array( [ @@ -122,9 +124,12 @@ def test_untile_masked_array(): ma: np.ma.MaskedArray = np.ma.MaskedArray(a, mask=m) untiled = tile.untile_array(tile.tile_array(ma.copy(), tile_shape=(2, 2)), array_shape=a.shape) + assert isinstance(untiled, np.ma.MaskedArray) assert np.all(ma == untiled) assert np.all(ma.mask == untiled.mask) untiled = tile.untile_array(tile.tile_array(ma.copy(), tile_shape=(3, 3), pad_value=4), array_shape=a.shape) + + assert isinstance(untiled, np.ma.MaskedArray) assert np.all(ma == untiled) assert np.all(ma.mask == untiled.mask)