-
Notifications
You must be signed in to change notification settings - Fork 61
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
enable contour plots with true minimum #113
Conversation
There was a bug in the initial commits that caused the |
flavio/plots/plotfunctions.py
Outdated
levelsf = [0] + list(levels) | ||
zero_contour = min(np.min(z),np.min(levels)*(1-1e-16)) | ||
levelsf = [zero_contour] + list(levels) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first solution doesn't work if all z
values on the grid are larger than 0
.
The new version works and solves a long-standing issue, namely that an error was produced if any of the levels was actually smaller than the zero_contour
value (which initially was np.min(z)
).
In my opinion it's always safer (as a user) to use keyword arguments when more than 3 or 4 arguments are involved. In fact, this could be enforeced, and any backwards-incompatible ambiguities avoided, by defining def contour(x, y, z, levels, *, z_min, ... although this would prevent calls |
Thanks for the suggestion! I actually didn't know that one can enforce the use of keyword arguments. I think this is really a good solution to avoid backward-incompatible ambiguities. It's now implemented in ecfc66b. |
This PR allows using an exact minimum determined by numerical minimization in contour plots generated by the
flavio.plots.contour
function. To this end, theflavio.plots.likelihood_contour_data
now returns itsz
-values without subtracting the lowestz
-value on the grid.Consequently, the output of
flavio.plots.likelihood_contour_data
is not backward compatible with older versions offlavio.plots.contour
. However, I don't see a reason why one should generate data with the new version but plot this data with an old version.On the other hand,
flavio.plots.contour
is fully backward compatible in the sense that plot data generated by old versions offlavio.plots.likelihood_contour_data
can still be plotted with the new version offlavio.plots.contour
.Furthermore, both
flavio.plots.contour
andflavio.plots.likelihood_contour_data
are backward compatible in the sense that code written for the old versions of these functions will still work with the new versions.(The only exception is calling
flavio.plots.contour
and using the argumentinterpolation_factor
not as a keyword argument. i.e. if the function is called ascontour(x, y, z, levels, interpolation_factor)
instead ofcontour(x, y, z, levels, interpolation_factor=interpolation_factor)
, then this yields unexpected results in the new version since the 5th argument offlavio.plots.contour
now isz_min
. This could be avoided ifz_min
is made the last argument and all other arguments are kept in their previous order. However, I thought thatz_min
might be a rather frequently used argument and function calls likecontour(x, y, z, levels, z_min)
could be convenient. But I am not completely sure about this. @DavidMStraub do you have an opinion on that?)