Repository navigation
Fix plot_plotly raising ValueError on every call - #2796
omkarbandikatte wants to merge 1 commit into
Conversation
assert m.history and assert m.changepoints call bool() on a DataFrame and a Series, which pandas rejects. Check for None instead, as the other asserts in plot.py do, and add a test that calls plot_plotly.
|
Hi @omkarbandikatte! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
plot_plotlyraises aValueErrorfor any fitted model, before it draws anything:m.historyis a DataFrame, and pandas refuses to turn a DataFrame into a bool. The same applies further down toassert m.changepoints, which is a Series, so fixing only the first line moves the error to line 829. Both asserts came in with the type annotations in #2720, so this affects 1.4.0 and later; I reproduced it with 1.5.0 from PyPI and onmain.plot_components_plotlyis not affected.This changes both asserts to
is not None, the form the other asserts inplot.pyalready use (for exampleassert m.changepoints is not Noneinadd_changepoints_to_plot).Testing
The existing plotly tests only call the
get_*_plotly_propshelpers, so nothing calledplot_plotlyitself. I addedTestPlotPlotly.test_draws_forecasttopython/prophet/tests/test_plot.py. It uses the existingmodel_and_forecastfixture, callsplot_plotlywithtrend=True, changepoints=True, and checks that the actual, predicted, trend and changepoint traces match the model and the forecast.additive,multiplicative_logistic) fail with the error above.test_plot.pypasses (22 tests), and so does the rest ofpython/prophet/tests(144 passed, 2 skipped).