r5py 1.0.1__py3-none-any.whl → 1.0.3.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of r5py might be problematic. Click here for more details.
- r5py/__init__.py +1 -1
- r5py/r5/__init__.py +0 -2
- r5py/r5/regional_task.py +4 -33
- r5py/r5/transit_layer.py +18 -39
- r5py/r5/transport_network.py +28 -2
- r5py/util/exceptions.py +4 -0
- {r5py-1.0.1.dist-info → r5py-1.0.3.dev0.dist-info}/METADATA +3 -2
- {r5py-1.0.1.dist-info → r5py-1.0.3.dev0.dist-info}/RECORD +11 -12
- {r5py-1.0.1.dist-info → r5py-1.0.3.dev0.dist-info}/WHEEL +1 -1
- r5py/r5/breakdown_stat.py +0 -26
- {r5py-1.0.1.dist-info → r5py-1.0.3.dev0.dist-info/licenses}/LICENSE +0 -0
- {r5py-1.0.1.dist-info → r5py-1.0.3.dev0.dist-info}/top_level.txt +0 -0
r5py/__init__.py
CHANGED
r5py/r5/__init__.py
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
"""R5 classes."""
|
|
4
4
|
|
|
5
5
|
from .access_leg import AccessLeg
|
|
6
|
-
from .breakdown_stat import BreakdownStat
|
|
7
6
|
from .detailed_itineraries import DetailedItineraries, DetailedItinerariesComputer
|
|
8
7
|
from .direct_leg import DirectLeg
|
|
9
8
|
from .egress_leg import EgressLeg
|
|
@@ -21,7 +20,6 @@ from .trip_planner import TripPlanner
|
|
|
21
20
|
|
|
22
21
|
__all__ = [
|
|
23
22
|
"AccessLeg",
|
|
24
|
-
"BreakdownStat",
|
|
25
23
|
"DetailedItineraries",
|
|
26
24
|
"DetailedItinerariesComputer",
|
|
27
25
|
"DirectLeg",
|
r5py/r5/regional_task.py
CHANGED
|
@@ -45,7 +45,6 @@ class RegionalTask:
|
|
|
45
45
|
speed_cycling=12.0,
|
|
46
46
|
max_public_transport_rides=8,
|
|
47
47
|
max_bicycle_traffic_stress=3,
|
|
48
|
-
breakdown=False,
|
|
49
48
|
):
|
|
50
49
|
"""
|
|
51
50
|
Create a RegionalTask, a computing request for R5.
|
|
@@ -110,8 +109,6 @@ class RegionalTask:
|
|
|
110
109
|
max_bicycle_traffic_stress : int
|
|
111
110
|
Maximum stress level for cyclist routing, ranges from 1-4 see
|
|
112
111
|
https://docs.conveyal.com/learn-more/traffic-stress Default: 3
|
|
113
|
-
breakdown : bool
|
|
114
|
-
Compute a more detailed breakdown of the routes. Default: False
|
|
115
112
|
"""
|
|
116
113
|
self._regional_task = com.conveyal.r5.analyst.cluster.RegionalTask()
|
|
117
114
|
self.scenario = Scenario()
|
|
@@ -149,8 +146,6 @@ class RegionalTask:
|
|
|
149
146
|
|
|
150
147
|
# always record travel times
|
|
151
148
|
self._regional_task.recordTimes = True
|
|
152
|
-
# also report paths, if `breakdown`
|
|
153
|
-
self.breakdown = breakdown
|
|
154
149
|
|
|
155
150
|
# a few settings we don’t expose (yet?)
|
|
156
151
|
self._regional_task.makeTauiSite = False
|
|
@@ -185,32 +180,6 @@ class RegionalTask:
|
|
|
185
180
|
access_modes, com.conveyal.r5.api.util.LegMode
|
|
186
181
|
)
|
|
187
182
|
|
|
188
|
-
@property
|
|
189
|
-
def breakdown(self):
|
|
190
|
-
"""Compute a more detailed breakdown of the routes."""
|
|
191
|
-
return self._breakdown
|
|
192
|
-
|
|
193
|
-
@breakdown.setter
|
|
194
|
-
def breakdown(self, breakdown):
|
|
195
|
-
self._breakdown = breakdown
|
|
196
|
-
self._regional_task.includePathResults = breakdown
|
|
197
|
-
|
|
198
|
-
# R5 has a maximum number of destinations for which it returns detailed
|
|
199
|
-
# information, and it’s set to 5000 by default.
|
|
200
|
-
# The value is a static property of com.conveyal.r5.analyst.cluster.PathResult;
|
|
201
|
-
# static properites of Java classes can be modified in a singleton kind of way
|
|
202
|
-
try:
|
|
203
|
-
num_destinations = len(self.destinations)
|
|
204
|
-
except AttributeError:
|
|
205
|
-
num_destinations = 0
|
|
206
|
-
if (
|
|
207
|
-
num_destinations
|
|
208
|
-
> com.conveyal.r5.analyst.cluster.PathResult.MAX_PATH_DESTINATIONS
|
|
209
|
-
):
|
|
210
|
-
com.conveyal.r5.analyst.cluster.PathResult.MAX_PATH_DESTINATIONS = (
|
|
211
|
-
num_destinations + 1
|
|
212
|
-
)
|
|
213
|
-
|
|
214
183
|
@property
|
|
215
184
|
def departure(self):
|
|
216
185
|
"""Find public transport connections leaving within ``departure_time_window`` after ``departure`` (datetime.datetime)."""
|
|
@@ -225,8 +194,10 @@ class RegionalTask:
|
|
|
225
194
|
):
|
|
226
195
|
# fmt: on
|
|
227
196
|
warnings.warn(
|
|
228
|
-
|
|
229
|
-
|
|
197
|
+
(
|
|
198
|
+
"The currently loaded GTFS data sets do not define "
|
|
199
|
+
f"any services on {departure.date()}."
|
|
200
|
+
),
|
|
230
201
|
RuntimeWarning,
|
|
231
202
|
)
|
|
232
203
|
|
r5py/r5/transit_layer.py
CHANGED
|
@@ -4,13 +4,12 @@
|
|
|
4
4
|
"""Wraps a com.conveyal.r5.transit.TransitLayer."""
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
import datetime
|
|
8
7
|
import functools
|
|
9
8
|
|
|
10
9
|
import jpype
|
|
11
10
|
import jpype.types
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
import java.time
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
__all__ = ["TransitLayer"]
|
|
@@ -32,44 +31,24 @@ class TransitLayer:
|
|
|
32
31
|
instance._transit_layer = transit_layer
|
|
33
32
|
return instance
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
try:
|
|
39
|
-
start_date = min(
|
|
40
|
-
[
|
|
41
|
-
parse_int_date(service.calendar.start_date)
|
|
42
|
-
for service in self._transit_layer.services
|
|
43
|
-
]
|
|
44
|
-
)
|
|
45
|
-
except (AttributeError, ValueError) as exception:
|
|
46
|
-
raise ValueError("No GTFS data set loaded") from exception
|
|
47
|
-
return start_date
|
|
34
|
+
def covers(self, date):
|
|
35
|
+
"""
|
|
36
|
+
Check whether `date` is covered by GTFS data sets.
|
|
48
37
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
raise ValueError("No GTFS data set loaded") from exception
|
|
64
|
-
return end_date
|
|
65
|
-
|
|
66
|
-
def covers(self, point_in_time):
|
|
67
|
-
"""Check whether `point_in_time` is covered by GTFS data sets."""
|
|
68
|
-
try:
|
|
69
|
-
covers = self.start_date <= point_in_time <= self.end_date
|
|
70
|
-
except ValueError: # no GTFS data loaded
|
|
71
|
-
covers = False
|
|
72
|
-
return covers
|
|
38
|
+
Arguments:
|
|
39
|
+
----------
|
|
40
|
+
date : datetime.date
|
|
41
|
+
date for which to check whether a GTFS service exists.
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
--------
|
|
45
|
+
bool
|
|
46
|
+
Whether or not any services exist on `date`.
|
|
47
|
+
"""
|
|
48
|
+
date = java.time.LocalDate.of(date.year, date.month, date.day)
|
|
49
|
+
return True in set(
|
|
50
|
+
[service.activeOn(date) for service in self._transit_layer.services]
|
|
51
|
+
)
|
|
73
52
|
|
|
74
53
|
def get_street_vertex_for_stop(self, stop):
|
|
75
54
|
"""
|
r5py/r5/transport_network.py
CHANGED
|
@@ -16,6 +16,7 @@ from .street_layer import StreetLayer
|
|
|
16
16
|
from .transit_layer import TransitLayer
|
|
17
17
|
from .transport_mode import TransportMode
|
|
18
18
|
from ..util import Config, contains_gtfs_data, FileDigest, start_jvm, WorkingCopy
|
|
19
|
+
from ..util.exceptions import GtfsFileError
|
|
19
20
|
|
|
20
21
|
import com.conveyal.gtfs
|
|
21
22
|
import com.conveyal.osmlib
|
|
@@ -35,7 +36,7 @@ start_jvm()
|
|
|
35
36
|
class TransportNetwork:
|
|
36
37
|
"""Wrap a com.conveyal.r5.transit.TransportNetwork."""
|
|
37
38
|
|
|
38
|
-
def __init__(self, osm_pbf, gtfs=[]):
|
|
39
|
+
def __init__(self, osm_pbf, gtfs=[], allow_errors=False):
|
|
39
40
|
"""
|
|
40
41
|
Load a transport network.
|
|
41
42
|
|
|
@@ -45,6 +46,9 @@ class TransportNetwork:
|
|
|
45
46
|
file path of an OpenStreetMap extract in PBF format
|
|
46
47
|
gtfs : str | pathlib.Path | list[str] | list[pathlib.Path]
|
|
47
48
|
path(s) to public transport schedule information in GTFS format
|
|
49
|
+
allow_errors : bool
|
|
50
|
+
try to proceed with loading the transport network even if input data
|
|
51
|
+
contain errors
|
|
48
52
|
"""
|
|
49
53
|
osm_pbf = WorkingCopy(osm_pbf)
|
|
50
54
|
if isinstance(gtfs, (str, pathlib.Path)):
|
|
@@ -79,9 +83,31 @@ class TransportNetwork:
|
|
|
79
83
|
transport_network.transitLayer = com.conveyal.r5.transit.TransitLayer()
|
|
80
84
|
transport_network.transitLayer.parentNetwork = transport_network
|
|
81
85
|
for gtfs_file in gtfs:
|
|
82
|
-
gtfs_feed = com.conveyal.gtfs.GTFSFeed.
|
|
86
|
+
gtfs_feed = com.conveyal.gtfs.GTFSFeed.writableTempFileFromGtfs(
|
|
83
87
|
f"{gtfs_file}"
|
|
84
88
|
)
|
|
89
|
+
if gtfs_feed.errors.size() > 0:
|
|
90
|
+
errors = [
|
|
91
|
+
f"{error.errorType}: {error.getMessageWithContext()}"
|
|
92
|
+
for error in gtfs_feed.errors
|
|
93
|
+
]
|
|
94
|
+
if allow_errors:
|
|
95
|
+
warnings.warn(
|
|
96
|
+
(
|
|
97
|
+
"R5 reported the following issues with "
|
|
98
|
+
f"GTFS file {gtfs_file.name}: \n"
|
|
99
|
+
+ ("\n- ".join(errors))
|
|
100
|
+
),
|
|
101
|
+
RuntimeWarning,
|
|
102
|
+
)
|
|
103
|
+
else:
|
|
104
|
+
raise GtfsFileError(
|
|
105
|
+
(
|
|
106
|
+
f"Could not load GTFS file {gtfs_file.name}. \n"
|
|
107
|
+
+ ("\n- ".join(errors))
|
|
108
|
+
)
|
|
109
|
+
)
|
|
110
|
+
|
|
85
111
|
transport_network.transitLayer.loadFromGtfs(gtfs_feed)
|
|
86
112
|
gtfs_feed.close()
|
|
87
113
|
|
r5py/util/exceptions.py
CHANGED
|
@@ -12,6 +12,10 @@ class R5pyError(Exception):
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
# more specific exceptions
|
|
15
|
+
class GtfsFileError(R5pyError):
|
|
16
|
+
"""GTFS file contained errors."""
|
|
17
|
+
|
|
18
|
+
|
|
15
19
|
class ChecksumFailed(requests.RequestException, R5pyError):
|
|
16
20
|
"""Requested resource did not pass checksum test."""
|
|
17
21
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: r5py
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3.dev0
|
|
4
4
|
Summary: Python wrapper for the R5 routing analysis engine
|
|
5
5
|
Author: Christoph Fink, Willem Klumpenhouwer, Marcus Sairava, Rafael Pereira, Henrikki Tenkanen
|
|
6
6
|
License: GPL-3.0-or-later or MIT
|
|
@@ -58,6 +58,7 @@ Requires-Dist: pytest-lazy-fixtures; extra == "tests"
|
|
|
58
58
|
Requires-Dist: r5py.sampledata.helsinki>=0.1.1; extra == "tests"
|
|
59
59
|
Requires-Dist: r5py.sampledata.sao_paulo>=0.1.1; extra == "tests"
|
|
60
60
|
Requires-Dist: typing-extensions; extra == "tests"
|
|
61
|
+
Dynamic: license-file
|
|
61
62
|
|
|
62
63
|
<img class="r5py_logo" align="right" src="https://github.com/r5py/r5py/raw/main/docs/_static/images/r5py_blue.svg" alt="r5py logo" style="width:180px; max-width:30vW;">
|
|
63
64
|
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
r5py/__init__.py,sha256=
|
|
1
|
+
r5py/__init__.py,sha256=fmuPx-uivkG0M6kPpYFSiiAHJKYQ4iWAprWSkeq--xA,551
|
|
2
2
|
r5py/__main__.py,sha256=Wvn0ChD7E-dCSZ8b8k_HhHG0KMOk0qMNFkijGuSH3-0,81
|
|
3
|
-
r5py/r5/__init__.py,sha256=
|
|
3
|
+
r5py/r5/__init__.py,sha256=BVEeEVc-uUHLPLYBq1LN4exiQIHDw4YyANxNrprb8jQ,1061
|
|
4
4
|
r5py/r5/access_leg.py,sha256=W3GfPEpqmWD1c4xipd6UcVIaBC-yb6srGCZV30E2dPY,293
|
|
5
5
|
r5py/r5/base_travel_time_matrix.py,sha256=Vl82Wkk2iANNy6L3r937yXNnQ9lmMOErGT_-fQnb1Ms,6978
|
|
6
|
-
r5py/r5/breakdown_stat.py,sha256=ZQkWA0hXlcRH3KVgtxPSNHP0FUDri8MWqdFk8EUdDMU,533
|
|
7
6
|
r5py/r5/detailed_itineraries.py,sha256=Oo8JnF5jM2FsYFR1ma9r4y3evOmU7itDYs5M4vbqrZo,11245
|
|
8
7
|
r5py/r5/direct_leg.py,sha256=T7wX8puhOVIssCpflXthYs-G9OA8pasFbdz9p8k8teg,1054
|
|
9
8
|
r5py/r5/egress_leg.py,sha256=9rsCIcwlZUzoZE6q4imNY3VWpjJepO1IJvheVrlPi90,297
|
|
10
9
|
r5py/r5/isochrones.py,sha256=NNpV3Df4NeLdDksGERkb2Eos33ziMBGEeaWyCKPt5P8,12974
|
|
11
|
-
r5py/r5/regional_task.py,sha256=
|
|
10
|
+
r5py/r5/regional_task.py,sha256=jpOoskx7Y-j-c4E-56uvJXiiuPYK3w28_FJsoGQLSbE,22062
|
|
12
11
|
r5py/r5/scenario.py,sha256=nUNAlN3cO7E_b4sMpNqdL0FD7WQaQ49iIvh-k8l4YRM,763
|
|
13
12
|
r5py/r5/street_layer.py,sha256=2AWhIE0-aTNGQenX6bF1xv5bmhR_LV0CgqM4BKgVYfk,2329
|
|
14
13
|
r5py/r5/street_segment.py,sha256=0O0QV8Eyfss-xHJShKGSQV1IusZfTrrxzu_AWl3KACo,1109
|
|
15
14
|
r5py/r5/transfer_leg.py,sha256=_IpzQJAyW4hDPO5V4k-ZjIPd3uyxhHPa4U6_b8UbKt4,311
|
|
16
|
-
r5py/r5/transit_layer.py,sha256=
|
|
15
|
+
r5py/r5/transit_layer.py,sha256=vfbzCpTiIpCevSwCTz7EGeFWB4LDrfba1JAqXYo7WXo,2334
|
|
17
16
|
r5py/r5/transit_leg.py,sha256=R0Qc9YLMEXYu51NIdo7Q0bdmpYIJf5irEDXWrW6pZWE,221
|
|
18
17
|
r5py/r5/transport_mode.py,sha256=zHSqXb0R4oyjTp069CzO69IgoCKt0nmOAwsSy272rGo,3675
|
|
19
|
-
r5py/r5/transport_network.py,sha256=
|
|
18
|
+
r5py/r5/transport_network.py,sha256=eKq4c4L46k_rpPkO9MxPOWHAZ0ZyPzV27lVouNFHqSk,9055
|
|
20
19
|
r5py/r5/travel_time_matrix.py,sha256=Z_ErylB8mMD_eO2BogV3K_OFdYFVCcmIPmcMe7GGRiU,8003
|
|
21
20
|
r5py/r5/trip.py,sha256=AqhlhgYaGRL5jVzV08BhsqgWxe8f4wAb5HMP8HIGwc8,2944
|
|
22
21
|
r5py/r5/trip_leg.py,sha256=9E4vZpBEJCXIVqAXWJvnPloC-upEASKhFnjiuen8i8A,6495
|
|
@@ -28,7 +27,7 @@ r5py/util/config.py,sha256=5jz42iUaftgBfJ2HNnktZw5oXIPE2ytl3Nxt2RjjDoM,5267
|
|
|
28
27
|
r5py/util/contains_gtfs_data.py,sha256=ooX4hfVDKK0aqX1MI46jSFZ7dZ6riyXaORrgF6PUFrk,1211
|
|
29
28
|
r5py/util/data_validation.py,sha256=H5Mcp2nS4vu5RKym20mPnGpl-8d0SDchzDRJBrrL6WE,1039
|
|
30
29
|
r5py/util/environment.py,sha256=cbSM8TKTuhbXsTIIB06pMtydBOiqLkitF2Lj2asVTho,1082
|
|
31
|
-
r5py/util/exceptions.py,sha256=
|
|
30
|
+
r5py/util/exceptions.py,sha256=i1FyTuas43HnlLUIf3zip0Eie2S0j09EcgB9KnmQoKE,1121
|
|
32
31
|
r5py/util/file_digest.py,sha256=95UbaxbTZLa54j1CupsKria028xZ8f6ueZsTupnjlYE,1061
|
|
33
32
|
r5py/util/good_enough_equidistant_crs.py,sha256=7FX3Ly3qegSV_YRA4OFk49LC29xUyTte1Gc5qOEi_9E,2458
|
|
34
33
|
r5py/util/jvm.py,sha256=NCwoYLDznXydcIRAZl2kzUQA6D6NCvzjVG74pm6ioR0,5027
|
|
@@ -40,8 +39,8 @@ r5py/util/spatially_clustered_geodataframe.py,sha256=FxG8V3SSeK-PuCep565p1b3TNcl
|
|
|
40
39
|
r5py/util/validating_requests_session.py,sha256=sH5FgpS9eGax5DG2qA2GrGuiwgTJgh8tKsZ9OiXKmvk,1807
|
|
41
40
|
r5py/util/warnings.py,sha256=CvxKWKlNO_p3riB4SkNqbU5AGPsaY_3-OzqaBObE3B8,139
|
|
42
41
|
r5py/util/working_copy.py,sha256=sbLbRCi39LtC-0tXxvh2y7ZN2D15chbhleCZXzHAFSc,1432
|
|
43
|
-
r5py-1.0.
|
|
44
|
-
r5py-1.0.
|
|
45
|
-
r5py-1.0.
|
|
46
|
-
r5py-1.0.
|
|
47
|
-
r5py-1.0.
|
|
42
|
+
r5py-1.0.3.dev0.dist-info/licenses/LICENSE,sha256=VAnuGDX1TPylSN9G2xLa-urDpj_SQwn-qqs068dx4tk,51
|
|
43
|
+
r5py-1.0.3.dev0.dist-info/METADATA,sha256=GnVvhl0wT1TNeqWnslpiwmvpw2fYJl62oUjkfptcsss,9981
|
|
44
|
+
r5py-1.0.3.dev0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
45
|
+
r5py-1.0.3.dev0.dist-info/top_level.txt,sha256=fOH1R85dkNDOI7jkg-lIsl5CQIO4fE5X868K9dTqs9U,5
|
|
46
|
+
r5py-1.0.3.dev0.dist-info/RECORD,,
|
r5py/r5/breakdown_stat.py
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
|
|
3
|
-
"""Wraps a com.conveyal.r5.analyst.cluster.PathResult.Stat enum set."""
|
|
4
|
-
|
|
5
|
-
import enum
|
|
6
|
-
|
|
7
|
-
from ..util import start_jvm
|
|
8
|
-
|
|
9
|
-
import com.conveyal.r5
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
__all__ = ["BreakdownStat"]
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
start_jvm()
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class BreakdownStat(enum.Enum):
|
|
19
|
-
"""
|
|
20
|
-
Statistical functions to apply to detailed routing results summary.
|
|
21
|
-
|
|
22
|
-
BreakdownStat.MEAN, BreakdownStat.MINIMUM
|
|
23
|
-
"""
|
|
24
|
-
|
|
25
|
-
MEAN = com.conveyal.r5.analyst.cluster.PathResult.Stat.valueOf("MEAN")
|
|
26
|
-
MINIMUM = com.conveyal.r5.analyst.cluster.PathResult.Stat.valueOf("MINIMUM")
|
|
File without changes
|
|
File without changes
|