-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
ENH: Added sanity check to printoptions #18263
ENH: Added sanity check to printoptions #18263
Conversation
Restarting CI, something weird happened. |
numpy/core/arrayprint.py
Outdated
|
||
if precision is not None: | ||
# forbid the bad precision arg as suggested by issue #18254 | ||
if not isinstance(precision, int): |
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.
Perhaps better as precision = operator.index(precision)
, else this blows up if users pass an np.int32
or something else that's harmless
Fixed a bug where precision couldn't be a non-native integer. See comments on pull request numpy#18263 for more info.
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
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 think we normally don't do from operator import *
, as those names are very likely to overlap with other names. If nothing else, it makes operator.index
something which can be searched for.
Can you update the annotations in arrayprint.pyi as well? In total two changes will be necessary:
if sys.version_info > (3, 8):
from typing import SupportsIndex
else:
from typing_extensions import SupportsIndex
|
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.
The annotation update is looking good as well.
Thanks @Mitchell-Faas . |
See issue #18254