Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systematic treatment of floating point warnings from numpy #482

Open
sergpolly opened this issue Jan 18, 2024 · 0 comments
Open

systematic treatment of floating point warnings from numpy #482

sergpolly opened this issue Jan 18, 2024 · 0 comments

Comments

@sergpolly
Copy link
Member

sergpolly commented Jan 18, 2024

it would be worth considering a systematic treatment of floating-point related warnings - division by zero and invalid operation pollute output too much - esp whenever obs/exp is involved - classification of float-point errors https://docs.oracle.com/cd/E19957-01/806-3568/ncg_handle.html

  1. consider using (on a per module basis ... or in __init__ or wherever)
# set new err-stated, to hide division by zero warnings
_err_state = np.seterr(divide="ignore", over="raise", under="warn", invalid="ignore")
  1. or use a conext manager https://numpy.org/devdocs/reference/generated/numpy.errstate.html for every obs/exp (and other relevant operations) - not sure if there is a big performance penalty associated with it ...
with np.errstate(divide="ignore", invalid="ignore"):
    snippet / e
  1. or use np.dividehttps://numpy.org/doc/stable/reference/generated/numpy.divide.html with the where filter engaged - to pre-emptively fill those anything/0.0 with np.nan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant