Skip to content

Commit b9ee523

Browse files
author
pavetsu14
committed
Modifications to coding style
1 parent 523a680 commit b9ee523

File tree

5 files changed

+42
-22
lines changed

5 files changed

+42
-22
lines changed

eis_toolkit/checks/crs.py

100644100755
+7-2
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
1-
def matching_crs(objects: list):
1+
def matching_crs(
2+
objects: list,
3+
) -> bool:
24
"""Check if every object in a list has a crs, and that they match.
35
46
Args:
57
objects (list): A list of objects to check.
68
79
Returns:
8-
Bool: True if everything matches, false if not.
10+
bool: True if everything matches, false if not.
911
"""
1012

1113
epsg_list = []
14+
1215
for object in objects:
1316
if not object.crs:
1417
return False
1518
epsg = object.crs.to_epsg()
1619
epsg_list.append(epsg)
20+
1721
if len(set(epsg_list)) != 1:
1822
return False
23+
1924
return True

eis_toolkit/checks/geometry.py

100644100755
+7-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
from typing import Iterable
22

33

4-
def correct_geometry_types(geometries: Iterable, allowed: list):
4+
def correct_geometry_types(
5+
geometries: Iterable,
6+
allowed: list,
7+
) -> bool:
58
"""Check all geometries in an iterable against a list of allowed types.
69
710
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.
1012
allowed_types: a list of allowed geometry types.
1113
1214
Returns:
13-
Bool: True if all geometries match, False if not
15+
bool: True if all geometries match, False if not.
1416
"""
1517

1618
for geometry in geometries:
1719
if geometry.geom_type not in allowed:
1820
return False
21+
1922
return True

eis_toolkit/dummy_tests/dummy.py

100644100755
+14-9
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
1-
def test_function(a: int, b: int) -> int:
1+
def test_function(
2+
a: int,
3+
b: int,
4+
) -> int:
25
"""Test whether simple function of summing two values together works.
36
47
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.
710
811
Returns:
9-
int: sum of the input values
12+
int: sum of the input values.
1013
"""
11-
return (a + b)
14+
return a + b
1215

1316

14-
def test_function2(a: int) -> int:
17+
def test_function2(
18+
a: int,
19+
) -> int:
1520
"""Test whether simple function of subtracting 5 from input value works.
1621
1722
Args:
18-
a (int): input integer
23+
a (int): input integer.
1924
2025
Returns:
21-
int: result after the subtraction operation
26+
int: result after the subtraction operation.
2227
"""
23-
return (a - 5)
28+
return a - 5

eis_toolkit/dummy_tests/dummy_sklearn.py

100644100755
+10-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
from sklearn import preprocessing
1+
from typing import Any
2+
23
import numpy as np
4+
from sklearn import preprocessing
35

46

5-
def sk_mean(a: np.ndarray) -> np.ndarray:
7+
def sk_mean(
8+
a: np.ndarray,
9+
) -> Any:
610
"""Test whether it works to call one of scikit-learn's functions.
711
812
Args:
9-
a (np.ndarray): input array
13+
a (np.ndarray): input array.
1014
1115
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.
1417
"""
1518
scaler = preprocessing.StandardScaler().fit(a)
1619
ka = scaler.mean_
17-
return (ka)
20+
21+
return ka

tests/clip_test.py

100644100755
+4-1
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ def test_clip():
2222
"""Tests clip functionality with geotiff raster and shapefile polygon."""
2323

2424
polygon = geopandas.read_file(polygon_path)
25+
2526
with rasterio.open(raster_path) as raster:
2627
out_image, out_meta = clip(
2728
raster=raster,
28-
polygon=polygon
29+
polygon=polygon,
2930
)
31+
3032
with rasterio.open(output_raster_path, "w", **out_meta) as dest:
3133
dest.write(out_image)
34+
3235
with rasterio.open(output_raster_path) as result:
3336
assert np.amax(result.read()) != np.amin(result.read())
3437
assert result.count == 1

0 commit comments

Comments
 (0)