Skip to content

Conversation

eric-wieser
Copy link
Contributor

@eric-wieser eric-wieser commented Aug 6, 2017

For x in {int, bool, str, float, complex, object}, np.{x} and builtins.{x} are one and the same:

>>> np.float is float
True
>>> np.bool is bool
True
# etc

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

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):
Copy link
Contributor Author

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):
Copy link
Contributor Author

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):
Copy link
Contributor Author

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

@tacaswell tacaswell merged commit f077d49 into matplotlib:master Aug 6, 2017
@tacaswell
Copy link
Member

Thanks @eric-wieser !

@QuLogic QuLogic added this to the 2.1 (next point release) milestone Aug 7, 2017
@eric-wieser eric-wieser deleted the outdated-sctype-use branch March 23, 2019 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants