From dcf24fdee3a91ac16743e30c0d4f93d5ffc3d4b7 Mon Sep 17 00:00:00 2001 From: eschalk Date: Mon, 4 Dec 2023 23:44:34 +0100 Subject: [PATCH] Avoid entering into the more complex else branch --- datatree/treenode.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datatree/treenode.py b/datatree/treenode.py index 16278079..1689d261 100644 --- a/datatree/treenode.py +++ b/datatree/treenode.py @@ -634,7 +634,7 @@ def relative_to(self: NamedNode, other: NamedNode) -> str: ) this_path = NodePath(self.path) - if other.path in list(parent.path for parent in self.parents): + if other.path in list(parent.path for parent in (self, *self.parents)): return str(this_path.relative_to(other.path)) else: common_ancestor = self.find_common_ancestor(other)