File tree 5 files changed +42
-22
lines changed
5 files changed +42
-22
lines changed Original file line number Diff line number Diff line change 1
- def matching_crs (objects : list ):
1
+ def matching_crs (
2
+ objects : list ,
3
+ ) -> bool :
2
4
"""Check if every object in a list has a crs, and that they match.
3
5
4
6
Args:
5
7
objects (list): A list of objects to check.
6
8
7
9
Returns:
8
- Bool : True if everything matches, false if not.
10
+ bool : True if everything matches, false if not.
9
11
"""
10
12
11
13
epsg_list = []
14
+
12
15
for object in objects :
13
16
if not object .crs :
14
17
return False
15
18
epsg = object .crs .to_epsg ()
16
19
epsg_list .append (epsg )
20
+
17
21
if len (set (epsg_list )) != 1 :
18
22
return False
23
+
19
24
return True
Original file line number Diff line number Diff line change 1
1
from typing import Iterable
2
2
3
3
4
- def correct_geometry_types (geometries : Iterable , allowed : list ):
4
+ def correct_geometry_types (
5
+ geometries : Iterable ,
6
+ allowed : list ,
7
+ ) -> bool :
5
8
"""Check all geometries in an iterable against a list of allowed types.
6
9
7
10
Args:
8
- geometries (Iterable): for example a list of shapely.geometry objects
9
- or a geopandas.GeoSeries.
11
+ geometries (Iterable): for example a list of shapely.geometry objects or a geopandas.GeoSeries.
10
12
allowed_types: a list of allowed geometry types.
11
13
12
14
Returns:
13
- Bool : True if all geometries match, False if not
15
+ bool : True if all geometries match, False if not.
14
16
"""
15
17
16
18
for geometry in geometries :
17
19
if geometry .geom_type not in allowed :
18
20
return False
21
+
19
22
return True
Original file line number Diff line number Diff line change 1
- def test_function (a : int , b : int ) -> int :
1
+ def test_function (
2
+ a : int ,
3
+ b : int ,
4
+ ) -> int :
2
5
"""Test whether simple function of summing two values together works.
3
6
4
7
Args:
5
- a (int): first input integer
6
- b (int): second input integer
8
+ a (int): first input integer.
9
+ b (int): second input integer.
7
10
8
11
Returns:
9
- int: sum of the input values
12
+ int: sum of the input values.
10
13
"""
11
- return ( a + b )
14
+ return a + b
12
15
13
16
14
- def test_function2 (a : int ) -> int :
17
+ def test_function2 (
18
+ a : int ,
19
+ ) -> int :
15
20
"""Test whether simple function of subtracting 5 from input value works.
16
21
17
22
Args:
18
- a (int): input integer
23
+ a (int): input integer.
19
24
20
25
Returns:
21
- int: result after the subtraction operation
26
+ int: result after the subtraction operation.
22
27
"""
23
- return ( a - 5 )
28
+ return a - 5
Original file line number Diff line number Diff line change 1
- from sklearn import preprocessing
1
+ from typing import Any
2
+
2
3
import numpy as np
4
+ from sklearn import preprocessing
3
5
4
6
5
- def sk_mean (a : np .ndarray ) -> np .ndarray :
7
+ def sk_mean (
8
+ a : np .ndarray ,
9
+ ) -> Any :
6
10
"""Test whether it works to call one of scikit-learn's functions.
7
11
8
12
Args:
9
- a (np.ndarray): input array
13
+ a (np.ndarray): input array.
10
14
11
15
Returns:
12
- np.ndarray: result vector containing the means of every column in the
13
- input array
16
+ np.ndarray: result vector containing the means of every column in the input array.
14
17
"""
15
18
scaler = preprocessing .StandardScaler ().fit (a )
16
19
ka = scaler .mean_
17
- return (ka )
20
+
21
+ return ka
Original file line number Diff line number Diff line change @@ -22,13 +22,16 @@ def test_clip():
22
22
"""Tests clip functionality with geotiff raster and shapefile polygon."""
23
23
24
24
polygon = geopandas .read_file (polygon_path )
25
+
25
26
with rasterio .open (raster_path ) as raster :
26
27
out_image , out_meta = clip (
27
28
raster = raster ,
28
- polygon = polygon
29
+ polygon = polygon ,
29
30
)
31
+
30
32
with rasterio .open (output_raster_path , "w" , ** out_meta ) as dest :
31
33
dest .write (out_image )
34
+
32
35
with rasterio .open (output_raster_path ) as result :
33
36
assert np .amax (result .read ()) != np .amin (result .read ())
34
37
assert result .count == 1
You can’t perform that action at this time.
0 commit comments