EMob-Lab / EMob-Lab/gpsmatcher
Ensure Unique File Names for Cached Transition Matrix Based on Input Parameters
- Dominant language
- Python
- Stars
- 10
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
**Problem:**
The current caching logic for loading a `transition_matrix` from a file does not guarantee uniqueness between different sets of input parameters. The file `transition_matrix.pickle` is reused regardless of which input graph or parameters were used to generate the matrix. This can lead to collisions where an incorrect transition matrix is loaded, as it doesn't necessarily correspond to the current input set.
[Relevant code](https://github.com/lbonnetain/gpsmatcher/blob/2dfcd05767d8719e2ec8f3c932a0fc2a009143d7/gpsmatcher/transition.py#L107-L109):
```python
if save and (os.path.isfile(folder_name + '/transition_matrix.pickle')):
transition_matrix = load_param(folder_name, "transition_matrix", show_print=show_print)
return(transition_matrix)
```
**Expected Behavior:**
The cached `transition_matrix` file should be unique to the specific input graph and any other parameters that affect its calculation. This will prevent conflicts when different sets of parameters generate different matrices, but are mistakenly loaded from the same cache file.
**Suggested Solution:**
- Introduce a method to generate a unique file name based on a hash or identifier that captures the state of the input graph and parameters.
- This file name can be used to save and load the transition matrix, ensuring correct retrieval based on the current input set.
**Benefits:**
- Prevents incorrect loading of cached data.
- Increases robustness of caching mechanism for different parameter sets.
Let me know if you'd like further clarification or assistance in implementing this change.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.