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 #8450: work around unplottable points in plot_vector_field().
Now that many of our plotting functions are using fast_callable() WITHOUT domain=float to support complex numbers that appear in intermediate computations, we need to work around some plot points that used to be NaN (as a result of domain=float) but now throw errors as we try to compute them. One such instance is in plot_vector_field(), where the lines xvec_array.append(f(x, y)) and yvec_array.append(g(x, y)) can fail to evaluate either f or g. This commit adds two try/except blocks to catch ValueError (calling math.sqrt on a negative number) and ZeroDivisionError (function undefined at some point), and turn them into NaN. The hope is that this leaves the behavior unchanged, since domain=float would have forced these evaluations to return NaN in the past.
- Loading branch information