gtfs_kit 5.2.6__tar.gz → 5.2.7__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gtfs-kit
3
- Version: 5.2.6
3
+ Version: 5.2.7
4
4
  Summary: A Python 3.8+ library for analyzing GTFS feeds.
5
5
  Home-page: https://github.com/mrcagney/gtfs_kit
6
6
  License: MIT
@@ -12,4 +12,4 @@ from .validators import *
12
12
  from .feed import *
13
13
 
14
14
 
15
- __version__ = "5.2.6"
15
+ __version__ = "5.2.7"
@@ -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
- index = np.argmax(np.apply_along_axis(get_duration, 1, max_runs))
177
- return max_runs[index]
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)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "gtfs_kit"
3
- version = "5.2.6"
3
+ version = "5.2.7"
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"
@@ -20,7 +20,7 @@ install_requires = \
20
20
 
21
21
  setup_kwargs = {
22
22
  'name': 'gtfs-kit',
23
- 'version': '5.2.6',
23
+ 'version': '5.2.7',
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