From 0d917324daab2913138cb1c604e5f77ac427804c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Annika=20M=C3=BCcke?= Date: Thu, 5 Oct 2023 18:07:30 +0200 Subject: [PATCH] specify possible error sources in warning --- tpcp/_dataset.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tpcp/_dataset.py b/tpcp/_dataset.py index bb216c5..8fa9cfb 100644 --- a/tpcp/_dataset.py +++ b/tpcp/_dataset.py @@ -66,8 +66,6 @@ def _create_check_index(self): most obvious ones. Furthermore, we check if all columns of the index are valid Python attribute names and throw a warning if not. - A string is a valid Python attribute name, if it only contains alphanumeric letters, or underscores, - and does not start with a number. Furthermore, it must not be a built-in Python keyword. In case, creating the index twice is too expensive, users can overwrite this method. But better to catch errors early. @@ -93,7 +91,10 @@ def _create_check_index(self): warnings.warn( f"Some of your index columns are not valid Python attribute names: {invalid_elements}. " "This will cause issues when using further methods such as `get_subset`, `group_label`, " - "`group_labels`, and `datapoint_label`.", + "`group_labels`, and `datapoint_label`.\n" + "To be a valid Python attribute a string should only consist of alphanumeric letters and underscores. " + "Strings starting with a number, containing spaces or special characters are not allowed." + "Furthermore, they must not shadow a built-in Python keyword.", RuntimeWarning, stacklevel=1, )