-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
in _axes.py: Added repr to error messages instead of using str #23383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Can you provide some context as to why you are doing this? Or maybe mark as draft until you are ready? |
raise ValueError(f"{name} must be a single scalar value, " | ||
f"but got {val}") | ||
raise ValueError(f"{repr(name)} must be a single scalar value," | ||
f" but got {repr(val)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f" but got {repr(val)}") | |
f" but got {val!r}") |
and so on also works (and is more compact).
f'and width ({width.dtype}) ' | ||
f'are incompatible') from e | ||
raise TypeError('the dtypes of parameters x' | ||
f' ({repr(x.dtype)}) ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that we want repr here.
@@ -2899,7 +2900,7 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0, | |||
""" | |||
if not 1 <= len(args) <= 5: | |||
raise TypeError('stem expected between 1 and 5 positional ' | |||
'arguments, got {}'.format(args)) | |||
f'arguments, got {repr(args)}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will most likely not produce the expected results.
@@ -3124,7 +3125,8 @@ def get_next_color(): | |||
|
|||
_api.check_isinstance(Number, radius=radius, startangle=startangle) | |||
if radius <= 0: | |||
raise ValueError(f'radius must be a positive number, not {radius}') | |||
raise ValueError('radius must be a positive number, not' | |||
f' {repr(radius)}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't make sense.
I take it that this is related to #21959 However, we do not always want the repr. Typically, for string input it makes sense (as one a) do not have to type the "/' and b) any line breaks or special characters are shown more clearly). But for e.g. a float value or a type it will not make any difference, it will print the same and is just confusing to have the additional call. |
Agreed with @oscargus; also note that this could/should be spelled |
I'm moving to draft until revised. Thanks! |
PR Summary
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).