harmonica icon indicating copy to clipboard operation
harmonica copied to clipboard

Catch numba errors about mixing int and float in forward modelling

Open leouieda opened this issue 4 years ago • 2 comments

Description of the desired feature

Our forward modelling code (harmonica/forward/) uses numba to speed up computations. It can be a bit picky about input data types and doesn't like it when we mix integers and floats. So specifying a tesseroid with [10, 20, 0, 15, 1000, 1200] will cause an error from numba about mixing int64 and float64. The actual error message is ugly, intimidating, and hard to read for non-experts. It would be better if we caught the exception in a try:... except:... block and added some more user friendly messages to it, explaining that this is probably due to mixing ints and floats in inputs and providing possible solutions (casting input arrays to float, for example).

For testing, it would help to first make a test that passes ints to the functions and verifies that they actually fail (so if numba ever stops raising these errors we can remove the code that catches them).

leouieda avatar Oct 11 '19 10:10 leouieda

I want to pick this issue up, but I'm not sure what error are we talking about? From what I see no prisms or tesseroids comprised of integers raise any errors, as that would cause some of the tests to fail.

Sorry for the ignorance, but could you please elaborate?

ziebam avatar Oct 11 '19 16:10 ziebam

From what I see no prisms or tesseroids comprised of integers raise any errors, as that would cause some of the tests to fail.

This is one of those things that seem to happen when the planets align :) But try changing one of the tesseroid tests to use integers. The reason why they are all 10.0 etc is to avoid this issue.

leouieda avatar Oct 14 '19 15:10 leouieda