Skip to content

Commit

Permalink
label after concat
Browse files Browse the repository at this point in the history
  • Loading branch information
colganwi committed Aug 21, 2024
1 parent 4ac765a commit b071326
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ and this project adheres to [Semantic Versioning][].
### Changed

- `obst` and `vart` create local copy of `nx.DiGraphs` that are added (#26)
- `TreeData.label` value remains the same after `td.concat` as long as all `label` values are the same (#27)

### Fixed

- Fixed bug which caused key to be listed twice in `tree_label` column after value update in `obst` or `vart` (#26)
- Fixed bug which caused key to be listed twice in `label` column after value update in `obst` or `vart` (#26)

## [0.0.2] - 2024-06-18

Expand Down
12 changes: 11 additions & 1 deletion src/treedata/_core/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

import typing
import warnings
from collections.abc import (
Callable,
Collection,
Expand Down Expand Up @@ -100,7 +101,16 @@ def concat(
fill_value=fill_value,
pairwise=pairwise,
)
tdata = TreeData(adata, allow_overlap=True)

# Create new TreeData object
label = {t.label for t in tdatas if t.label is not None}
if len(label) > 1:
warnings.warn("Multiple label values found. Setting to `tree`.", stacklevel=2)
label = "tree"
else:
label = next(iter(label), None)
allow_overlap = any(t.allow_overlap for t in tdatas)
tdata = TreeData(adata, allow_overlap=allow_overlap, label=label)

# Trees for concatenation axis
concat_trees = [getattr(t, f"{dim}t") for t in tdatas]
Expand Down

0 comments on commit b071326

Please sign in to comment.