Skip to content

Commit bbb9afc

Browse files
authored
Use more descriptive transform names; improve doc strings. (#303)
1 parent 8f97d58 commit bbb9afc

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

xl2times/__main__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,14 @@ def convert_xl_to_times(
129129
transforms.process_transform_availability,
130130
transforms.process_flexible_import_tables, # slow
131131
transforms.process_user_constraint_tables,
132-
transforms.process_tradelinks,
132+
transforms.harmonise_tradelinks,
133133
transforms.include_tables_source,
134134
transforms.process_processes,
135135
transforms.create_model_topology,
136136
transforms.fill_in_column_defaults,
137137
transforms.generate_uc_properties,
138138
transforms.expand_rows_parallel, # slow
139-
transforms.process_trade_links,
139+
transforms.process_tradelinks,
140140
transforms.merge_tables,
141141
transforms.remove_invalid_values,
142142
transforms.include_cgs_in_topology,
@@ -148,7 +148,7 @@ def convert_xl_to_times(
148148
transforms.enforce_availability,
149149
transforms.complete_model_trade,
150150
transforms.create_model_cgs,
151-
transforms.apply_fixups,
151+
transforms.prepare_for_querying,
152152
transforms.apply_transform_tables,
153153
transforms.generate_implied_topology,
154154
transforms.verify_uc_topology,

xl2times/transforms.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,12 +1203,18 @@ def _populate_calculated_defaults(df: DataFrame, model: TimesModel):
12031203
)
12041204

12051205

1206-
def apply_fixups(
1206+
def prepare_for_querying(
12071207
config: Config,
12081208
tables: dict[str, DataFrame],
12091209
model: TimesModel,
12101210
) -> dict[str, DataFrame]:
1211-
"""Apply fixups to the tables."""
1211+
"""Prepare tables for querying by harmonising them and filling in missing values.
1212+
This includes
1213+
- Adding expected columns with NA if they are missing.
1214+
- Expanding year columns if they contain ranges.
1215+
- Applying attribute-specific default values (incl. if specified under a different column).
1216+
- Filling in missing values in year and currency columns with defaults.
1217+
"""
12121218
exclude_tags = {Tag.tfm_mig, Tag.tfm_upd}
12131219
attribute_tags = [Tag.fi_t, Tag.uc_t]
12141220
currency = tables[Tag.currencies]["currency"][0]
@@ -1447,12 +1453,12 @@ def create_model_cgs(
14471453
return tables
14481454

14491455

1450-
def process_trade_links(
1456+
def process_tradelinks(
14511457
config: Config,
14521458
tables: list[EmbeddedXlTable],
14531459
model: TimesModel,
14541460
) -> list[EmbeddedXlTable]:
1455-
"""Process trade links and create model trade (between internal regions)."""
1461+
"""Process tradelinks and create model trade (between internal regions)."""
14561462
cols_list = ["origin", "in", "destination", "out", "process"]
14571463
cols_list.extend(dm_cols)
14581464
result = []
@@ -1823,7 +1829,7 @@ def generate_dummy_processes(
18231829
return tables
18241830

18251831

1826-
def process_tradelinks(
1832+
def harmonise_tradelinks(
18271833
config: Config,
18281834
tables: list[EmbeddedXlTable],
18291835
model: TimesModel,
@@ -3199,7 +3205,7 @@ def apply_final_fixup(
31993205
tables: dict[str, DataFrame],
32003206
model: TimesModel,
32013207
) -> dict[str, DataFrame]:
3202-
3208+
"""Clean up remaining issues. Includes handling of aliases that could not be generalised."""
32033209
veda_ire_sets = model.custom_sets
32043210
reg_com_flows = model.topology[["region", "process", "commodity"]].copy()
32053211
reg_com_flows.drop_duplicates(inplace=True, ignore_index=True)

0 commit comments

Comments
 (0)