Closed Datseris closed 9 months ago
Okay, in PR #101 I've removed the storage of visited cells, but all tests went to hell. So maybe we use them somewhere? But I can't tell where.
(hence, one more reason for PR #101 . The source code needs to clarify these things)
Hi! This is a queue to optimize the cleaning of the basins matrix. Once the algorithm is finished, all the cells that have not been labeled as a basin or as an attractor are wipped from the matrix. Instead of searching for these labels in the matrix you store the visited cells in a queue and set these entries to zero.
This optimization is crucial for the speed of the algorithm. But there are surely better ways to name these functions, something like basins_cleanup
.
Aaaaaaaah now I understand.... Okay, I'll put this as a comment in #101 because I couldn't understand this.
cc @awage
Why does
BasinInfo
contain a fieldvisited_list::Vector{CartesianIndex{D}}
? Is this used anywhere? I am reading the source code but I don't understand if it is used anywhere.THe only point in the source code that
.visited_list
is populated with cells is here:There are only 2 sections in the source code where
.visited_list
is called, and they are both the same function call:which calls the function:
There are two things I notice:
old_label
can never be the same asnew_label
, as the visited cells by definition have label at least 4, whilenew_label
is always0
given how we call the function.So, @awage, do we actually need the
visited_list
? I don't see how. Seems to me like we are wasting computations by storing, and then removing the visited cells, without actually using them anywhere!