From dcfbe10d427729b405af26c0afd35958c3e30109 Mon Sep 17 00:00:00 2001 From: DaGuT Date: Fri, 15 Apr 2022 15:46:38 +0300 Subject: [PATCH] Fixed paramval2str type error for non-str lists Hi, if you have parameter with list of something other than list (e.g. list of dicts), you'll get a error `TypeError: sequence item 0: expected str instance, found`. With this fix you'll convert everything to string recursively, thus preserving better text output. Slightly better than https://github.com/verybadsoldier/backtrader_plotting/pull/88 --- backtrader_plotting/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backtrader_plotting/utils.py b/backtrader_plotting/utils.py index 5bb5baf..7c733d8 100644 --- a/backtrader_plotting/utils.py +++ b/backtrader_plotting/utils.py @@ -24,7 +24,7 @@ def paramval2str(name, value): elif isinstance(value, float): return f"{value:.2f}" elif isinstance(value, (list,tuple)): - return ','.join(value) + return ','.join(map(lambda x: paramval2str(name, x), value)) elif isinstance(value, type): return value.__name__ else: