forked from caoji2001/HOSER
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Problem
The generate_trajectories_programmatic function in gene.py currently only supports sampling OD pairs from the dataset. However, tools/generate_abnormal_od.py and python_pipeline.py are calling it with parameters that don't exist:
num_generate(should benum_gene)od_list(doesn't exist - function samples instead)output_file(doesn't exist - function creates its own output path)
This causes TypeError: generate_trajectories_programmatic() got an unexpected keyword argument 'num_generate' when running the abnormal OD workflow.
Current Behavior
The function currently:
- Samples OD pairs from dataset based on
od_sourceandnum_gene - Uses
od_to_train_indicesorod_to_test_indicesto get timestamps - Generates trajectories for sampled pairs
- Creates output file with auto-generated path
Desired Behavior
Extend the function to support:
- Custom OD pairs: Accept optional
od_listparameter (List[Tuple[int, int]]) - Custom output path: Accept optional
output_fileparameter (Path or str) - Backward compatibility: When
od_listis None, use current sampling behavior - Validation: Validate that custom OD pairs are valid (destinations are reachable)
Use Cases
- Abnormal OD workflow: Generate trajectories for specific abnormal OD pairs
- Targeted testing: Test models on specific challenging OD pairs
- Cross-dataset evaluation: Generate for OD pairs from different dataset
Implementation Approach
- Add optional parameters:
od_list: Optional[List[Tuple[int, int]]] = None,output_file: Optional[Union[Path, str]] = None - When
od_listis provided, use it instead of sampling - When
output_fileis provided, use it instead of auto-generating path - Validate custom OD pairs against reachable destinations
- Handle timestamp selection for custom OD pairs (use fallback if OD not in dataset)
Testing
Create comprehensive pytest tests in tests/test_generate_trajectories_programmatic.py:
- Test function signature and parameter validation
- Test backward compatibility (sampling mode)
- Test custom OD pairs mode
- Test custom output file path
- Test validation of invalid OD pairs
- Test integration with abnormal OD workflow
Related Code
gene.py:1821-generate_trajectories_programmaticfunctiontools/generate_abnormal_od.py:139- Current incorrect callpython_pipeline.py:1867- Another incorrect call
Metadata
Metadata
Assignees
Labels
No labels