r5py 0.1.1.dev2__py3-none-any.whl → 1.0.0__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.

Files changed (38) hide show
  1. r5py/__init__.py +8 -1
  2. r5py/__main__.py +1 -14
  3. r5py/r5/__init__.py +20 -2
  4. r5py/r5/{base_travel_time_matrix_computer.py → base_travel_time_matrix.py} +28 -8
  5. r5py/r5/{detailed_itineraries_computer.py → detailed_itineraries.py} +82 -20
  6. r5py/r5/direct_leg.py +1 -3
  7. r5py/r5/isochrones.py +351 -0
  8. r5py/r5/regional_task.py +12 -9
  9. r5py/r5/street_layer.py +8 -3
  10. r5py/r5/street_segment.py +41 -0
  11. r5py/r5/transfer_leg.py +2 -6
  12. r5py/r5/transit_layer.py +6 -0
  13. r5py/r5/transit_leg.py +1 -5
  14. r5py/r5/transport_mode.py +5 -3
  15. r5py/r5/transport_network.py +60 -138
  16. r5py/r5/travel_time_matrix.py +209 -0
  17. r5py/r5/trip.py +13 -8
  18. r5py/r5/trip_leg.py +76 -15
  19. r5py/r5/trip_planner.py +109 -54
  20. r5py/util/__init__.py +8 -0
  21. r5py/util/classpath.py +9 -5
  22. r5py/util/config.py +32 -7
  23. r5py/util/environment.py +34 -0
  24. r5py/util/file_digest.py +42 -0
  25. r5py/util/good_enough_equidistant_crs.py +8 -4
  26. r5py/util/memory_footprint.py +3 -5
  27. r5py/util/sample_data_set.py +17 -6
  28. r5py/util/spatially_clustered_geodataframe.py +78 -0
  29. r5py/util/validating_requests_session.py +2 -2
  30. r5py/util/working_copy.py +44 -0
  31. {r5py-0.1.1.dev2.dist-info → r5py-1.0.0.dist-info}/METADATA +34 -33
  32. r5py-1.0.0.dist-info/RECORD +47 -0
  33. {r5py-0.1.1.dev2.dist-info → r5py-1.0.0.dist-info}/WHEEL +1 -1
  34. r5py/r5/travel_time_matrix_computer.py +0 -134
  35. r5py/sampledata/_keep/__init__.py +0 -3
  36. r5py-0.1.1.dev2.dist-info/RECORD +0 -42
  37. {r5py-0.1.1.dev2.dist-info → r5py-1.0.0.dist-info}/LICENSE +0 -0
  38. {r5py-0.1.1.dev2.dist-info → r5py-1.0.0.dist-info}/top_level.txt +0 -0
