Skip to content

Commit b67570c

Browse files
committed
refacto
1 parent 7785307 commit b67570c

2 files changed

Lines changed: 31 additions & 32 deletions

File tree

src/andromede/pypsa_converter/pypsa_converter.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ def _pypsa_network_preprocessing(self) -> None:
171171
co2_emissions=0,
172172
max_growth=any_to_float(inf),
173173
)
174-
self.pypsa_network.carriers["carrier"] = (
175-
self.pypsa_network.carriers.index.values
176-
)
174+
self.pypsa_network.carriers[
175+
"carrier"
176+
] = self.pypsa_network.carriers.index.values
177177
### Rename PyPSA buses, to delete spaces
178178
if len(self.pypsa_network.buses) > 0:
179179
self.pypsa_network.buses.index = self.pypsa_network.buses.index.str.replace(
@@ -364,32 +364,32 @@ def _register_pypsa_globalconstraints(self) -> None:
364364
],
365365
)
366366
if carrier_attribute == "co2_emissions" and sense == "<=":
367-
self.pypsa_globalconstraints_data[pypsa_model_id] = (
368-
PyPSAGlobalConstraintData(
369-
name,
370-
carrier_attribute,
371-
sense,
372-
self.pypsa_network.global_constraints.loc[
373-
pypsa_model_id, "constant"
374-
],
375-
"global_constraint_co2_max",
376-
"emission_port",
377-
gems_components_and_ports,
378-
)
367+
self.pypsa_globalconstraints_data[
368+
pypsa_model_id
369+
] = PyPSAGlobalConstraintData(
370+
name,
371+
carrier_attribute,
372+
sense,
373+
self.pypsa_network.global_constraints.loc[
374+
pypsa_model_id, "constant"
375+
],
376+
"global_constraint_co2_max",
377+
"emission_port",
378+
gems_components_and_ports,
379379
)
380380
elif carrier_attribute == "co2_emissions" and sense == "==":
381-
self.pypsa_globalconstraints_data[pypsa_model_id] = (
382-
PyPSAGlobalConstraintData(
383-
name,
384-
carrier_attribute,
385-
sense,
386-
self.pypsa_network.global_constraints.loc[
387-
pypsa_model_id, "constant"
388-
],
389-
"global_constraint_co2_eq",
390-
"emission_port",
391-
gems_components_and_ports,
392-
)
381+
self.pypsa_globalconstraints_data[
382+
pypsa_model_id
383+
] = PyPSAGlobalConstraintData(
384+
name,
385+
carrier_attribute,
386+
sense,
387+
self.pypsa_network.global_constraints.loc[
388+
pypsa_model_id, "constant"
389+
],
390+
"global_constraint_co2_eq",
391+
"emission_port",
392+
gems_components_and_ports,
393393
)
394394
else:
395395
raise ValueError("Type of GlobalConstraint not supported.")

tests/pypsa_converter/utils.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111

1212

1313
def convert_pypsa_network(
14-
pypsa_network: Network,
15-
systems_dir: Path,
16-
series_dir: Path,
17-
series_file_format:str
14+
pypsa_network: Network, systems_dir: Path, series_dir: Path, series_file_format: str
1815
) -> InputSystem:
1916
"""
2017
Convert a PyPSA network to an Andromede InputSystem.
@@ -28,7 +25,9 @@ def convert_pypsa_network(
2825
InputSystem: The converted Andromede InputSystem
2926
"""
3027
logger = Logger(__name__, "")
31-
converter = PyPSAStudyConverter(pypsa_network, logger, systems_dir, series_dir,series_file_format)
28+
converter = PyPSAStudyConverter(
29+
pypsa_network, logger, systems_dir, series_dir, series_file_format
30+
)
3231
input_system_from_pypsa_converter = converter.to_gems_study()
3332
return input_system_from_pypsa_converter
3433

0 commit comments

Comments
 (0)