Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option "all" not supported for clustering: TypeError: Clustering.__init__() takes 4 positional arguments but 6 were given #1150

Closed
2 tasks
fhg-isi opened this issue Jul 12, 2024 · 3 comments
Labels

Comments

@fhg-isi
Copy link
Contributor

fhg-isi commented Jul 12, 2024

a) I tried to use the sector tutorial with a larger number of clusters and changed the value from 5 to 'all'.
Then I get the error below. Maybe you want to use tools like pylint etc. to check for number of arguments.

INFO:pypsa.io:Imported network elec_s.nc has buses, carriers, generators, lines, loads, shapes
ERROR:root:Uncaught exception
Traceback (most recent call last):
File "/home/projekt-resilient03/pypsa-eur/.snakemake/scripts/tmpnlfyn0go.cluster_network.py", line 528, in
clustering = pypsa.clustering.spatial.Clustering(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Clustering.init() takes 4 positional arguments but 6 were given
RuleException:
CalledProcessError in file /home/projekt-resilient03/pypsa-eur/rules/build_electricity.smk, line 511:
Command 'set -euo pipefail; /home/projekt-resilient03/conda/envs/pypsa-eur/bin/python3.11 /home/projekt-resilient03/pypsa-eur/.snakemake/scripts/tmpnlfyn0go.cluster_network.py' returned non-zero exit status 1.
[Fri Jul 12 10:11:45 2024]

b) After removing some of the arguments I got another error:

INFO:main:Using biomass potentials for 2030.
Traceback (most recent call last):
File "/home/projekt-resilient03/pypsa-eur/.snakemake/scripts/tmp9so9_wsv.build_shipping_demand.py", line 60, in
nodal_demand = demand.loc[countries].fillna(0.0)
~~~~~~~~~~^^^^^^^^^^^
File "/home/projekt-resilient03/conda/envs/pypsa-eur/lib/python3.11/site-packages/pandas/core/indexing.py", line 1191, in getitem
return self._getitem_axis(maybe_callable, axis=axis)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/projekt-resilient03/conda/envs/pypsa-eur/lib/python3.11/site-packages/pandas/core/indexing.py", line 1420, in _getitem_axis
return self._getitem_iterable(key, axis=axis)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/projekt-resilient03/conda/envs/pypsa-eur/lib/python3.11/site-packages/pandas/core/indexing.py", line 1360, in _getitem_iterable
keyarr, indexer = self._get_listlike_indexer(key, axis)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/projekt-resilient03/conda/envs/pypsa-eur/lib/python3.11/site-packages/pandas/core/indexing.py", line 1558, in _get_listlike_indexer
keyarr, indexer = ax._get_indexer_strict(key, axis_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/projekt-resilient03/conda/envs/pypsa-eur/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 6200, in _get_indexer_strict
self._raise_if_missing(keyarr, indexer, axis_name)
File "/home/projekt-resilient03/conda/envs/pypsa-eur/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 6249, in _raise_if_missing
raise KeyError(f"None of [{key}] are in the [{axis_name}]")
KeyError: "None of [Index(['50', '50', '74'], dtype='object', name='name')] are in the [index]"

Related:

#1149

Checklist

  • I am using the current master branch or the latest release. Please indicate.
  • I am running on an up-to-date pypsa-eur environment. Update via conda env update -f envs/environment.yaml.
@mxh970120
Copy link

I had the same problem. I am creating a network for a German network. When I set clusters to all or 337 (max) I get the following error

INFO:pypsa.io:Imported network elec_s.nc has buses, carriers, generators, lines, links, loads, shapes, storage_units
ERROR:root:Uncaught exception
Traceback (most recent call last):
  File "C:\Workspace\EnergyModels\PyPSA\pypsa-eur\.snakemake\scripts\tmpl0wy95f3.cluster_network.py", line 516, in <module>
    clustering = pypsa.clustering.spatial.Clustering(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Clustering.__init__() takes 4 positional arguments but 6 were given
RuleException:
CalledProcessError in file C:\Workspace\EnergyModels\PyPSA\pypsa-eur\rules/build_electricity.smk, line 541:
Command 'C:/Users/ii6823/AppData/Local/miniconda3/envs/pypsa-eur/python.exe "C:\Workspace\EnergyModels\PyPSA\pypsa-eur\.snakemake\scripts\tmpl0wy95f3.cluster_network.py"' returned non-zero exit status 1.

But when I use 336, I can get the result normally

@fneum
Copy link
Member

fneum commented Aug 3, 2024

In cluster_network.py, change to:

clustering = pypsa.clustering.spatial.Clustering(
    n, busmap, linemap
)

@fneum
Copy link
Member

fneum commented Aug 23, 2024

closed via 73d1353

@fneum fneum closed this as completed Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants