simpeg / geoana

Interactive geoscience (mostly) analytic functions.
MIT License
22 stars 9 forks source link

small fix to catch edge cases in floating point errors. #55

Closed jcapriot closed 1 year ago

jcapriot commented 1 year ago

Was a small undetected edge case in the potential field prism kernels. For example, it occurred when x and z were small relative to a negative y (or y and z were small relative to a negative x). If these values were close to but not exactly 0, the floating point error would cause y + r = 0, thus throwing an error in log(0).

The fix for this is to just skip over when this condition (y + r == 0) happens by first checking the input to the logarithm. I favor this approach opposed to setting an arbitrary threshold on determining small values of x in order to more accurately compute the prism function when all three values (x, y, and z) are small.

codecov[bot] commented 1 year ago

Codecov Report

Merging #55 (0e56855) into main (3d3e021) will decrease coverage by 0.00%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #55      +/-   ##
==========================================
- Coverage   87.51%   87.50%   -0.01%     
==========================================
  Files          29       28       -1     
  Lines        2892     2890       -2     
==========================================
- Hits         2531     2529       -2     
  Misses        361      361              
Impacted Files Coverage Δ
geoana/kernels/potential_field_prism.py 90.38% <100.00%> (+0.48%) :arrow_up:
geoana/__init__.py

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.