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

set numpy floating point error level to ignore. #238

Merged
merged 2 commits into from
Mar 19, 2019

Conversation

pkofod
Copy link
Contributor

@pkofod pkofod commented Mar 14, 2019

@llorracc this should do the job. It ignores the floating point exceptions. Currently we only warn anyway, so it's not like we're handling it.

The exceptions aren't really errors either as numpy calls them. They're well-defined operations that give useful answers. Things such as -1/-np.inf gives 0. This is very useful in DCEGM to interpolate from the lowest value to the first values of the resource grid that is not 0. It could be special handled, but this is implemented all the way down to the hardware level, so I don't see why we shouldn't just use it.

For release notes
Several procedures in HARK actively take advantage of floating point behavior of np.inf's, division by zero and more. The default behavior in Numpy is to throw warnings in this case. These only risk confusing users who know little of floating point numbers, and so we turn them off in central methods used throughout HARK.

@mnwhite
Copy link
Contributor

mnwhite commented Mar 14, 2019

One line added, other line changes are whitespace removal.

Does this need to be in our other files where numpy is imported, or does this act on numpy everywhere in the code?

@pkofod
Copy link
Contributor Author

pkofod commented Mar 14, 2019

One line added, other line changes are whitespace removal.

Ah yes, that's my editor stripping white space at the end.

Does this need to be in our other files where numpy is imported, or does this act on numpy everywhere in the code?

I tried using the REMARK PR notebook with this branch, and the errors were gone even in functions defined outside of HARK. I wonder though if this also means that if you check out two packages, one being HARK and the other being, say, pandas, you'll also change the setting of pandas?

@mnwhite
Copy link
Contributor

mnwhite commented Mar 14, 2019 via email

@pkofod
Copy link
Contributor Author

pkofod commented Mar 14, 2019

Then we can just turn it in and off at the beginning and end of a solve call?

@mnwhite
Copy link
Contributor

mnwhite commented Mar 14, 2019 via email

@pkofod
Copy link
Contributor Author

pkofod commented Mar 14, 2019

Yeah, maybe solve, simulate, and update? The "major" AgentType operations where lots of work is done inside of HARK?

I'll try that instead.

…instead, as these will automatically reset upon exit.
@pkofod
Copy link
Contributor Author

pkofod commented Mar 19, 2019

How's this @mnwhite ? It uses error states instead, so every code in that with block should have those error setings. I need to run the notebooks to make sure, but I'm fairly sure this works as intended.

This last commit sets the error state for solve and simulate.

A side-question: I tried to "hide" the white space changes. When you look at the diff, do they still show up?

@mnwhite
Copy link
Contributor

mnwhite commented Mar 19, 2019

The whitespace changes show up on github.com's diff display, but I don't actually care. My comment was a note to self that there was only one line added, explaining why I was about to merge a PR with X hundred "line changes" a few minutes after it was submitted (my finger was hovering over the Merge button).

@mnwhite mnwhite merged commit 10482e7 into econ-ark:master Mar 19, 2019
@shaunagm
Copy link
Contributor

Hi @pkofod, I'm going through PRs and adding a "needs release notes" label. Can you provide a one sentence summary of your changes, ideally by editing the issue itself (as opposed to leaving a comment), clearly labeled with "For release notes" or similar? Remember to specify if there are breaking changes in the PR.

I'm not going to leave a comment like this on every merged PR of yours, but you can find a full list (well, full once I'm done tagging) here.

@pkofod pkofod deleted the numpyfloatingpointerror branch March 22, 2019 11:43
@llorracc
Copy link
Collaborator

llorracc commented Apr 4, 2019

For release notes: "Suppress some worrisome but meaningless warning messages"

@llorracc
Copy link
Collaborator

Release note: Removed inappropriately scary warnings about non-problems

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

Successfully merging this pull request may close these issues.

4 participants