BlueBrain / BlueBrain/Atlas-Download-Tools
Avoid recomputatation of `transformation` inside of `DisplacementField.warp`
- Dominant language
- Python
- Stars
- 17
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
Whenever one calls `warp` the transformation needs to be computed from the displacements.
https://github.com/BlueBrain/Atlas-Download-Tools/blob/60f0221916f4f9987a4728807be0b37934784cd0/src/atldld/base.py#L319
This operation requires `np.meshgrid` or `np.indices` and can be costly for big shapes. Anyway, the `DisplacementField` should be immutable and it should be enough to compute the transformation once.
### Some ideas
* LRU cache
* Explicit caching `e.g. (self._tx, self._ty)`
* Optionally pass it in the constructor (assuming it was computed already)
### Why relevant?
The primary example is when we download both the section and the expression image. We use the same `DisplacementField` to warp them, however, `transformation` is computed twice.
Contributor guide
Research direction
Start at src/atldld/base.py around line 319 and inspect DisplacementField.warp and how transformation is computed with np.meshgrid or np.indices. Compare repeated warps using the same field; done means an immutable DisplacementField reuses one computed transformation for both operations without changing warp results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- performance
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100