Skip to content

Commit

Permalink
Fix dtype bug in combine-preds field lists (#577)
Browse files Browse the repository at this point in the history
* Fix dtype bug in combine-preds field lists

* Remove code.interact

* Use fields_to_do in loop instead of 'not' fields_to_list
  • Loading branch information
bfhealy authored Apr 9, 2024
1 parent c0265a4 commit e96dfe0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tools/combine_preds.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,23 @@ def combine_preds(
os.makedirs(path_to_preds / combined_preds_dirname, exist_ok=True)

done_fields = [
str(x).split("/")[-1].split(".")[0]
int(str(x).split("/")[-1].split(".")[0].split("_")[1])
for x in (path_to_preds / combined_preds_dirname).glob("field_*.parquet")
]
fields_to_list = done_fields.copy()

if fields_to_exclude is not None:
fields_to_list.extend(fields_to_exclude)

fields_to_do = list(set(fields_dnn_dict).difference(done_fields))
fields_to_do = list(
set([int(x.split("_")[1]) for x in fields_dnn_dict.keys()]).difference(
fields_to_list
)
)
fields_to_list.extend(fields_to_do)

# Use set to drop duplicate fields before sorting
fields_to_list = list(set(fields_to_list))
fields_to_list.sort()

if save:
Expand All @@ -127,8 +133,11 @@ def combine_preds(
counter = 0
print(f"Processing {len(fields_to_do)} fields/files...")

# Reformat fields in field_N format to match filenames
fields_to_do = [f"field_{x}" for x in fields_to_do]

for field in fields_dnn_dict.keys():
if field not in done_fields:
if field in fields_to_do:
if field in fields_xgb_dict.keys():
try:
dnn_preds = read_parquet(
Expand Down

0 comments on commit e96dfe0

Please sign in to comment.