Circuitscape.py
Circuitscape.py copied to clipboard
Handle memory errors with appropriate message
Amy Guthrie's problem posted to the user group caused memory errors in compute_base at the line:
G = -G + sparse.spdiags(G.sum(0), 0, n, n)
However, the code interprets this as a solver failure and does not provide a memory error message. Not sure why this continued execution, it may be wrapped in a try-except statement in a calling function. Best way to handle this would be to give our standard memory error with recommendation to see the user guide (as done in gui.py).
I was unable to trace the path where a memory error in laplacian would be ignored. The stack trace posted in the user_group pointed to methods _create_current_maps and _get_branch_currents_posneg, don't they?
Plus, I don't think we elegantly handle MemoryErrors in parallel execution yet.
There were errors happening in two places- one of them was the stack trace when it tried to write current maps (i.e. the code behaved as it should here I think). The other was just being reported as a solver failure. When I tested Amy's problem, the line in laplacian was where errors were occurring, but these were just being reported as solver failures. When I wrapped that line in a try... except memoryError statement it caught it fine.
I hadn't thought about memory errors in parallel. Ouch, that makes my head hurt.