gtfs_kit 5.2.2__tar.gz → 5.2.5__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.2
3
+ Version: 5.2.5
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
@@ -9,9 +9,10 @@ Author-email: araichev@mrcagney.com
9
9
  Requires-Python: >=3.8,<4
10
10
  Classifier: License :: OSI Approved :: MIT License
11
11
  Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.10
13
12
  Classifier: Programming Language :: Python :: 3.8
14
13
  Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
15
16
  Requires-Dist: folium (>=0)
16
17
  Requires-Dist: geopandas (>=0)
17
18
  Requires-Dist: json2html (>=1)
@@ -19,7 +20,7 @@ Requires-Dist: pandas (>=1)
19
20
  Requires-Dist: pycountry (>=19)
20
21
  Requires-Dist: requests (>=2)
21
22
  Requires-Dist: rtree (>=0)
22
- Requires-Dist: shapely (>=1)
23
+ Requires-Dist: shapely (>=1.8)
23
24
  Requires-Dist: utm (>=0)
24
25
  Project-URL: Documentation, https://mrcagney.github.io/gtfs_kit_docs
25
26
  Project-URL: Repository, https://github.com/mrcagney/gtfs_kit
@@ -27,14 +28,11 @@ Description-Content-Type: text/x-rst
27
28
 
28
29
  GTFS Kit
29
30
  ********
30
- .. image:: https://travis-ci.com/mrcagney/gtfs_kit.svg?branch=master
31
- :target: https://travis-ci.come/mrcagney/gtfs_kit
31
+ .. image:: https://github.com/mrcagney/gtfs_kit/actions/workflows/test.yml/badge.svg
32
32
 
33
33
  GTFS 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.
34
34
  It uses Pandas and Shapely to do the heavy lifting.
35
35
 
36
- This project supersedes `GTFSTK <https://github.com/mrcagney/gtfstk>`_.
37
-
38
36
 
39
37
  Installation
40
38
  =============
@@ -1,13 +1,10 @@
1
1
  GTFS Kit
2
2
  ********
3
- .. image:: https://travis-ci.com/mrcagney/gtfs_kit.svg?branch=master
4
- :target: https://travis-ci.come/mrcagney/gtfs_kit
3
+ .. image:: https://github.com/mrcagney/gtfs_kit/actions/workflows/test.yml/badge.svg
5
4
 
6
5
  GTFS 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.
7
6
  It uses Pandas and Shapely to do the heavy lifting.
8
7
 
9
- This project supersedes `GTFSTK <https://github.com/mrcagney/gtfstk>`_.
10
-
11
8
 
12
9
  Installation
13
10
  =============
@@ -12,4 +12,4 @@ from .validators import *
12
12
  from .feed import *
13
13
 
14
14
 
