-
Notifications
You must be signed in to change notification settings - Fork 17
Description
numpy arrays can have either row- or column-major layouts. We currently handle these layouts inconsistently, and this is an ongoing source of confusion.
Here is how things should behave:
- libtopotoolbox functions should be agnostic to the memory layout of their arguments.
- libtopotoolbox functions should iterate in "column-major" order. Really this means iterating over the fastest-changing dimension first, and otherwise the dimensions shouldn't matter too much. You do have to swap the order of the dimensions if you pass a row-major array.
dem.shapeshould return(rows, columns)for every array, regardless of its memory order, just as numpy arrays.dem.dimsshould return(rows, columns)for column-major ('F') arrays and(columns, rows)for row-major ('C') arrays.- pytopotoolbox should pass
dem.dimsrather thandem.shapeto libtopotoolbox. StreamObjectandFlowObjectrefer to their nodes with 0-based linear indices in column-major order.
The one major exception here is for graphflood, because I don't think we were very careful about matching it to the other libtopotoolbox functions. Correct me if I am wrong, @bgailleton, but I think it works kind of the same way as the other libtopotoolbox functions, but the dim arguments are reversed relative to the libtopotoolbox -- (rows, columns) for row-major and (columns, rows) for column-major.
I am noticing that the addition of the dims argument did not propagate to every libtopotoolbox function in pytopotoolbox.
I have added subissues for tasks that we need to fix these problems.