Merge pull request #330 from PyPSA/fix-clustering-with-infs
Fix clustering of p_nom_max values with pandas version > 1.4
This commit is contained in:
commit
5a76493685
@ -263,9 +263,9 @@ def clustering_for_n_clusters(n, n_clusters, custom_busmap=False, aggregate_carr
|
|||||||
algorithm="kmeans", extended_link_costs=0, focus_weights=None):
|
algorithm="kmeans", extended_link_costs=0, focus_weights=None):
|
||||||
|
|
||||||
if potential_mode == 'simple':
|
if potential_mode == 'simple':
|
||||||
p_nom_max_strategy = np.sum
|
p_nom_max_strategy = pd.Series.sum
|
||||||
elif potential_mode == 'conservative':
|
elif potential_mode == 'conservative':
|
||||||
p_nom_max_strategy = np.min
|
p_nom_max_strategy = pd.Series.min
|
||||||
else:
|
else:
|
||||||
raise AttributeError(f"potential_mode should be one of 'simple' or 'conservative' but is '{potential_mode}'")
|
raise AttributeError(f"potential_mode should be one of 'simple' or 'conservative' but is '{potential_mode}'")
|
||||||
|
|
||||||
@ -281,7 +281,7 @@ def clustering_for_n_clusters(n, n_clusters, custom_busmap=False, aggregate_carr
|
|||||||
aggregate_generators_carriers=aggregate_carriers,
|
aggregate_generators_carriers=aggregate_carriers,
|
||||||
aggregate_one_ports=["Load", "StorageUnit"],
|
aggregate_one_ports=["Load", "StorageUnit"],
|
||||||
line_length_factor=line_length_factor,
|
line_length_factor=line_length_factor,
|
||||||
generator_strategies={'p_nom_max': p_nom_max_strategy, 'p_nom_min': np.sum},
|
generator_strategies={'p_nom_max': p_nom_max_strategy, 'p_nom_min': pd.Series.sum},
|
||||||
scale_link_capital_costs=False)
|
scale_link_capital_costs=False)
|
||||||
|
|
||||||
if not n.links.empty:
|
if not n.links.empty:
|
||||||
|
Loading…
Reference in New Issue
Block a user