gtfs_kit 5.2.7__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gtfs-kit
3
- Version: 5.2.7
3
+ Version: 5.2.8
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.7"
15
+ __version__ = "5.2.8"
@@ -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
- f["flag1"] = (
644
- f.agency_id.notna().astype(int)
645
- + f.route_id.notna().astype(int)
646
- + f.trip_id.notna().astype(int)
647
- )
648
- cond = lambda x: x.flag1 > 1
649
- problems = check_table(
650
- problems,
651
- table,
652
- f,
653
- cond,
654
- "At most one of agency_id, route_id, trip_id can be given",
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
- f["flag2"] = (
667
- f.is_producer.fillna(0) + f.is_operator.fillna(0) + f.is_authority.fillna(0)
668
- )
669
- cond = lambda x: x.flag2 < 1
670
- problems = check_table(
671
- problems,
672
- table,
673
- f,
674
- cond,
675
- "At least one of is_producer, is_operator, or is_authority must be 1",
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.7"
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.7',
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