15
- __version__ = "5.2.2"
15
+ __version__ = "5.2.5"
@@ -864,7 +864,8 @@ def compute_screen_line_counts(
864
864
 
865
865
  Notes:
866
866
 
867
- - Assume the Feed's stop times DataFrame has an accurate ``shape_dist_traveled`` column.
867
+ - Assume the Feed's stop times DataFrame has an accurate ``shape_dist_traveled``
868
+ column.
868
869
  - Assume that trips travel in the same direction as their shapes, an assumption
869
870
  that is part of the GTFS.
870
871
  - Assume that the screen line is straight and simple.
@@ -872,9 +873,9 @@ def compute_screen_line_counts(
872
873
  - The algorithm works as follows
873
874
 
874
875
  1. Find the trip shapes that intersect the screen lines.
875
- 2. For each such shape and screen line, compute the intersection points, the distance
876
- of the point along the shape, and the orientation of the screen line relative to
877
- the shape.
876
+ 2. For each such shape and screen line, compute the intersection points,
877
+ the distance of the point along the shape, and the orientation of the screen
878
+ line relative to the shape.
878
879
  3. For each given date, restrict to trips active on the
879
880
  date and interpolate a stop time for the intersection point using
880
881
  the ``shape_dist_traveled`` column.
@@ -897,10 +898,10 @@ def compute_screen_line_counts(
897
898
  if "screen_line_id" not in screen_lines.columns:
898
899
  screen_lines["screen_line_id"] = hp.make_ids(n, "sl")
899
900
 
900
- # Make a vector in the direction of each screen line to calculate crossing orientation.
901
- # Does not work in case of a bent screen line.
902
- p1 = screen_lines.geometry.map(lambda x: np.array(x.coords[0]))
903
- p2 = screen_lines.geometry.map(lambda x: np.array(x.coords[-1]))
901
+ # Make a vector in the direction of each screen line to calculate crossing
902
+ # orientation. Does not work in case of a bent screen line.
903
+ p1 = screen_lines["geometry"].map(lambda x: np.array(x.coords[0]))
904
+ p2 = screen_lines["geometry"].map(lambda x: np.array(x.coords[-1]))
904
905
  screen_lines["screen_line_vector"] = p2 - p1
905
906
 
906
907
  # Get intersection points of shapes and screen lines
@@ -911,8 +912,8 @@ def compute_screen_line_counts(
911
912
  )
912
913
  # Compute intersection points
913
914
  .assign(
914
- int_point=lambda x: gp.GeoSeries(x.geometry_x, crs=crs).intersection(
915
- gp.GeoSeries(x.geometry_y, crs=crs)
915
+ int_point=lambda x: gp.GeoSeries(x["geometry_x"], crs=crs).intersection(
916
+ gp.GeoSeries(x["geometry_y"], crs=crs)
916
917
  )
917
918
  )
918
919
  )
@@ -923,7 +924,7 @@ def compute_screen_line_counts(
923
924
  if isinstance(row.int_point, sg.Point):
924
925
  intersections = [row.int_point]
925
926
  else:
926
- intersections = row.int_point
927
+ intersections = row.int_point.geoms
927
928
  for int_point in intersections:
928
929
  record = {
929
930
  "shape_id": row.shape_id,
@@ -938,12 +939,12 @@ def compute_screen_line_counts(
938
939
  g.crs = crs
939
940
 
940
941
  # Get distance (in meters) of each intersection point along shape
941
- g["crossing_dist"] = g.apply(lambda x: x.geometry.project(x.int_point), axis=1)
942
+ g["crossing_dist"] = g.apply(lambda x: x["geometry"].project(x.int_point), axis=1)
942
943
 
943
944
  # Build a tiny vector along each shape
944
- p2 = g.apply(lambda x: x.geometry.interpolate(x.crossing_dist + 1), axis=1).map(
945
- lambda x: np.array(x.coords[0])
946
- )
945
+ p2 = g.apply(
946
+ lambda x: x["geometry"].interpolate(x["crossing_dist"] + 1), axis=1
947
+ ).map(lambda x: np.array(x.coords[0]))
947
948
  p1 = g.int_point.map(lambda x: np.array(x.coords[0]))
948
949
  g["shape_vector"] = p2 - p1
949
950
 
@@ -970,13 +971,13 @@ def compute_screen_line_counts(
970
971
 
971
972
  # Get stop times of trips whose shapes lie in h
972
973
  st = (
973
- feed.trips.loc[lambda x: x.shape_id.isin(h.index)]
974
+ feed.trips.loc[lambda x: x["shape_id"].isin(h.index)]
974
975
  # Merge in route short names and stop times
975
976
  .merge(feed.routes[["route_id", "route_short_name"]]).merge(feed.stop_times)
976
977
  # Keep only non-NaN departure times
977
- .loc[lambda x: x.departure_time.notna()]
978
+ .loc[lambda x: x["departure_time"].notna()]
978
979
  # Convert to seconds past midnight
979
- .assign(departure_time=lambda x: x.departure_time.map(hp.timestr_to_seconds))
980
+ .assign(departure_time=lambda x: x["departure_time"].map(hp.timestr_to_seconds))
980
981
  )
981
982
 
982
983
  # Compute crossing times by date
@@ -985,15 +986,13 @@ def compute_screen_line_counts(
985
986
  for date in dates:
986
987
  # Subset to trips active on date and merge with g
987
988
  ids = ta.loc[lambda x: x[date] == 1, "trip_id"]
988
- f = st.loc[lambda x: x.trip_id.isin(ids)].sort_values(
989
+ f = st.loc[lambda x: x["trip_id"].isin(ids)].sort_values(
989
990
  ["trip_id", "shape_dist_traveled"]
990
991
  ) # Need this sorting for interpolation to work
991
992
 
992
993
  # Get crossing time for each trip
993
994
  for tid, group in f.groupby("trip_id"):
994
995
  sid = group["shape_id"].iat[0]
995
- rid = group["route_id"].iat[0]
996
- rsn = group["route_short_name"].iat[0]
997
996
  dists = group["shape_dist_traveled"].values
998
997
  times = group["departure_time"].values
999
998
  crossing_dists = h.loc[[sid], "crossing_dist"].values
@@ -1002,9 +1001,9 @@ def compute_screen_line_counts(
1002
1001
  record = {
1003
1002
  "date": date,
1004
1003
  "trip_id": tid,
1005
- "route_id": group.route_id.iat[0],
1006
- "route_short_name": group.route_short_name.iat[0],
1007
- "shape_id": group.shape_id.iat[0],
1004
+ "route_id": group["route_id"].iat[0],
1005
+ "route_short_name": group["route_short_name"].iat[0],
1006
+ "shape_id": group["shape_id"].iat[0],
1008
1007
  "screen_line_id": row.screen_line_id,
1009
1008
  "crossing_direction": row.crossing_direction,
1010
1009
  "crossing_distance": row.crossing_dist,
@@ -1013,7 +1012,7 @@ def compute_screen_line_counts(
1013
1012
  records.append(record)
1014
1013
 
1015
1014
  result = pd.DataFrame.from_records(records).assign(
1016
- crossing_time=lambda x: x.crossing_time.map(
1015
+ crossing_time=lambda x: x["crossing_time"].map(
1017
1016
  lambda x: hp.timestr_to_seconds(x, inverse=True)
1018
1017
  )
1019
1018
  )
@@ -724,21 +724,13 @@ def geometrize_routes(
724
724
  d["geometry"] = so.linemerge(group.geometry.tolist())
725
725
  return pd.Series(d)
726
726
 
727
- if use_utm:
728
- lat, lon = feed.shapes[["shape_pt_lat", "shape_pt_lon"]].values[0]
729
- crs = hp.get_utm_crs(lat, lon)
730
- else:
731
- crs = cs.WGS84
732
-
733
727
  return (
734
728
  feed.geometrize_trips(trip_ids, use_utm=use_utm)
735
729
  .filter(["route_id", "direction_id", "geometry"])
736
- # GeoDataFrame disappears here
737
730
  .groupby(groupby_cols)
738
731
  .apply(merge_lines)
739
732
  .reset_index()
740
733
  .merge(feed.routes)
741
- .pipe(gp.GeoDataFrame, crs=crs)
742
734
  )
743
735
 
744
736
 
@@ -77,18 +77,22 @@ def geometrize_shapes_0(
77
77
 
78
78
  If ``use_utm``, then use local UTM coordinates for the geometries.
79
79
  """
80
- f = shapes.copy().sort_values(["shape_id", "shape_pt_sequence"])
81
80
 
82
81
  def my_agg(group):
83
82
  d = {}
84
83
  d["geometry"] = sg.LineString(group[["shape_pt_lon", "shape_pt_lat"]].values)
85
84
  return pd.Series(d)
86
85
 
87
- g = f.groupby("shape_id").apply(my_agg).reset_index()
88
- g = gp.GeoDataFrame(g, crs=cs.WGS84)
86
+ g = (
87
+ shapes.sort_values(["shape_id", "shape_pt_sequence"])
88
+ .groupby("shape_id", sort=False)
89
+ .apply(my_agg)
90
+ .reset_index()
91
+ .pipe(gp.GeoDataFrame, crs=cs.WGS84)
92
+ )
89
93
 
90
94
  if use_utm:
91
- lat, lon = f[["shape_pt_lat", "shape_pt_lon"]].values[0]
95
+ lat, lon = shapes[["shape_pt_lat", "shape_pt_lon"]].values[0]
92
96
  crs = hp.get_utm_crs(lat, lon)
93
97
  g = g.to_crs(crs)
94
98
 
@@ -190,7 +194,7 @@ def get_shapes_intersecting_geometry(
190
194
  geometry: sg.base.BaseGeometry,
191
195
  shapes_g: Optional[gp.GeoDataFrame] = None,
192
196
  *,
193
- geometrized: bool = False
197
+ geometrized: bool = False,
194
198
  ) -> pd.DataFrame:
195
199
  """
196
200
  Return the subset of ``feed.shapes`` that contains all shapes that
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "gtfs_kit"
3
- version = "5.2.2"
3
+ version = "5.2.5"
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"
@@ -12,7 +12,7 @@ exclude = ["tests", "docs"]
12
12
  [tool.poetry.dependencies]
13
13
  python = ">=3.8, <4"
14
14
  pandas = ">=1"
15
- shapely = ">=1"
15
+ shapely = ">=1.8"
16
16
  pycountry = ">=19"
17
17
  utm = ">=0"
18
18
  json2html = ">=1"
@@ -21,18 +21,29 @@ rtree = ">=0"
21
21
  folium = ">=0"
22
22
  requests = ">=2"
23
23
 
24
- [tool.poetry.dev-dependencies]
24
+ [tool.poetry.group.dev.dependencies]
25
25
  jupyter = "*"
26
26
  pytest = ">=6"
27
27
  sphinx = ">=3"
28
28
  pre-commit = ">=0"
29
- black = ">22"
30
- publish_sphinx_docs = ">=1.0"
31
29
  matplotlib = ">=1"
32
30
  pytest-socket = ">=0"
31
+ black = ">22"
33
32
  nbstripout = ">=0.5"
33
+ ruff = ">=0.0.257"
34
+ publish_sphinx_docs = ">=1.0"
34
35
 
35
36
  [build-system]
36
37
  requires = ["poetry>=1"]
37
38
  build-backend = "poetry.masonry.api"
38
39
 
40
+ [tool.pytest.ini_options]
41
+ markers = [
42
+ "slow: marks tests as slow (deselect with '-m \"not slow\"')",
43
+ "serial",
44
+ ]
45
+
46
+ [tool.ruff]
47
+ # Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
48
+ select = ["E", "F"]
49
+ ignore = ["F403"]
@@ -0,0 +1,38 @@
1
+ # -*- coding: utf-8 -*-
2
+ from setuptools import setup
3
+
4
+ packages = \
5
+ ['gtfs_kit']
6
+
7
+ package_data = \
8
+ {'': ['*']}
9
+
10
+ install_requires = \
11
+ ['folium>=0',
12
+ 'geopandas>=0',
13
+ 'json2html>=1',
14
+ 'pandas>=1',
15
+ 'pycountry>=19',
16
+ 'requests>=2',
17
+ 'rtree>=0',
18
+ 'shapely>=1.8',
19
+ 'utm>=0']
20
+
21
+ setup_kwargs = {
22
+ 'name': 'gtfs-kit',
23
+ 'version': '5.2.5',
24
+ 'description': 'A Python 3.8+ library for analyzing GTFS feeds.',
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
+ 'author': 'Alex Raichev',
27
+ 'author_email': 'araichev@mrcagney.com',
28
+ 'maintainer': 'None',
29
+ 'maintainer_email': 'None',
30
+ 'url': 'https://github.com/mrcagney/gtfs_kit',
31
+ 'packages': packages,
32
+ 'package_data': package_data,
33
+ 'install_requires': install_requires,
34
+ 'python_requires': '>=3.8,<4',
35
+ }
36
+
37
+
38
+ setup(**setup_kwargs)
gtfs_kit-5.2.2/setup.py DELETED
@@ -1,38 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- from setuptools import setup
3
-
4
- packages = \
5
- ['gtfs_kit']
6
-
7
- package_data = \
8
- {'': ['*']}
9
-
10
- install_requires = \
11
- ['folium>=0',
12
- 'geopandas>=0',
13
- 'json2html>=1',
14
- 'pandas>=1',
15
- 'pycountry>=19',
16
- 'requests>=2',
17
- 'rtree>=0',
18
- 'shapely>=1',
19
- 'utm>=0']
20
-
21
- setup_kwargs = {
22
- 'name': 'gtfs-kit',
23
- 'version': '5.2.2',
24
- 'description': 'A Python 3.8+ library for analyzing GTFS feeds.',
25
- 'long_description': "GTFS Kit\n********\n.. image:: https://travis-ci.com/mrcagney/gtfs_kit.svg?branch=master\n :target: https://travis-ci.come/mrcagney/gtfs_kit\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\nThis project supersedes `GTFSTK <https://github.com/mrcagney/gtfstk>`_.\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
- 'author': 'Alex Raichev',
27
- 'author_email': 'araichev@mrcagney.com',
28
- 'maintainer': None,
29
- 'maintainer_email': None,
30
- 'url': 'https://github.com/mrcagney/gtfs_kit',
31
- 'packages': packages,
32
- 'package_data': package_data,
33
- 'install_requires': install_requires,
34
- 'python_requires': '>=3.8,<4',
35
- }
36
-
37
-
38
- setup(**setup_kwargs)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes