From 5a971cea4152c74867275a42896aa27be63a16d3 Mon Sep 17 00:00:00 2001 From: mcguirepr89 Date: Fri, 24 Jun 2022 09:15:59 -0400 Subject: [PATCH] linted plotly --- scripts/plotly_streamlit.py | 167 +++++++++++++++++------------------- 1 file changed, 80 insertions(+), 87 deletions(-) diff --git a/scripts/plotly_streamlit.py b/scripts/plotly_streamlit.py index d555e48..fe8fa08 100755 --- a/scripts/plotly_streamlit.py +++ b/scripts/plotly_streamlit.py @@ -6,13 +6,11 @@ from numpy import ma import plotly.graph_objects as go from plotly.subplots import make_subplots import plotly.io as pio -from datetime import timedelta, datetime -from pathlib import Path +from datetime import timedelta import sqlite3 from sqlite3 import Connection import plotly.express as px from sklearn.preprocessing import normalize -import time pio.templates.default = "plotly_white" @@ -40,9 +38,8 @@ st.markdown(""" """, unsafe_allow_html=True) - @st.cache(hash_funcs={Connection: id}) -#@st.cache(allow_output_mutation=True) +# @st.cache(allow_output_mutation=True) def get_connection(path: str): return sqlite3.connect(path, check_same_thread=False) @@ -58,19 +55,18 @@ df2 = df.copy() df2['DateTime'] = pd.to_datetime(df2['Date'] + " " + df2['Time']) df2 = df2.set_index('DateTime') -daily = st.sidebar.checkbox('Single Day View', help= 'Select if you want single day view, unselect for multi-day views') +daily = st.sidebar.checkbox('Single Day View', help='Select if you want single day view, unselect for multi-day views') if daily: -# Date as slider + # Date as slider Start_Date = pd.to_datetime(df2.index.min()).date() End_Date = pd.to_datetime(df2.index.max()).date() # cols1, cols2 = st.columns((1, 1)) end_date = st.sidebar.date_input('Date to View', - min_value = Start_Date, - max_value = End_Date, - value=(End_Date), - help= 'Select date for single day view' - ) + min_value=Start_Date, + max_value=End_Date, + value=(End_Date), + help='Select date for single day view') start_date = end_date else: Start_Date = pd.to_datetime(df2.index.min()).date() @@ -78,11 +74,10 @@ else: # cols1, cols2 = st.columns((1, 1)) start_date, end_date = st.sidebar.slider('Date Range', - min_value = Start_Date-timedelta(days=1), - max_value = End_Date, - value=(Start_Date, End_Date), - help= 'Select start and end date, if same date get a clockplot for a single day' - ) + min_value=Start_Date-timedelta(days=1), + max_value=End_Date, + value=(Start_Date, End_Date), + help='Select start and end date, if same date get a clockplot for a single day') # start_date, end_date = cols1.date_input( # "Date Input for Analysis - select Range for single specie analysis, select single date for daily view", @@ -93,12 +88,14 @@ else: # start_date = datetime(2022 ,5 ,17).date() # end_date = datetime(2022 ,5 ,17).date() + @st.cache() def date_filter(df, start_date, end_date): filt = (df2.index >= pd.Timestamp(start_date)) & (df2.index <= pd.Timestamp(end_date + timedelta(days=1))) df = df[filt] return(df) + df2 = date_filter(df2, start_date, end_date) st.write('', @@ -112,7 +109,7 @@ st.write('