Skip to content

Fix UnboundLocalError for all_mappings in run_pdm_score.py - #193

Open
dhruvildarji wants to merge 1 commit into
autonomousvision:mainfrom
dhruvildarji:fix/unbound-local-error-pdm-score
Open

Fix UnboundLocalError for all_mappings in run_pdm_score.py#193
dhruvildarji wants to merge 1 commit into
autonomousvision:mainfrom
dhruvildarji:fix/unbound-local-error-pdm-score

Conversation

@dhruvildarji

Copy link
Copy Markdown

Summary

  • Fixes UnboundLocalError: local variable 'all_mappings' referenced before assignment in run_pdm_score.py
  • When reactive_all_mapping config key is missing, the except block now initializes all_mappings = {} so downstream code (calculate_individual_mapping_scores) doesn't crash

Fixes #182

Changes

In navsim/planning/script/run_pdm_score.py, added all_mappings = {} to the except block (line 386) that handles the missing reactive_all_mapping configuration key. Previously, all_mappings was only assigned inside the try block, causing an UnboundLocalError when the exception path was taken.

Test plan

  • Run run_pdm_score.py with a split that lacks reactive_all_mapping (e.g., navtest_two_stage) and confirm it completes without crashing

Initialize `all_mappings = {}` in the except block so that when
`reactive_all_mapping` config key is missing, the variable is still
defined for downstream usage in `calculate_individual_mapping_scores`.

Fixes autonomousvision#182

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

UnboundLocalError: local variable 'all_mappings' referenced before assignment in run_pdm_score.py

1 participant