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

68 path optional plot forecast #71

Merged
merged 5 commits into from
Oct 16, 2018
Merged

Conversation

slenas
Copy link
Contributor

@slenas slenas commented Oct 15, 2018

closes #68

@slenas slenas added the enhancement New feature or request label Oct 15, 2018
@slenas slenas requested a review from bezes October 15, 2018 16:45
@capelastegui capelastegui self-requested a review October 15, 2018 17:41
def plot_forecast(df_fcast, path, output='html', width=None,
height=None, title=None, dpi=70, show_legend=True,
auto_open=False):
def plot_forecast(df_fcast, output, path, width=None, height=None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we have path=None here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought a bit about this yesterday, but I'm not sure that have path=None is the right approach, as when using None that usually means that it is not needed in most cases or it defaults to some value within the code if not provided. This is not the case in plot_forecast as the value of "path" is related to the value of "output", so it's up to the user to define exactly what he wants. That's why I also changed the order as it makes more sense to me.

Copy link
Contributor

@bezes bezes Oct 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have explained the issue better. I raised it when I wanted to plot in a jupyter notebook and I got an error for missing parameters. The fact that I had to add plot=None was counter-intuitive.

So the idea was to make path optional, which means adding path=None in the function signature, as @capelastegui suggests.

Edit: Changing the order of input parameters is a matter of style and not relevant in this issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm ok, I see. I'll proceed with the change then.

Copy link
Contributor

@capelastegui capelastegui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I'm mistaken, the purpose of #68 is to change the signature of plot_forecast to plot_forecast(df_fcast, output, path=None, ...) . Once we add that, I think everything is OK

Copy link
Contributor

@bezes bezes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's the idea @capelastegui. And input checks too.

@slenas
Copy link
Contributor Author

slenas commented Oct 16, 2018

@capelastegui @bezes guys could you please check my reply above and comment? As I'm seeing it, for me "path" is not exactly an optional parameter...

@@ -334,12 +333,13 @@ def plot_forecast(df_fcast, path, output='html', width=None,
| - date (timestamp)
| - model (str) : ID for the forecast model
| - y (float) : Value of the time series in that sample
| - is_actuals (bool) : True for actuals samples, False for forecasted samples # noqa
| - is_actuals (bool) : True for actuals samples, False for
| forecasted samples # noqa
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove #noqa here, it's for ignoring PEP8 long line warning

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should raise a different issue to fix any docstrings that need fixing.

@codecov-io
Copy link

codecov-io commented Oct 16, 2018

Codecov Report

Merging #71 into master will increase coverage by 0.04%.
The diff coverage is 71.42%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #71      +/-   ##
==========================================
+ Coverage   84.85%   84.89%   +0.04%     
==========================================
  Files           6        6              
  Lines        1373     1377       +4     
==========================================
+ Hits         1165     1169       +4     
  Misses        208      208
Impacted Files Coverage Δ
anticipy/app.py 0% <0%> (ø) ⬆️
anticipy/forecast_plot.py 87.83% <83.33%> (+0.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update abf4620...0475258. Read the comment docs.

@@ -375,6 +375,10 @@ def plot_forecast(df_fcast, path, output='html', width=None,
fig = _matplotlib_forecast_create(df_fcast, subplots, sources,
nrows, ncols, width, height,
title, dpi, show_legend)
if path is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't cover the empty string path=''. I think it's better to check if not path:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. Good catch!

@@ -393,6 +397,10 @@ def plot_forecast(df_fcast, path, output='html', width=None,
fig = _plotly_forecast_create(df_fcast, subplots, sources, nrows,
ncols, width, height, title,
show_legend)
if path is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

@@ -357,6 +357,10 @@ def plot_forecast(df_fcast, path, output='html', width=None,

assert isinstance(df_fcast, pd.DataFrame)

if not path and (output == 'html' or output == 'png'):
logger.error('No export path provided.')
return 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks and done!

@bezes bezes merged commit 2856f6b into master Oct 16, 2018
@bezes bezes deleted the 68-path_optional_plot_forecast branch October 16, 2018 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make path an optional input variable in forecast_plot.plot_forecast()
4 participants