From cd8308781effbf5fda3b60365b8a71f4f9e3823c Mon Sep 17 00:00:00 2001 From: Nat DeFries <42820733+nmdefries@users.noreply.github.com> Date: Tue, 24 Sep 2024 16:18:32 -0400 Subject: [PATCH] replace boolean comparisons with pythonic "not" --- src/acquisition/rvdss/rvdss_historic.py | 16 ++++++++-------- src/acquisition/rvdss/rvdss_update.py | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/acquisition/rvdss/rvdss_historic.py b/src/acquisition/rvdss/rvdss_historic.py index ee15825af..918ddbb78 100644 --- a/src/acquisition/rvdss/rvdss_historic.py +++ b/src/acquisition/rvdss/rvdss_historic.py @@ -75,7 +75,7 @@ def get_report_date(week,start_year,epi=False): epi_week = Week(year, week) - if epi==False: + if not epi: report_date = str(epi_week.enddate()) else: report_date = str(epi_week) @@ -272,7 +272,7 @@ def create_percent_positive_detection_table(table,modified_date,start_year, flu= table.columns=names # Remake the weeks column from dates - if overwrite_weeks==True: + if overwrite_weeks: week_ends = [datetime.strptime(date_string, "%Y-%m-%d") for date_string in table['time_value']] table["week"] = [Week.fromdate(d).week for d in week_ends] @@ -444,14 +444,14 @@ def get_season_reports(url): # Check if the indices are already in the season table # If not, add the weeks tables into the season table - if respiratory_detection_table.index.isin(all_respiratory_detection_table.index).any() == False: + if not respiratory_detection_table.index.isin(all_respiratory_detection_table.index).any(): all_respiratory_detection_table= pd.concat([all_respiratory_detection_table,respiratory_detection_table]) - if combined_positive_tables.index.isin(all_positive_tables.index).any() == False: + if not combined_positive_tables.index.isin(all_positive_tables.index).any(): all_positive_tables=pd.concat([all_positive_tables,combined_positive_tables]) - if number_table_exists == True: - if number_detections_table.index.isin(all_number_tables.index).any() == False: + if number_table_exists: + if not number_detections_table.index.isin(all_number_tables.index).any(): all_number_tables=pd.concat([all_number_tables,number_detections_table]) # write files to csvs @@ -479,10 +479,10 @@ def main(): # Check if indices are already present in the old data # If not, add the new data - if weekly_data.index.isin(old_detection_data.index).any() == False: + if not weekly_data.index.isin(old_detection_data.index).any(): old_detection_data= pd.concat([old_detection_data,weekly_data],axis=0) - if positive_data.index.isin(old_positive_data.index).any() == False: + if not positive_data.index.isin(old_positive_data.index).any(): old_positive_data= pd.concat([old_positive_data,positive_data],axis=0) # Overwrite/update csvs diff --git a/src/acquisition/rvdss/rvdss_update.py b/src/acquisition/rvdss/rvdss_update.py index 1894dd905..cab8d68bc 100644 --- a/src/acquisition/rvdss/rvdss_update.py +++ b/src/acquisition/rvdss/rvdss_update.py @@ -17,19 +17,19 @@ def main(): path1 = './' + RESP_COUNTS_OUTPUT_FILE path2 = './' + POSITIVE_TESTS_OUTPUT_FILE - if os.path.exists(path1)==False: + if not os.path.exists(path1): weekly_data.to_csv(path1,index=True) else: old_detection_data = pd.read_csv(path1).set_index(['epiweek', 'time_value', 'issue', 'geo_type', 'geo_value']) - if weekly_data.index.isin(old_detection_data.index).any() == False: + if not weekly_data.index.isin(old_detection_data.index).any(): old_detection_data= pd.concat([old_detection_data,weekly_data],axis=0) old_detection_data.to_csv(path1,index=True) - if os.path.exists(path2)==False: + if not os.path.exists(path2): positive_data.to_csv(path2,index=True) else: old_positive_data = pd.read_csv(path2).set_index(['epiweek', 'time_value', 'issue', 'geo_type', 'geo_value']) - if positive_data.index.isin(old_positive_data.index).any() == False: + if not positive_data.index.isin(old_positive_data.index).any(): old_positive_data= pd.concat([old_positive_data,positive_data],axis=0) old_positive_data.to_csv(path2,index=True)