Skip to content

Commit

Permalink
PERF: Replace isclose() comparison with explicit bounds
Browse files Browse the repository at this point in the history
Rather than using isclose() we can directly compare against the
expected values using array indexing.
  • Loading branch information
greglucas committed Nov 15, 2024
1 parent 6f8d2d7 commit 0471f96
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pymsis/msis.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,8 @@ def run(
)

# The Fortran code puts 9.9e-38 in as NaN
# Have to make sure this doesn't overlap 0 due to really small values
# so atol should be less than the comparison value
output[np.isclose(output, 9.9e-38, atol=1e-38)] = np.nan
# or 9.99e-38, or 9.999e-38, so lets just bound the 9s
output[(output >= 9.9e-38) & (output < 1e-37)] = np.nan # noqa: PLR2004

return output.reshape(*input_shape, 11)

Expand Down

0 comments on commit 0471f96

Please sign in to comment.