etsap-TIMES / xl2times

Open source tool to convert TIMES models specified in Excel
https://xl2times.readthedocs.io/
MIT License
12 stars 7 forks source link

Refactor code expanding/exploding regions into a single utility function #206

Open siddharth-krishna opened 8 months ago

siddharth-krishna commented 8 months ago

There's code in generate_uc_properties that expands allregions and comma-separated region lists: https://github.com/etsap-TIMES/xl2times/blob/b12287d15324ddf058b34266a6c5d0ffd3a67ce7/xl2times/transforms.py#L749-L767 which is very similar to code in process_transform_tables: https://github.com/etsap-TIMES/xl2times/blob/3720c7e554534131e7975753ef1b8e42c5311d97/xl2times/transforms.py#L1708-L1745 and there's also an explode function in utils.py.

It would be good to have all the code exploding regions in one place, both for code reuse and conciseness but also so that optimizations are applied everywhere.

(Link to original discussion: https://github.com/etsap-TIMES/xl2times/pull/179/files/4ea76267c9558b3a08d09ec282b7a5fcaa458f8c#r1487242195)