gtfs_kit 5.2.6__tar.gz → 5.2.8__tar.gz
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.
- {gtfs_kit-5.2.6 → gtfs_kit-5.2.8}/PKG-INFO +1 -1
- {gtfs_kit-5.2.6 → gtfs_kit-5.2.8}/gtfs_kit/__init__.py +1 -1
- {gtfs_kit-5.2.6 → gtfs_kit-5.2.8}/gtfs_kit/helpers.py +26 -8
- {gtfs_kit-5.2.6 → gtfs_kit-5.2.8}/gtfs_kit/routes.py +5 -1
- {gtfs_kit-5.2.6 → gtfs_kit-5.2.8}/gtfs_kit/validators.py +28 -24
- {gtfs_kit-5.2.6 → gtfs_kit-5.2.8}/pyproject.toml +2 -2
- {gtfs_kit-5.2.6 → gtfs_kit-5.2.8}/setup.py +1 -1
- {gtfs_kit-5.2.6 → gtfs_kit-5.2.8}/LICENSE.txt +0 -0
- {gtfs_kit-5.2.6 → gtfs_kit-5.2.8}/README.rst +0 -0
- {gtfs_kit-5.2.6 → gtfs_kit-5.2.8}/gtfs_kit/calendar.py +0 -0
- {gtfs_kit-5.2.6 → gtfs_kit-5.2.8}/gtfs_kit/cleaners.py +0 -0
- {gtfs_kit-5.2.6 → gtfs_kit-5.2.8}/gtfs_kit/constants.py +0 -0
- {gtfs_kit-5.2.6 → gtfs_kit-5.2.8}/gtfs_kit/feed.py +0 -0
- {gtfs_kit-5.2.6 → gtfs_kit-5.2.8}/gtfs_kit/miscellany.py +0 -0
- {gtfs_kit-5.2.6 → gtfs_kit-5.2.8}/gtfs_kit/shapes.py +0 -0
- {gtfs_kit-5.2.6 → gtfs_kit-5.2.8}/gtfs_kit/stop_times.py +0 -0
- {gtfs_kit-5.2.6 → gtfs_kit-5.2.8}/gtfs_kit/stops.py +0 -0
- {gtfs_kit-5.2.6 → gtfs_kit-5.2.8}/gtfs_kit/trips.py +0 -0
|
@@ -56,7 +56,7 @@ def timestr_to_seconds(
|
|
|
56
56
|
result = int(hours) * 3600 + int(mins) * 60 + int(seconds)
|
|
57
57
|
if mod24:
|
|
58
58
|
result %= 24 * 3600
|
|
59
|
-
except:
|
|
59
|
+
except Exception:
|
|
60
60
|
result = np.nan
|
|
61
61
|
else:
|
|
62
62
|
try:
|
|
@@ -66,7 +66,7 @@ def timestr_to_seconds(
|
|
|
66
66
|
hours, remainder = divmod(seconds, 3600)
|
|
67
67
|
mins, secs = divmod(remainder, 60)
|
|
68
68
|
result = f"{hours:02d}:{mins:02d}:{secs:02d}"
|
|
69
|
-
except:
|
|
69
|
+
except Exception:
|
|
70
70
|
result = np.nan
|
|
71
71
|
return result
|
|
72
72
|
|
|
@@ -80,7 +80,7 @@ def timestr_mod24(timestr: str) -> int:
|
|
|
80
80
|
hours, mins, secs = [int(x) for x in timestr.split(":")]
|
|
81
81
|
hours %= 24
|
|
82
82
|
result = f"{hours:02d}:{mins:02d}:{secs:02d}"
|
|
83
|
-
except:
|
|
83
|
+
except Exception:
|
|
84
84
|
result = None
|
|
85
85
|
return result
|
|
86
86
|
|
|
@@ -98,12 +98,12 @@ def weekday_to_str(
|
|
|
98
98
|
if not inverse:
|
|
99
99
|
try:
|
|
100
100
|
return s[weekday]
|
|
101
|
-
except:
|
|
101
|
+
except Exception:
|
|
102
102
|
return
|
|
103
103
|
else:
|
|
104
104
|
try:
|
|
105
105
|
return s.index(weekday)
|
|
106
|
-
except:
|
|
106
|
+
except Exception:
|
|
107
107
|
return
|
|
108
108
|
|
|
109
109
|
|
|
@@ -167,14 +167,32 @@ def get_peak_indices(times: list, counts: list) -> np.array:
|
|
|
167
167
|
the first longest time period such that for all i <= x < j,
|
|
168
168
|
counts[x] is the max of counts.
|
|
169
169
|
Assume times and counts have the same nonzero length.
|
|
170
|
+
|
|
171
|
+
Examples::
|
|
172
|
+
|
|
173
|
+
>>> times = [0, 10, 20, 30, 31, 32, 40]
|
|
174
|
+
>>> counts = [7, 1, 2, 7, 7, 1, 2]
|
|
175
|
+
>>> get_peak_indices(times, counts)
|
|
176
|
+
array([0, 1])
|
|
177
|
+
|
|
178
|
+
>>> counts = [0, 0, 0]
|
|
179
|
+
>>> times = [18000, 21600, 28800]
|
|
180
|
+
>>> get_peak_indices(times, counts)
|
|
181
|
+
array([0, 3])
|
|
182
|
+
|
|
170
183
|
"""
|
|
171
184
|
max_runs = get_max_runs(counts)
|
|
172
185
|
|
|
173
186
|
def get_duration(a):
|
|
174
187
|
return times[a[1]] - times[a[0]]
|
|
175
188
|
|
|
176
|
-
|
|
177
|
-
|
|
189
|
+
if len(max_runs) == 1:
|
|
190
|
+
result = max_runs[0]
|
|
191
|
+
else:
|
|
192
|
+
index = np.argmax(np.apply_along_axis(get_duration, 1, max_runs))
|
|
193
|
+
result = max_runs[index]
|
|
194
|
+
|
|
195
|
+
return result
|
|
178
196
|
|
|
179
197
|
|
|
180
198
|
def is_metric(dist_units: str) -> bool:
|
|
@@ -577,7 +595,7 @@ def longest_subsequence(
|
|
|
577
595
|
# update existing subsequence of length j or extend the longest
|
|
578
596
|
try:
|
|
579
597
|
lastoflength[j] = i
|
|
580
|
-
except:
|
|
598
|
+
except Exception:
|
|
581
599
|
lastoflength.append(i)
|
|
582
600
|
# remember element before seq[i] in the subsequence
|
|
583
601
|
predecessor.append(lastoflength[j - 1] if j > 0 else None)
|
|
@@ -31,6 +31,8 @@ def compute_route_stats_0(
|
|
|
31
31
|
Compute stats for the given subset of trips stats (of the form output by the
|
|
32
32
|
function :func:`.trips.compute_trip_stats`).
|
|
33
33
|
|
|
34
|
+
Ignore trips with zero duration, because they are defunct.
|
|
35
|
+
|
|
34
36
|
If ``split_directions``, then separate the stats by trip direction (0 or 1).
|
|
35
37
|
Use the headway start and end times to specify the time period for computing
|
|
36
38
|
headway stats.
|
|
@@ -94,8 +96,10 @@ def compute_route_stats_0(
|
|
|
94
96
|
if trip_stats_subset.empty:
|
|
95
97
|
return pd.DataFrame()
|
|
96
98
|
|
|
99
|
+
# Remove defunct trips
|
|
100
|
+
f = trip_stats_subset.loc[lambda x: x["duration"] > 0].copy()
|
|
101
|
+
|
|
97
102
|
# Convert trip start and end times to seconds to ease calculations below
|
|
98
|
-
f = trip_stats_subset.copy()
|
|
99
103
|
f[["start_time", "end_time"]] = f[["start_time", "end_time"]].applymap(
|
|
100
104
|
hp.timestr_to_seconds
|
|
101
105
|
)
|
|
@@ -640,19 +640,20 @@ def check_attributions(
|
|
|
640
640
|
)
|
|
641
641
|
|
|
642
642
|
# Check combination of agency_id, route_id, trip_id
|
|
643
|
-
|
|
644
|
-
f
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
problems
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
643
|
+
if {"agency_id", "route_id", "trip_id"} <= set(f.columns):
|
|
644
|
+
f["flag1"] = (
|
|
645
|
+
f["agency_id"].notna().astype(int)
|
|
646
|
+
+ f["route_id"].notna().astype(int)
|
|
647
|
+
+ f["trip_id"].notna().astype(int)
|
|
648
|
+
)
|
|
649
|
+
cond = lambda x: x.flag1 > 1
|
|
650
|
+
problems = check_table(
|
|
651
|
+
problems,
|
|
652
|
+
table,
|
|
653
|
+
f,
|
|
654
|
+
cond,
|
|
655
|
+
"At most one of agency_id, route_id, trip_id can be given",
|
|
656
|
+
)
|
|
656
657
|
|
|
657
658
|
# Check organization_name
|
|
658
659
|
problems = check_column(problems, table, f, "organization_name", valid_str)
|
|
@@ -663,17 +664,20 @@ def check_attributions(
|
|
|
663
664
|
problems = check_column(problems, table, f, col, v, column_required=False)
|
|
664
665
|
|
|
665
666
|
# Check combination of is_producer, is_consumer, is_authority
|
|
666
|
-
|
|
667
|
-
f
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
667
|
+
if {"is_producer", "is_operator", "is_authority"} <= set(f.columns):
|
|
668
|
+
f["flag2"] = (
|
|
669
|
+
f["is_producer"].fillna(0)
|
|
670
|
+
+ f["is_operator"].fillna(0)
|
|
671
|
+
+ f["is_authority"].fillna(0)
|
|
672
|
+
)
|
|
673
|
+
cond = lambda x: x.flag2 < 1
|
|
674
|
+
problems = check_table(
|
|
675
|
+
problems,
|
|
676
|
+
table,
|
|
677
|
+
f,
|
|
678
|
+
cond,
|
|
679
|
+
"At least one of is_producer, is_operator, or is_authority must be 1",
|
|
680
|
+
)
|
|
677
681
|
|
|
678
682
|
# Check attribution_url
|
|
679
683
|
problems = check_column(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "gtfs_kit"
|
|
3
|
-
version = "5.2.
|
|
3
|
+
version = "5.2.8"
|
|
4
4
|
description = "A Python 3.8+ library for analyzing GTFS feeds."
|
|
5
5
|
authors = ["Alex Raichev <araichev@mrcagney.com>"]
|
|
6
6
|
readme = "README.rst"
|
|
@@ -46,4 +46,4 @@ markers = [
|
|
|
46
46
|
[tool.ruff]
|
|
47
47
|
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
|
|
48
48
|
select = ["E", "F"]
|
|
49
|
-
ignore = ["E501", "F401", "F403"]
|
|
49
|
+
ignore = ["E501", "E731", "F401", "F403"]
|
|
@@ -20,7 +20,7 @@ install_requires = \
|
|
|
20
20
|
|
|
21
21
|
setup_kwargs = {
|
|
22
22
|
'name': 'gtfs-kit',
|
|
23
|
-
'version': '5.2.
|
|
23
|
+
'version': '5.2.8',
|
|
24
24
|
'description': 'A Python 3.8+ library for analyzing GTFS feeds.',
|
|
25
25
|
'long_description': "GTFS Kit\n********\n.. image:: https://github.com/mrcagney/gtfs_kit/actions/workflows/test.yml/badge.svg\n\nGTFS Kit is a Python 3.8+ library for analyzing `General Transit Feed Specification (GTFS) <https://en.wikipedia.org/wiki/GTFS>`_ data in memory without a database.\nIt uses Pandas and Shapely to do the heavy lifting.\n\n\nInstallation\n=============\n``poetry add gtfs_kit``.\n\n\nExamples\n========\nYou can find examples in the Jupyter notebook ``notebooks/examples.ipynb``.\n\n\nAuthors\n=========\n- Alex Raichev (2019-09), maintainer\n\n\nDocumentation\n=============\nDocumentation is built via Sphinx from the source code in the ``docs`` directory then published to Github Pages at `mrcagney.github.io/gtfs_kit_docs <https://mrcagney.github.io/gtfs_kit_docs>`_.\n\n\nNotes\n=====\n- This project's development status is Alpha.\n I use GTFS Kit for work and change it breakingly to suit my needs.\n- This project uses semantic versioning.\n- I aim for GTFS Kit to handle `the current GTFS <https://developers.google.com/transit/gtfs/reference>`_.\n In particular, i avoid handling `GTFS extensions <https://developers.google.com/transit/gtfs/reference/gtfs-extensions>`_.\n That is the most reasonable scope boundary i can draw at present, given this project's tiny budget.\n If you would like to fund me to expand that scope, feel free to email me.\n- Thanks to `MRCagney <http://www.mrcagney.com/>`_ for periodically donating to this project.\n- Constructive feedback and contributions are welcome.\n Please issue pull requests from a feature branch into the ``develop`` branch and include tests.\n- GTFS time is measured relative noon minus 12 hours, which can mess things up when crossing into daylight savings time.\n I don't think this issue causes any bugs in GTFS Kit, but you and i have been warned.\n Thanks to user derhuerst for bringing this to my attention in `closed Issue 8 <https://github.com/mrcagney/gtfs_kit/issues/8#issue-1063633457>`_.\n",
|
|
26
26
|
'author': 'Alex Raichev',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|