Skip to content

Commit 9529284

Browse files
authored
fix: allow pypsa<0.35 (#1786)
1 parent b261087 commit 9529284

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

scripts/prepare_network.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,23 @@
2929
import numpy as np
3030
import pandas as pd
3131
import pypsa
32-
from pypsa.common import expand_series
3332

3433
from scripts._helpers import (
34+
PYPSA_V1,
3535
configure_logging,
3636
get,
3737
set_scenario_config,
3838
update_config_from_wildcards,
3939
)
4040
from scripts.add_electricity import load_costs, set_transmission_costs
4141

42+
# Allow for PyPSA versions <0.35
43+
if PYPSA_V1:
44+
from pypsa.common import expand_series
45+
else:
46+
from pypsa.descriptors import expand_series
47+
48+
4249
idx = pd.IndexSlice
4350

4451
logger = logging.getLogger(__name__)

scripts/prepare_perfect_foresight.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
import numpy as np
1111
import pandas as pd
1212
import pypsa
13-
from pypsa.common import expand_series
1413
from six import iterkeys
1514

1615
from scripts._helpers import (
16+
PYPSA_V1,
1717
configure_logging,
1818
sanitize_custom_columns,
1919
set_scenario_config,
@@ -22,6 +22,12 @@
2222
from scripts.add_electricity import sanitize_carriers
2323
from scripts.add_existing_baseyear import add_build_year_to_new_assets
2424

25+
# Allow for PyPSA versions <0.35
26+
if PYPSA_V1:
27+
from pypsa.common import expand_series
28+
else:
29+
from pypsa.descriptors import expand_series
30+
2531
logger = logging.getLogger(__name__)
2632

2733

scripts/solve_network.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@
5353
)
5454

5555
logger = logging.getLogger(__name__)
56-
pypsa.network.power_flow.logger.setLevel(logging.WARNING)
56+
57+
# Allow for PyPSA versions <0.35
58+
if PYPSA_V1:
59+
pypsa.network.power_flow.logger.setLevel(logging.WARNING)
60+
else:
61+
pypsa.pf.logger.setLevel(logging.WARNING)
5762

5863

5964
class ObjectiveValueError(Exception):

0 commit comments

Comments
 (0)