tskit
tskit copied to clipboard
Warning for `draw_svg` plot uses `logging` module instead of `warnings`
I came across a minor issue with the plotting code: the draw_svg warning for mutations above unplotted nodes uses the logging module instead of the warnings module, that we'd usually use for user warnings. I discovered this because I couldn't find a way to suppress it. The warning is currently this:
if len(unplotted) > 0:
logging.warning(
f"Mutations {unplotted} are above nodes which are not present in the "
"displayed tree, so are not plotted on the topology."
)
If we were to use warnings instead, I'm guessing we'd do something like this? I'm not sure what stack level is appropriate here.
if len(unplotted) > 0:
warnings.warn(
f"Mutations {unplotted} are above nodes which are not present in the "
"displayed tree, so are not plotted on the topology.",
UserWarning,
stacklevel=2
)
PR welcome!
I realised we forgot to update the changelog to track this bugfix (we should really note anything that's fixing a bug, even if it is fairly trivial like this) so opening this again to track that.