Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wrong extracting routes on stop #17

Merged
merged 1 commit into from
May 8, 2024
Merged

fix: wrong extracting routes on stop #17

merged 1 commit into from
May 8, 2024

Conversation

Kanahiro
Copy link
Member

@Kanahiro Kanahiro commented May 8, 2024

Close #16

Description(変更内容)

  • ...

Manual Testing(手動テスト)

Not required / 不要

@Kanahiro Kanahiro merged commit 7f9aa70 into main May 8, 2024
Copy link

coderabbitai bot commented May 8, 2024

Walkthrough

このアップデートでは、GTFSデータの解析を改善するためにいくつかの関数が更新されました。特にデータフレームの結合方法、座標の取り扱い、および停留所パターンの生成が見直されています。これにより、データの処理効率と正確性が向上しています。

Changes

ファイル 変更の概要
gtfs_parser/parse.py データフレームの結合方法の変更、座標の取り扱いのリファクタリング、停留所パターンの生成の再編成
tests/test_parser.py 新しいプライベート関数の追加、特定の機能を探すテストケースの追加

Assessment against linked issues

Objective Addressed Explanation
route_ids in stops.geojson can be nan (#16) 変更の詳細からは、この問題が直接的に対処されたかどうかが不明です。

🐇✨
ぴょんぴょん進化するコードの世界
データ結ぶ糸を紡ぎ直し
新たな道、軽やかに
解析の深みへと跳び込む
春風に乗って、さあ行こう! 🌸🌿
🐰💻


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Kanahiro Kanahiro deleted the fix/route_ids branch May 8, 2024 12:18
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 2cf53f2 and 957bbe2.
Files selected for processing (2)
  • gtfs_parser/parse.py (6 hunks)
  • tests/test_parser.py (1 hunks)
Additional comments not posted (3)
gtfs_parser/parse.py (3)

Line range hint 79-172: read_routes 関数の変更を承認します。


Line range hint 79-116: __read_route_shapes 関数の変更を承認します。


Line range hint 126-162: __read_routes_ignore_shapes 関数の変更を承認します。

Comment on lines +4 to +10
def __find_feature_by(properties, features):
for feature in features:
if all(
feature["properties"].get(key) == value for key, value in properties.items()
):
return feature
return None
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__find_feature_by 関数のリファクタリングを提案します。

-            feature["properties"].get(key) == value for key, value in properties.items()
+            feature["properties"].get(key) == value for key, value in properties.items()  # 明確なコメントを追加

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
def __find_feature_by(properties, features):
for feature in features:
if all(
feature["properties"].get(key) == value for key, value in properties.items()
):
return feature
return None
def __find_feature_by(properties, features):
for feature in features:
if all(
feature["properties"].get(key) == value for key, value in properties.items() # 明確なコメントを追加
):
return feature
return None

Comment on lines +12 to +42

def test_read_stops(gtfs):
stops_features = read_stops(gtfs)
# list of geojson-feature
assert 899 == len(stops_features)

# this feature exists in stops.geojson
feature = {
"type": "Feature",
"geometry": {"type": "Point", "coordinates": [143.203227, 42.918326]},
"properties": {
"stop_id": "1000_04",
"stop_name": "帯広駅バスターミナル",
"route_ids": [
"24_C",
"53_F",
"32_B",
"33_C",
"51_C",
"34_A",
"42_B",
"41_A",
"31_A",
"52_D",
],
},
}

found = __find_feature_by(feature["properties"], stops_features)
assert found is not None

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

テストケースの改善を提案します。

-    assert 899 == len(stops_features)
+    assert len(stops_features) > 0  # ハードコードされた値ではなく、動的なチェックを使用

-    assert found is not None
+    assert isinstance(found, dict)  # foundが辞書型であることを確認

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
def test_read_stops(gtfs):
stops_features = read_stops(gtfs)
# list of geojson-feature
assert 899 == len(stops_features)
# this feature exists in stops.geojson
feature = {
"type": "Feature",
"geometry": {"type": "Point", "coordinates": [143.203227, 42.918326]},
"properties": {
"stop_id": "1000_04",
"stop_name": "帯広駅バスターミナル",
"route_ids": [
"24_C",
"53_F",
"32_B",
"33_C",
"51_C",
"34_A",
"42_B",
"41_A",
"31_A",
"52_D",
],
},
}
found = __find_feature_by(feature["properties"], stops_features)
assert found is not None
def test_read_stops(gtfs):
stops_features = read_stops(gtfs)
# list of geojson-feature
assert len(stops_features) > 0 # ハードコードされた値ではなく、動的なチェックを使用
# this feature exists in stops.geojson
feature = {
"type": "Feature",
"geometry": {"type": "Point", "coordinates": [143.203227, 42.918326]},
"properties": {
"stop_id": "1000_04",
"stop_name": "帯広駅バスターミナル",
"route_ids": [
"24_C",
"53_F",
"32_B",
"33_C",
"51_C",
"34_A",
"42_B",
"41_A",
"31_A",
"52_D",
],
},
}
found = __find_feature_by(feature["properties"], stops_features)
assert isinstance(found, dict) # foundが辞書型であることを確認

Comment on lines +17 to +25
stop_trip_route_df = pd.merge(
gtfs.stop_times[["trip_id", "stop_id"]],
gtfs.trips[["trip_id", "route_id"]],
on="trip_id",
)
stop_route_df = stop_trip_route_df[["stop_id", "route_id"]].drop_duplicates()
route_ids_on_stops = stop_route_df.groupby("stop_id")["route_id"].apply(list).rename("route_ids")

route_ids_on_stops = (
stop_route_df.groupby("stop_id")["route_id"].apply(list).rename("route_ids")
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

read_stops 関数のドキュメントを改善することを提案します。

-        list: [description]
+        list: GeoJSON形式の停留所のリストを返します。`ignore_no_route`がTrueの場合、ルートに接続されていない停留所は除外されます。

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
stop_trip_route_df = pd.merge(
gtfs.stop_times[["trip_id", "stop_id"]],
gtfs.trips[["trip_id", "route_id"]],
on="trip_id",
)
stop_route_df = stop_trip_route_df[["stop_id", "route_id"]].drop_duplicates()
route_ids_on_stops = stop_route_df.groupby("stop_id")["route_id"].apply(list).rename("route_ids")
route_ids_on_stops = (
stop_route_df.groupby("stop_id")["route_id"].apply(list).rename("route_ids")
)
stop_trip_route_df = pd.merge(
gtfs.stop_times[["trip_id", "stop_id"]],
gtfs.trips[["trip_id", "route_id"]],
on="trip_id",
)
stop_route_df = stop_trip_route_df[["stop_id", "route_id"]].drop_duplicates()
route_ids_on_stops = (
stop_route_df.groupby("stop_id")["route_id"].apply(list).rename("route_ids")
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

route_ids in stops.geojson can be nan
1 participant