From 1081bcca4b19e04fe99187a3ceedad0c5e16c7ee Mon Sep 17 00:00:00 2001 From: Matthew Andres Moreno Date: Wed, 5 Feb 2025 14:27:52 -0500 Subject: [PATCH] Warn support values as node attributes --- src/dendropy/datamodel/treemodel/_tree.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/dendropy/datamodel/treemodel/_tree.py b/src/dendropy/datamodel/treemodel/_tree.py index 2e21c744f..4292856fa 100644 --- a/src/dendropy/datamodel/treemodel/_tree.py +++ b/src/dendropy/datamodel/treemodel/_tree.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- import copy +import functools import warnings from io import StringIO from dendropy.utility import terminal @@ -2493,6 +2494,19 @@ def reseed_at( edges_to_invert = [] current_node = new_seed_node while current_node: + + @functools.lru_cache() + def warn_node_support_values_once(): + warnings.warn("""Support value detected as a node attribute, which can cause unexpected results when rerooting. + +See for details on this issue. Consider +using the `is_assign_internal_labels_to_edges` kwarg when loading data to assign support values to edges instead of nodes. + +See for information on how to suppress this warning with a using a filter.""") + + if any("support" in attr for attr in current_node.__dict__): + warn_node_support_values_once() + if current_node._parent_node is not None: edges_to_invert.append(current_node.edge) current_node = current_node._parent_node