PyPSA / PyPSA/PyPSA

`network.merge(...)` seems to add default values for outputs

Open
#1,606 9 comments 0 reactions 1 assignee View on GitHub

@lkstrp is already working on this.

Since Mar 18, 2026.

data validation model-building
Dominant language
Python
Stars
2.2k
Forks
699
Avg merge
2d 10h
Merged PRs (30d)
13

Description

Version Checks (indicate both or one)
  • I have confirmed this bug exists on the lastest release of PyPSA.

  • I have confirmed this bug exists on the current master branch of PyPSA.

Issue Description

Not 100% on this one.

Calling n_merged = n.merge(n_other) seems to restore some values to their default values, even if they were not present in either network.

In my case, n and n_other had both <n|n_other.>c.links.dynamic["p0"].empty == True.
However then n_mergedc.links.dynamic["p0"].empty == False, with all valeus set to 0.

This is not bad per-se. The problem is in combination with other functionality that determines if a network has already been solved or not and behaves differently depending on which attributes are set / not set.
In my case that is the network.cluster.temporal.segmentation(...) function that throws a warning as it encounters values in p1 and others:

https://github.com/PyPSA/PyPSA/blob/2e22ebd6bd8315a5e6c51f7581cbb56aa7f1e4af/pypsa/clustering/temporal.py#L28-L41

Reproducible Example
-
Expected Behavior

n.merge(...) should not re-add attributes with their default values if they were not present in the originating networks.

Installed Versions
Replace this line.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.