@@ -1,134 +0,0 @@
1
- #!/usr/bin/env python3
2
-
3
- """Calculate travel times between many origins and destinations."""
4
-
5
- import copy
6
-
7
- import joblib
8
- import pandas
9
-
10
- from .base_travel_time_matrix_computer import BaseTravelTimeMatrixComputer
11
- from ..util import start_jvm
12
-
13
- import com.conveyal.r5
14
-
15
-
16
- __all__ = ["TravelTimeMatrixComputer"]
17
-
18
-
19
- start_jvm()
20
-
21
-
22
- class TravelTimeMatrixComputer(BaseTravelTimeMatrixComputer):
23
- """Compute travel times between many origins and destinations."""
24
-
25
- def compute_travel_times(self):
26
- """
27
- Compute travel times from all origins to all destinations.
28
-
29
- Returns
30
- -------
31
- pandas.DataFrame
32
- A data frame containing the columns ``from_id``, ``to_id``, and
33
- ``travel_time``, where ``travel_time`` is the median calculated
34
- travel time between ``from_id`` and ``to_id`` or ``numpy.nan``
35
- if no connection with the given parameters was found.
36
- If non-default ``percentiles`` were requested: one or more columns
37
- ``travel_time_p{:02d}`` representing the particular percentile of
38
- travel time.
39
- """
40
- self._prepare_origins_destinations()
41
- self.request.destinations = self.destinations
42
-
43
- # loop over all origins, modify the request, and compute the times
44
- # to all destinations.
45
- with joblib.Parallel(
46
- prefer="threads",
47
- verbose=(10 * self.verbose), # joblib has a funny verbosity scale
48
- n_jobs=self.NUM_THREADS,
49
- ) as parallel:
50
- od_matrix = pandas.concat(
51
- parallel(
52
- joblib.delayed(self._travel_times_per_origin)(from_id)
53
- for from_id in self.origins.id
54
- ),
55
- ignore_index=True,
56
- )
57
-
58
- try:
59
- od_matrix = od_matrix.to_crs(self._origins_crs)
60
- except AttributeError: # (not a GeoDataFrame)
61
- pass
62
- return od_matrix
63
-
64
- def _parse_results(self, from_id, results):
65
- """
66
- Parse the results of an R5 TravelTimeMatrix.
67
-
68
- Parse data as returned from `com.conveyal.r5.analyst.TravelTimeComputer.computeTravelTimes()`,
69
- cast data to Python types, and return as a `pandas.Dataframe`. Because of the way r5py
70
- and R5 interact, this parses the results of routing from one origin to many (all) destinations.
71
-
72
- Arguments
73
- ---------
74
- from_id : mixed
75
- The value of the ID column of the origin record to report on.
76
- results : `com.conveyal.r5.OneOriginResult` (Java object)
77
-
78
- Returns
79
- -------
80
- pandas.DataFrame
81
- A data frame containing the columns ``from_id``, ``to_id``, and
82
- ``travel_time``, where ``travel_time`` is the median calculated
83
- travel time between ``from_id`` and ``to_id`` or ``numpy.nan``
84
- if no connection with the given parameters was found.
85
- If non-default ``percentiles`` were requested: one or more columns
86
- ``travel_time_p{:02d}`` representing the particular percentile of
87
- travel time.
88
- """
89
- # First, create an empty DataFrame (this forces column types)
90
- travel_time_columns = {
91
- "from_id": pandas.Series(dtype=str),
92
- "to_id": pandas.Series(dtype=str),
93
- }
94
- travel_time_columns.update(
95
- {
96
- f"travel_time_p{percentile:d}": pandas.Series(dtype=float)
97
- for percentile in self.request.percentiles
98
- }
99
- )
100
- od_matrix = pandas.DataFrame(travel_time_columns)
101
-
102
- # first assign columns with correct length (`to_id`),
103
- # only then fill `from_id` (it’s a scalar)
104
- od_matrix["to_id"] = self.destinations.id
105
- od_matrix["from_id"] = from_id
106
-
107
- for p, percentile in enumerate(self.request.percentiles):
108
- travel_times = results.travelTimes.getValues()[p]
109
- od_matrix[f"travel_time_p{percentile:d}"] = travel_times
110
-
111
- # rename percentile column if only median requested (the default)
112
- if self.request.percentiles == [50]:
113
- od_matrix = od_matrix.rename(columns={"travel_time_p50": "travel_time"})
114
-
115
- # R5’s NULL value is MAX_INT32
116
- od_matrix = self._fill_nulls(od_matrix)
117
-
118
- # re-index (and don’t keep the old index as a new column)
119
- od_matrix = od_matrix.reset_index(drop=True)
120
-
121
- return od_matrix
122
-
123
- def _travel_times_per_origin(self, from_id):
124
- request = copy.copy(self.request)
125
- request.origin = self.origins[self.origins.id == from_id].geometry.item()
126
-
127
- travel_time_computer = com.conveyal.r5.analyst.TravelTimeComputer(
128
- request, self.transport_network
129
- )
130
- results = travel_time_computer.computeTravelTimes()
131
-
132
- od_matrix = self._parse_results(from_id, results)
133
-
134
- return od_matrix
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env
2
-
3
- """A placeholder for plugin-style sample data packages within the r5py.sampledata.* namespace."""
@@ -1,42 +0,0 @@
1
- r5py/__init__.py,sha256=eWYsVlnfyYPcIveYA3jP_niDewEPlrWau81hem9WybM,418
2
- r5py/__main__.py,sha256=5p_QWx8hsNbz34OwMKl9mY644bfqwXRFXkFSlTP06AM,239
3
- r5py/r5/__init__.py,sha256=gq-1XbdrHE4v3XAvyV-Amod-Vcgp_c1Sbs13mgxOD08,643
4
- r5py/r5/access_leg.py,sha256=W3GfPEpqmWD1c4xipd6UcVIaBC-yb6srGCZV30E2dPY,293
5
- r5py/r5/base_travel_time_matrix_computer.py,sha256=lnyI70dIGq0e9E1cvLJfF17hIw8eG8Qnt8WfXOwNFBo,6313
6
- r5py/r5/breakdown_stat.py,sha256=ZQkWA0hXlcRH3KVgtxPSNHP0FUDri8MWqdFk8EUdDMU,533
7
- r5py/r5/detailed_itineraries_computer.py,sha256=kRV8OBpvdsgYHcNGQzBi6Y3WyAlPCTSQn0HrWoBqvus,8483
8
- r5py/r5/direct_leg.py,sha256=opX575iuByoy8WORIsSvIgVqAwglBVCl15ZCo1pv_Mk,1064
9
- r5py/r5/egress_leg.py,sha256=9rsCIcwlZUzoZE6q4imNY3VWpjJepO1IJvheVrlPi90,297
10
- r5py/r5/regional_task.py,sha256=uzciavh9qWrMPYtixIdSR8hMxg4tyC98FnTYqpN4FME,23136
11
- r5py/r5/scenario.py,sha256=nUNAlN3cO7E_b4sMpNqdL0FD7WQaQ49iIvh-k8l4YRM,763
12
- r5py/r5/street_layer.py,sha256=aA8cBXvV60wH7WlEnwqbPXPpPxwQQsPPbW59HDUJrc0,2196
13
- r5py/r5/transfer_leg.py,sha256=m_9t1Kr8pq5rmtJz4XZSvRpog4_WpMtF2nKeybJ0v8U,325
14
- r5py/r5/transit_layer.py,sha256=znQcJmtFpqVcsvZziPDHxAcRS0OXvyn3JdWE_lXZv0A,2928
15
- r5py/r5/transit_leg.py,sha256=zd8QnMiOHCw3hS6WO5uwegxROdwDpqNDqvZwVJ2MlKo,241
16
- r5py/r5/transport_mode.py,sha256=YJj2CzZ0cz4hAu48udYtX8MnFuSx4he703xcP3BV_7I,3586
17
- r5py/r5/transport_network.py,sha256=ZWKHEhRkmpy_lQLvMjjjRqp_8ciP5kea7263Y4WwhG0,10470
18
- r5py/r5/travel_time_matrix_computer.py,sha256=ns4DnWXfyPpslwQlHGM5Vsmpdzvr8NF-hWaRgc8HYGc,4880
19
- r5py/r5/trip.py,sha256=SvXXQdvkCZzXcAbLyxKjCEwdbft_Jt7SPmPDzdw0K9w,2617
20
- r5py/r5/trip_leg.py,sha256=gto-VRo_AdUxdRDRlIey6f8jSZ021NI91BODTowp-wQ,4131
21
- r5py/r5/trip_planner.py,sha256=298IvJioFz4uj1L8qXJE5Ehrqcy51IP_2FoQfo3GEDc,21293
22
- r5py/sampledata/_keep/__init__.py,sha256=Dd14TxWipq66sLK3ponMl09SbtzWoqmD-dhbTuS889M,114
23
- r5py/util/__init__.py,sha256=moUcR_oxpITt2vdNQxuej6haFywjA62UcUY4T5TMDns,673
24
- r5py/util/camel_to_snake_case.py,sha256=zj5F3PNBvsuS6vqN4USeeo8NI-3hnscGhwun0G95AK0,673
25
- r5py/util/classpath.py,sha256=os4UmHEs2GGk0jnHSD_1wJHEjmpYQU3VAb6T_iUdFEw,2724
26
- r5py/util/config.py,sha256=M3eT4B2mB0CaFHQYn5DmtFTtSc4_RCK8fS3UuO7X2D8,4216
27
- r5py/util/contains_gtfs_data.py,sha256=ooX4hfVDKK0aqX1MI46jSFZ7dZ6riyXaORrgF6PUFrk,1211
28
- r5py/util/data_validation.py,sha256=H5Mcp2nS4vu5RKym20mPnGpl-8d0SDchzDRJBrrL6WE,1039
29
- r5py/util/exceptions.py,sha256=r65XUg_AJ_bTw8ARNj7A2-GbFZlSTrOAjDynx1pSD2Y,1049
30
- r5py/util/good_enough_equidistant_crs.py,sha256=VuzPGPTyL7T0Cl3SZba7atBTyyt9uUTLkq7JVMxjGsI,2355
31
- r5py/util/jvm.py,sha256=NCwoYLDznXydcIRAZl2kzUQA6D6NCvzjVG74pm6ioR0,5027
32
- r5py/util/memory_footprint.py,sha256=FlOLEAz7yI3YOv3wJe_tejJPh0y640QlDd0Z3Ce5i2s,4660
33
- r5py/util/parse_int_date.py,sha256=JmnV8TwdUdUp3kSp2e73ZSxCbRyqv2FmQzNt0I_MsM0,667
34
- r5py/util/sample_data_set.py,sha256=YQcDjcywria2hiR9A3cS8y3LmGsEAraQMDaGXFPg4JU,2165
35
- r5py/util/snake_to_camel_case.py,sha256=uJ5hTCVDUEmIxTyy4LGFTbpGC_rtnjDZVQ2vmVRTQ4k,485
36
- r5py/util/validating_requests_session.py,sha256=nkgOsZ_fbaP19R8l0ImZLFo5zUdw9-B289w0DEygtW0,1809
37
- r5py/util/warnings.py,sha256=CvxKWKlNO_p3riB4SkNqbU5AGPsaY_3-OzqaBObE3B8,139
38
- r5py-0.1.1.dev2.dist-info/LICENSE,sha256=VAnuGDX1TPylSN9G2xLa-urDpj_SQwn-qqs068dx4tk,51
39
- r5py-0.1.1.dev2.dist-info/METADATA,sha256=ZFy_vU_mdoQtSMduASSOhF8uIIL0Yq2PG0KxnuBVnCY,9997
40
- r5py-0.1.1.dev2.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
41
- r5py-0.1.1.dev2.dist-info/top_level.txt,sha256=fOH1R85dkNDOI7jkg-lIsl5CQIO4fE5X868K9dTqs9U,5
42
- r5py-0.1.1.dev2.dist-info/RECORD,,