Skip to content

Commit ff71fdf

Browse files
authored
better_parse_error
pandasGEXpress/parse_gct.py more descriptive error when parsing GCT files of incorrect shape
1 parent 0406a37 commit ff71fdf

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

cmapPy/pandasGEXpress/parse_gct.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,13 @@ def parse_into_3_df(file_path, num_data_rows, num_data_cols, num_row_metadata, n
212212
dtype=str, na_values=nan_values, keep_default_na=False)
213213

214214
# Check that full_df is the size we expect
215-
assert full_df.shape == (num_col_metadata + num_data_rows + 1,
216-
num_row_metadata + num_data_cols + 1), (
217-
("The shape of full_df is not as expected: data is {} x {} " +
218-
"but there are {} row meta fields and {} col fields").format(
219-
num_data_rows, num_data_cols, num_row_metadata, num_col_metadata))
215+
expected_row_num = num_col_metadata + num_data_rows + 1
216+
expected_col_num = num_row_metadata + num_data_cols + 1
217+
assert full_df.shape == (expected_row_num,
218+
expected_col_num), (
219+
("The shape of full_df is not as expected: expected shape is {} x {} " +
220+
"parsed shape is {} x {}").format(expected_row_num, expected_col_num,
221+
full_df.shape[0], full_df.shape[1]))
220222

221223
# Assemble metadata dataframes
222224
row_metadata = assemble_row_metadata(full_df, num_col_metadata, num_data_rows, num_row_metadata)

0 commit comments

Comments
 (0)