Skip to content

Commit

Permalink
small bug fix to data loading to make it able to only have one tabula…
Browse files Browse the repository at this point in the history
…r data source specified
  • Loading branch information
florencejt committed Jan 31, 2024
1 parent bdb276b commit af26d5f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions fusilli/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,18 @@ def __init__(self, sources, img_downsample_dims=None):
# read in the csv files and raise errors if they don't have the right columns
# or if the index column is not named "ID"
tab1_df = pd.read_csv(self.tabular1_source)
tab2_df = pd.read_csv(self.tabular2_source)

if "ID" not in tab1_df.columns:
raise ValueError("The CSV must have an index column named 'ID'.")
if "prediction_label" not in tab1_df.columns:
raise ValueError("The CSV must have a label column named 'prediction_label'.")
if "ID" not in tab2_df.columns:
raise ValueError("The CSV must have an index column named 'ID'.")
if "prediction_label" not in tab2_df.columns:
raise ValueError("The CSV must have a label column named 'prediction_label'.")

# if tabular2_source exists, check it has the right columns
if self.tabular2_source != "":
tab2_df = pd.read_csv(self.tabular2_source)
if "ID" not in tab2_df.columns:
raise ValueError("The CSV must have an index column named 'ID'.")
if "prediction_label" not in tab2_df.columns:
raise ValueError("The CSV must have a label column named 'prediction_label'.")

def load_tabular1(self):
"""
Expand Down

0 comments on commit af26d5f

Please sign in to comment.