Skip to content

Commit

Permalink
fixed regression by exploding model.commodity_groups before removing …
Browse files Browse the repository at this point in the history
…duplicates.
  • Loading branch information
SamRWest committed Mar 13, 2024
1 parent a147f5c commit e269829
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions xl2times/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2130,9 +2130,6 @@ def process_wildcards(
df = tables[tag]
dictionary = generate_topology_dictionary(tables, model)

# Explode=False: Ran Ireland in 10.94s. 90.0% (36629 correct, 3415 additional).
# Explode=True: Ran Ireland in 14.51s. 90.0% (36614 correct, 3415 additional).

if set(df.columns).intersection(set(process_map.keys())):
df = _match_wildcards(
df,
Expand Down Expand Up @@ -2427,9 +2424,10 @@ def apply_transform_tables(
updates = tables[datatypes.Tag.tfm_comgrp].filter(table.columns, axis=1)

commodity_groups = pd.concat([table, updates], ignore_index=True)
commodity_groups = commodity_groups.drop_duplicates(
subset=[c for c in commodity_groups.columns if c != "commodity"]
commodity_groups["commodity"] = commodity_groups["commodity"].explode(
ignore_index=True
)
commodity_groups = commodity_groups.drop_duplicates()
commodity_groups.loc[commodity_groups["gmap"].isna(), ["gmap"]] = True
model.commodity_groups = commodity_groups.dropna()

Expand All @@ -2455,11 +2453,6 @@ def explode_process_commodity_cols(
)
tables[tag] = df

# special case: explode any commodities that got added during the Tag.tfm_comgrp processing in apply_transform_tables
model.commodity_groups = model.commodity_groups.explode(
"commodity", ignore_index=True
)

return tables


Expand Down

0 comments on commit e269829

Please sign in to comment.