Skip to content

Commit

Permalink
Merge pull request #17 from transferwise/feature/return_fig
Browse files Browse the repository at this point in the history
added return_fig for streamlit
  • Loading branch information
AlxdrPolyakov authored Aug 2, 2023
2 parents bea707f + da2be48 commit 22eb6a3
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 30 deletions.
63 changes: 36 additions & 27 deletions notebooks/Finding interesting segments.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions wise_pizza/explain.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ def explain_levels(
s["total"] += average * s["seg_size"]
# print(average)
sf.reg.intercept_ = average
sf.plot = lambda plot_is_static=False, width=2000, height=500: plot_segments(
sf, plot_is_static=plot_is_static, width=width, height=height
sf.plot = lambda plot_is_static=False, width=2000, height=500, return_fig=False: plot_segments(
sf, plot_is_static=plot_is_static, width=width, height=height, return_fig=return_fig
)
sf.task = "levels"
return sf
6 changes: 5 additions & 1 deletion wise_pizza/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def plot_segments(
plot_is_static: bool = False,
width: int = 2000,
height: int = 500,
return_fig: bool = False
):
"""
Plot segments for explain_levels
Expand Down Expand Up @@ -210,7 +211,10 @@ def plot_segments(
width=width + len(sf.segment_labels) * 30,
)
else:
fig.show()
if return_fig:
return fig
else:
fig.show()


def waterfall_args(sf: SliceFinder):
Expand Down

0 comments on commit 22eb6a3

Please sign in to comment.