From ce1042f69152d4efa0d386578648f59161c90db4 Mon Sep 17 00:00:00 2001 From: Tim Mensinger Date: Thu, 28 Dec 2023 15:15:42 +0100 Subject: [PATCH] Use isinstance instead of checking type equality --- src/estimagic/visualization/estimation_table.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/estimagic/visualization/estimation_table.py b/src/estimagic/visualization/estimation_table.py index 44c1a5559..48d611c7e 100644 --- a/src/estimagic/visualization/estimation_table.py +++ b/src/estimagic/visualization/estimation_table.py @@ -1237,11 +1237,12 @@ def _generate_notes_latex( amp_n = "&" * n_levels if isinstance(custom_notes, list): if not all(isinstance(n, str) for n in custom_notes): + not_str_notes = [n for n in custom_notes if not isinstance(n, str)] + not_str_notes_types = [type(n) for n in not_str_notes] raise ValueError( f"""Each custom note can only be of string type. The following notes: - {[n for n in custom_notes if type(n) != str]} are of types - {[type(n) for n in custom_notes if type(n) != str]} + {not_str_notes} are of types {not_str_notes_types} respectively.""" ) for n in custom_notes: @@ -1297,11 +1298,12 @@ def _generate_notes_html( if custom_notes: if isinstance(custom_notes, list): if not all(isinstance(n, str) for n in custom_notes): + not_str_notes = [n for n in custom_notes if not isinstance(n, str)] + not_str_notes_types = [type(n) for n in not_str_notes] raise ValueError( f"""Each custom note can only be of string type. The following notes: - {[n for n in custom_notes if type(n) != str]} are of types - {[type(n) for n in custom_notes if type(n) != str]} + {not_str_notes} are of types {not_str_notes_types} respectively.""" ) notes_text += """