-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Stop using np.{builtin}, and fix bugs due to the previous confusion #8996
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
This is the case for x in {int, bool, str, float, complex, object}. Using the np.{x} version is deceptive as it suggests that there is a difference. This change doesn't affect any external behaviour. The `long` type is missing in python 3, so np.long is still useful
Additionally, make the fixes needed to avoid an incoming deprecation in numpy/numpy#9505
@@ -3136,17 +3136,17 @@ def get_type(item, atype=int): | |||
def get_justify(colname, column, precision): | |||
ntype = column.dtype | |||
|
|||
if np.issubdtype(ntype, str) or np.issubdtype(ntype, bytes): |
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 didn't catch unicode on python 2, but did on python 3
fixed_width = int(ntype.str[2:]) | ||
length = max(len(colname), fixed_width) | ||
return 0, length+padding, "%s" # left justify | ||
|
||
if np.issubdtype(ntype, np.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.
This was false for ntype == np.uint8
length = max(len(colname), | ||
np.max(list(map(len, list(map(str, column)))))) | ||
return 1, length+padding, "%d" # right justify | ||
|
||
if np.issubdtype(ntype, np.float): |
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 worked correctly, but will raise a warning in numpy 1.14 if numpy/numpy#9505 is merged
Thanks @eric-wieser ! |
For
x
in{int, bool, str, float, complex, object}
,np.{x}
andbuiltins.{x}
are one and the same:Using the
np.{x}
version is deceptive as it suggests that there is a difference, when there is not. This change doesn't affect any external behaviour.Similar to numpy/numpy#9517