This repository has been archived by the owner on Jan 30, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trac #24536: factor out a FastCallableFloatWrapper class from plots.
We have a few numerical methods that run into trouble in certain situations: 1. When the objective function is symbolic and contains complex sub-expressions, the real fast_callable() wrapper can't handle the (intermediate) complex results. 2. When the function evaluations can technically be complex, but the imaginary parts are essentially numerical noise. Our plotting infrastructure had the same problems, and we worked around it by (a) using complex fast_callable() wrappers instead of real ones, and (b) adding *another* wrapper around each fast-callable. The so-called FastCallablePlotWrapper ignores imaginary noise, but returns NaN if the result is truly complex -- the end result being that complex results are "skipped" while plotting. A similar solution should work for other numerical methods, but we don't want to ignore complex results if we're trying to e.g. minimize a function that is supposed to return real numbers. So instead of using the existing FastCallablePlotWrapper, this commit factors out a superclass called FastCallableFloatWrapper that works just like the plot wrapper except that it raises an error when it sees a complex result from the underlying fast_callable().
- Loading branch information
Showing
2 changed files
with
158 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters