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

FIX: used to try to show a dataframe as a plot, broke if two analyses… #286

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion alphastats/gui/pages/04_Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def select_analysis():

plot_to_display = False
df_to_display = False
method_plot = None

with c1:

Expand Down Expand Up @@ -196,7 +197,7 @@ def select_analysis():
with col3:
download_preprocessing_info(method_plot)

elif analysis_result is not None and df_to_display:
elif analysis_result is not None and df_to_display and method_plot:
col1, col2, col3 = st.columns([1, 1, 1])

with col1:
Expand Down
27 changes: 15 additions & 12 deletions alphastats/gui/pages/06_Results.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ def display_plotly_figure(plot):
st.plotly_chart(plot)


def save_plotly(plot, format):
def save_plotly(plot, name, format):
# Create an in-memory buffer
buffer = io.BytesIO()
# Save the figure as a pdf to the buffer
plot[1].write_image(file=buffer, format=format)
plot.write_image(file=buffer, format=format)
st.download_button(
label="Download as " + format, data=buffer, file_name=plot[0] + "." + format
label="Download as " + format, data=buffer, file_name=name + "." + format
)


Expand All @@ -27,10 +27,10 @@ def convert_df(df, user_session_id=st.session_state.user_session_id):
return df.to_csv().encode("utf-8")


def download_preprocessing_info(plot, count):
preprocesing_dict = plot[1].preprocessing
def download_preprocessing_info(plot, name, count):
preprocesing_dict = plot.preprocessing
df = pd.DataFrame(preprocesing_dict.items())
filename = "plot" + plot[0] + "preprocessing_info.csv"
filename = "plot" + name + "preprocessing_info.csv"
csv = convert_df(df)
st.download_button(
"Download DataSet Info as .csv",
Expand All @@ -50,21 +50,24 @@ def download_preprocessing_info(plot, count):
count = str(count)

st.markdown("\n\n")
st.write(plot[0])
name = plot[0]
plot = plot[1]
if name == "ttest":
plot = plot.plot
st.write(name)

display_plotly_figure(plot[1])
display_plotly_figure(plot)

col1, col2, col3 = st.columns([1, 1, 1])

with col1:
save_plotly(plot, format="pdf")
save_plotly(plot, name + count, format="pdf")

with col2:
save_plotly(plot, format="svg")
save_plotly(plot, name + count, format="svg")

with col3:
download_preprocessing_info(plot, count)

download_preprocessing_info(plot, name, count)

else:
st.info("No analysis performed yet.")
Loading