Skip to content

Commit ab9a7d8

Browse files
committed
enforce pep8
1 parent 94ff14e commit ab9a7d8

22 files changed

Lines changed: 283 additions & 274 deletions

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ performs a wind forecast analysis for the specified time and location (usually s
2626
and returns a tuple with true wind direction (`twd`) expressed in degrees and true wind speed (`tws`) expressed in meters per second or `None` if running out of temporal/geographic grib scope.
2727

2828
```python
29-
def getWindAt(t, lat, lon)
29+
def get_wind_at(t, lat, lon)
3030
# wind forecast analysys implementation
3131
# speed is in m/s, direction in degrees
3232
...
@@ -93,11 +93,11 @@ routing_obj = Routing(
9393
LinearBestIsoRouter, # specify a router type
9494
polar_obj, # the polar object for a specific sail boat
9595
track, # the list of track points (lat,lon)
96-
getWindAt, # the function that returns (twd,tws) for a specified (datetime, lat, lon)
96+
get_wind_at, # the function that returns (twd,tws) for a specified (datetime, lat, lon)
9797
start, # the start datetime
9898
start_position = (37.8, 4.8) # the start location (lat lon, optional, the first track point if undefined)
99-
pointValidity = point_validity # the point validity function (optional)
100-
lineValidity = line_validity # the line validity function (optional)
99+
point_validity = point_validity # the point validity function (optional)
100+
line_validity = line_validity # the line validity function (optional)
101101
)
102102
```
103103

@@ -126,10 +126,10 @@ res.path # the list of route waypoints
126126
### Export path as geojson
127127
The path could be exported as a geojson object for cartographic representation
128128
```python
129-
from weatherrouting.utils import pathAsGeojson
129+
from weatherrouting.utils import path_as_geojson
130130
import json
131131

132-
json.dumps(pathAsGeojson(res.path))
132+
json.dumps(path_as_geojson(res.path))
133133
```
134134

135135

docs/source/generated/weatherrouting.routers.router.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ weatherrouting.routers.router
3030

3131
.. autosummary::
3232

33-
RoutingNoWindException
33+
RoutingNoWindError
3434

3535

3636

docs/source/generated/weatherrouting.routing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ weatherrouting.routing
1313

1414
.. autosummary::
1515

16-
listRoutingAlgorithms
16+
list_routing_algorithms
1717

1818

1919

docs/source/generated/weatherrouting.utils.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ weatherrouting.utils
1616
cfbinomiale
1717
km2nm
1818
lossodromic
19-
maxReachDistance
19+
max_reach_distance
2020
nm2km
2121
ortodromic
2222
ortodromic2
23-
pathAsGeojson
24-
pointDistance
23+
path_as_geojson
24+
point_distance
2525
reduce180
2626
reduce360
27-
routagePointDistance
27+
routage_point_distance
2828

2929

3030

scripts/replace_latlon_tests.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,25 @@
3636
# measurement.bearing(start,end)
3737

3838

39-
def routagePointDistance(latA: float, lonA: float, distance: float, hdg: float):
40-
"""Returns the point from (latA, lonA) to the given (distance, hdg)"""
39+
def routage_point_distance(lat_a: float, lon_a: float, distance: float, hdg: float):
40+
"""Returns the point from (lat_a, lon_a) to the given (distance, hdg)"""
4141
d = distance
4242

43-
p = latlon.LatLon(latlon.Latitude(latA), latlon.Longitude(lonA))
43+
p = latlon.LatLon(latlon.Latitude(lat_a), latlon.Longitude(lon_a))
4444
of = p.offset(math.degrees(hdg), d).to_string("D")
4545
return (float(of[0]), float(of[1]))
4646

4747

48-
def ortodromic(latA: float, lonA: float, latB: float, lonB: float):
49-
p1 = latlon.LatLon(latlon.Latitude(latA), latlon.Longitude(lonA))
50-
p2 = latlon.LatLon(latlon.Latitude(latB), latlon.Longitude(lonB))
48+
def ortodromic(lat_a: float, lon_a: float, lat_b: float, lon_b: float):
49+
p1 = latlon.LatLon(latlon.Latitude(lat_a), latlon.Longitude(lon_a))
50+
p2 = latlon.LatLon(latlon.Latitude(lat_b), latlon.Longitude(lon_b))
5151

5252
return (p1.distance(p2), math.radians(p1.heading_initial(p2)))
5353

5454

55-
def lossodromic(latA: float, lonA: float, latB: float, lonB: float):
56-
p1 = latlon.LatLon(latlon.Latitude(latA), latlon.Longitude(lonA))
57-
p2 = latlon.LatLon(latlon.Latitude(latB), latlon.Longitude(lonB))
55+
def lossodromic(lat_a: float, lon_a: float, lat_b: float, lon_b: float):
56+
p1 = latlon.LatLon(latlon.Latitude(lat_a), latlon.Longitude(lon_a))
57+
p2 = latlon.LatLon(latlon.Latitude(lat_b), latlon.Longitude(lon_b))
5858

5959
return (p1.distance(p2, ellipse="sphere"), math.radians(p1.heading_initial(p2)))
6060

@@ -81,5 +81,5 @@ def lossodromic(latA: float, lonA: float, latB: float, lonB: float):
8181
g = geod.Direct(-32.06, 115.74, 225, 20000e3)
8282
print(g)
8383

84-
g = routagePointDistance(-32.06, 115.74, 20000, math.radians(225))
84+
g = routage_point_distance(-32.06, 115.74, 20000, math.radians(225))
8585
print(g)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
setup(
1818
name="weatherrouting",
19-
version="0.1.13",
19+
version="0.2",
2020
description="Weather routing library for sailing",
2121
author="Davide Gessa",
2222
setup_requires="setuptools",

tests/linearbestisorouter_test.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from weatherrouting.routers.linearbestisorouter import LinearBestIsoRouter
2525

2626
from .mock_grib import MockGrib
27-
from .mock_point_validity import MockPointValidity
27+
from .mock_point_validity import MockpointValidity
2828

2929
polar_bavaria38 = weatherrouting.Polar(
3030
os.path.join(os.path.dirname(__file__), "data/bavaria38.pol")
@@ -38,7 +38,7 @@ def heading(y, x):
3838
return (90 - a + 360) % 360
3939

4040

41-
# class TestRouting_straigth_upwind(unittest.TestCase):
41+
# class TestRoutingStraigthUpwind(unittest.TestCase):
4242
# def test_step(self):
4343
# base_step = [
4444
# [1, 0],
@@ -57,14 +57,14 @@ def heading(y, x):
5757
# base_end = [base_start[0] + s[0], base_start[1] + s[1]]
5858
# head = heading(*s)
5959
# print("TEST UPWIND TWD", head, "step", s)
60-
# pvmodel = MockPointValidity([base_start, base_end])
60+
# pvmodel = MockpointValidity([base_start, base_end])
6161
# routing_obj = weatherrouting.Routing(
6262
# LinearBestIsoRouter,
6363
# polar_bavaria38,
6464
# [base_start, base_end],
6565
# MockGrib(10, head, 0),
6666
# datetime.datetime.fromisoformat("2021-04-02T12:00:00"),
67-
# lineValidity=pvmodel.line_validity,
67+
# line_validity=pvmodel.line_validity,
6868
# )
6969
# res = None
7070
# i = 0
@@ -75,28 +75,28 @@ def heading(y, x):
7575

7676
# path_to_end = res.path
7777
# if not base_gjs:
78-
# base_gjs = weatherrouting.utils.pathAsGeojson(path_to_end)
78+
# base_gjs = weatherrouting.utils.path_as_geojson(path_to_end)
7979
# else:
80-
# base_gjs["features"] += weatherrouting.utils.pathAsGeojson(path_to_end)[
80+
# base_gjs["features"] += weatherrouting.utils.path_as_geojson(path_to_end)[
8181
# "features"
8282
# ]
8383
# gjs = json.dumps(base_gjs)
8484

8585
# print(gjs)
8686

8787

88-
class TestRouting_lowWind_noIsland(unittest.TestCase):
88+
class TestRoutingLowWindNoIsland(unittest.TestCase):
8989
def setUp(self):
9090
grib = MockGrib(2, 180, 0.1)
9191
self.track = [(5, 38), (5.2, 38.2)]
92-
island_route = MockPointValidity(self.track)
92+
island_route = MockpointValidity(self.track)
9393
self.routing_obj = weatherrouting.Routing(
9494
LinearBestIsoRouter,
9595
polar_bavaria38,
9696
self.track,
9797
grib,
9898
datetime.datetime.fromisoformat("2021-04-02T12:00:00"),
99-
pointValidity=island_route.point_validity,
99+
point_validity=island_route.point_validity,
100100
)
101101

102102
def test_step(self):
@@ -115,26 +115,26 @@ def test_step(self):
115115
res.time, datetime.datetime.fromisoformat("2021-04-02 18:00:00")
116116
)
117117

118-
gj = weatherrouting.utils.pathAsGeojson(path_to_end)
118+
gj = weatherrouting.utils.path_as_geojson(path_to_end)
119119

120120
self.assertEqual(len(gj["features"]), 8)
121121
self.assertEqual(
122122
gj["features"][-1]["properties"]["end-timestamp"], "2021-04-02 18:00:00"
123123
)
124124

125125

126-
class TestRouting_lowWind_mockIsland_5(unittest.TestCase):
126+
class TestRoutingLowWindMockIsland5(unittest.TestCase):
127127
def setUp(self):
128128
grib = MockGrib(2, 180, 0.1)
129129
self.track = [(5, 38), (5.2, 38.2)]
130-
island_route = MockPointValidity(self.track, factor=5)
130+
island_route = MockpointValidity(self.track, factor=5)
131131
self.routing_obj = weatherrouting.Routing(
132132
LinearBestIsoRouter,
133133
polar_bavaria38,
134134
self.track,
135135
grib,
136136
datetime.datetime.fromisoformat("2021-04-02T12:00:00"),
137-
pointValidity=island_route.point_validity,
137+
point_validity=island_route.point_validity,
138138
)
139139

140140
def test_step(self):
@@ -149,18 +149,18 @@ def test_step(self):
149149
self.assertEqual(not res.path, False)
150150

151151

152-
class checkRoute_mediumWind_mockIsland_8(unittest.TestCase):
152+
class CheckRouteMediumWindMockIsland8(unittest.TestCase):
153153
def setUp(self):
154154
grib = MockGrib(5, 45, 0.5)
155155
self.track = [(5, 38), (4.6, 37.6)]
156-
island_route = MockPointValidity(self.track, factor=8)
156+
island_route = MockpointValidity(self.track, factor=8)
157157
self.routing_obj = weatherrouting.Routing(
158158
LinearBestIsoRouter,
159159
polar_bavaria38,
160160
self.track,
161161
grib,
162162
datetime.datetime.fromisoformat("2021-04-02T12:00:00"),
163-
lineValidity=island_route.line_validity,
163+
line_validity=island_route.line_validity,
164164
)
165165

166166
def test_step(self):
@@ -175,18 +175,18 @@ def test_step(self):
175175
self.assertEqual(not res.path, False)
176176

177177

178-
class checkRoute_highWind_mockIsland_3(unittest.TestCase):
178+
class CheckRouteHighWindMockIsland3(unittest.TestCase):
179179
def setUp(self):
180180
grib = MockGrib(10, 270, 0.5)
181181
self.track = [(5, 38), (5.5, 38.5)]
182-
island_route = MockPointValidity(self.track, factor=3)
182+
island_route = MockpointValidity(self.track, factor=3)
183183
self.routing_obj = weatherrouting.Routing(
184184
LinearBestIsoRouter,
185185
polar_bavaria38,
186186
self.track,
187187
grib,
188188
datetime.datetime.fromisoformat("2021-04-02T12:00:00"),
189-
lineValidity=island_route.line_validity,
189+
line_validity=island_route.line_validity,
190190
)
191191

192192
def test_step(self):
@@ -201,7 +201,7 @@ def test_step(self):
201201
self.assertEqual(not res.path, False)
202202

203203

204-
class checkRoute_out_of_scope(unittest.TestCase):
204+
class CheckRouteOutOfScope(unittest.TestCase):
205205
def setUp(self):
206206
grib = MockGrib(
207207
10,
@@ -210,14 +210,14 @@ def setUp(self):
210210
out_of_scope=datetime.datetime.fromisoformat("2021-04-02T15:00:00"),
211211
)
212212
self.track = [(5, 38), (5.5, 38.5)]
213-
island_route = MockPointValidity(self.track, factor=3)
213+
island_route = MockpointValidity(self.track, factor=3)
214214
self.routing_obj = weatherrouting.Routing(
215215
LinearBestIsoRouter,
216216
polar_bavaria38,
217217
self.track,
218218
grib,
219219
datetime.datetime.fromisoformat("2021-04-02T12:00:00"),
220-
lineValidity=island_route.line_validity,
220+
line_validity=island_route.line_validity,
221221
)
222222

223223
def test_step(self):
@@ -232,11 +232,11 @@ def test_step(self):
232232
self.assertEqual(not res.path, False)
233233

234234

235-
class checkRoute_multipoint(unittest.TestCase):
235+
class CheckRouteMultipoint(unittest.TestCase):
236236
def setUp(self):
237237
grib = MockGrib(10, 270, 0.5)
238238
self.track = [(5, 38), (5.3, 38.3), (5.6, 38.6)]
239-
# island_route = MockPointValidity(self.track, factor=3)
239+
# island_route = MockpointValidity(self.track, factor=3)
240240
self.routing_obj = weatherrouting.Routing(
241241
LinearBestIsoRouter,
242242
polar_bavaria38,
@@ -257,18 +257,18 @@ def test_step(self):
257257
self.assertEqual(not res.path, False)
258258

259259

260-
class TestRouting_custom_step(unittest.TestCase):
260+
class TestRoutingCustomStep(unittest.TestCase):
261261
def setUp(self):
262262
grib = MockGrib(2, 180, 0.1)
263263
self.track = [(5, 38), (5.2, 38.2)]
264-
island_route = MockPointValidity(self.track, factor=5)
264+
island_route = MockpointValidity(self.track, factor=5)
265265
self.routing_obj = weatherrouting.Routing(
266266
LinearBestIsoRouter,
267267
polar_bavaria38,
268268
self.track,
269269
grib,
270270
datetime.datetime.fromisoformat("2021-04-02T12:00:00"),
271-
pointValidity=island_route.point_validity,
271+
point_validity=island_route.point_validity,
272272
)
273273

274274
def test_step(self):

tests/mock_grib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def twd_var(self, t=None):
4747
random.random() * self.fuzziness - self.fuzziness / 2
4848
)
4949

50-
def getWindAt(self, t, lat, lon) -> Optional[Tuple[float, float]]:
50+
def get_wind_at(self, t, lat, lon) -> Optional[Tuple[float, float]]:
5151
"""
5252
Returns a tuple containing direction in degree and speed in m/s
5353
"""

tests/mock_point_validity.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@
1515
import weatherrouting
1616

1717

18-
class MockPointValidity:
18+
class MockpointValidity:
1919
def __init__(self, track, factor=4):
2020
self.mean_point = (
2121
(track[0][1] + track[1][1]) / 2,
2222
(track[0][0] + track[1][0]) / 2,
2323
)
2424
self.mean_island = (
25-
weatherrouting.utils.pointDistance(*(track[0] + track[1])) / factor
25+
weatherrouting.utils.point_distance(*(track[0] + track[1])) / factor
2626
)
2727

2828
def point_validity(self, y, x):
2929
if (
30-
weatherrouting.utils.pointDistance(x, y, *(self.mean_point))
30+
weatherrouting.utils.point_distance(x, y, *(self.mean_point))
3131
< self.mean_island
3232
):
3333
return False
@@ -36,7 +36,7 @@ def point_validity(self, y, x):
3636

3737
def line_validity(self, y1, x1, y2, x2):
3838
if (
39-
weatherrouting.utils.pointDistance(x1, y2, *(self.mean_point))
39+
weatherrouting.utils.point_distance(x1, y2, *(self.mean_point))
4040
< self.mean_island
4141
):
4242
return False

0 commit comments

Comments
 (0)