Skip to content

Commit

Permalink
specify possible error sources in warning
Browse files Browse the repository at this point in the history
  • Loading branch information
a-mosquito authored and AKuederle committed Oct 5, 2023
1 parent 7d6dc26 commit 0d91732
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tpcp/_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
)
Expand Down

0 comments on commit 0d91732

Please sign in to comment.