Skip to content

BUG: to_numeric downcast = 'unsigned' would not un-sign a 0 value. #14504

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

Closed
wants to merge 16 commits into from

Conversation

verhalenn
Copy link

Have to figure out whats going wrong with the build still. Will let you know as soon as I do.

@jreback jreback added Bug Dtype Conversions Unexpected or buggy dtype conversions labels Oct 26, 2016
@@ -78,3 +78,7 @@ Bug Fixes


- Bug in ``pd.pivot_table`` may raise ``TypeError`` or ``ValueError`` when ``index`` or ``columns`` is not scalar and ``values`` is not specified (:issue:`14380`)
- Bug in ``pd.pivot_table`` may raise ``TypeError`` or ``ValueError`` when ``index`` or ``columns``
- Bug in ``pd.to_numeric`` where a 0 was not unsigned on a downcast = 'unsigned' argument (:issue:`14401`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just add your fix, don't change the existing

@jreback
Copy link
Contributor

jreback commented Nov 2, 2016

can you rebase this

@codecov-io
Copy link

codecov-io commented Nov 5, 2016

Current coverage is 85.28% (diff: 100%)

Merging #14504 into master will not change coverage

@@             master     #14504   diff @@
==========================================
  Files           140        140          
  Lines         50693      50693          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits          43235      43235          
  Misses         7458       7458          
  Partials          0          0          

Powered by Codecov. Last update 726efc7...07264cd

@jorisvandenbossche
Copy link
Member

@verhalenn There is still a test failing. Do you have time to look into this?

@verhalenn
Copy link
Author

@jorisvandenbossche I have been but I'm having trouble replicating it.

@jorisvandenbossche
Copy link
Member

@verhalenn Apparently this is a bug in older numpy versions:

>>> np.__version__
'1.8.2'
>>> arr = np.array([-128, 127])
>>> arr2 = arr.astype('int8')
>>> np.allclose(arr, arr2)
False
>>> np.__version__
'1.11.2'
>>> arr = np.array([-128, 127])
>>> arr2 = arr.astype('int8')
>>> np.allclose(arr, arr2)
True

So you can skip the failing test for numpy versions of 1.8 or lower.

@verhalenn
Copy link
Author

verhalenn commented Nov 15, 2016

That should do. If there is anything you would like different, let me know.

Also thanks @jorisvandenbossche for the help.

@jorisvandenbossche
Copy link
Member

@verhalenn See here for an example how to skip a test for a numpy version:

raise nose.SkipTest("Numpy version is under 1.9")

Can you also move the whatsnew note to the 0.19.2 file ?

@@ -58,4 +58,4 @@ Bug Fixes
- Bug in ``df.groupby`` causing an ``AttributeError`` when grouping a single index frame by a column and the index level (:issue`14327`)
- Bug in ``df.groupby`` where ``TypeError`` raised when ``pd.Grouper(key=...)`` is passed in a list (:issue:`14334`)
- Bug in ``pd.pivot_table`` may raise ``TypeError`` or ``ValueError`` when ``index`` or ``columns``
is not scalar and ``values`` is not specified (:issue:`14380`)
Copy link
Contributor

@jreback jreback Nov 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this file

@@ -25,3 +25,4 @@ Bug Fixes

- compat with ``dateutil==2.6.0`` for testing (:issue:`14621`)
- allow ``nanoseconds`` in ``Timestamp.replace`` kwargs (:issue:`14621`)
- Bug in ``pd.to_numeric`` where a 0 was not unsigned on a downcast = 'unsigned' argument (:issue:`14401`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

downcast='unsigned' (use double-backticks)

@@ -4,9 +4,11 @@
import nose

import numpy as np
from numpy import (iinfo, int8, int16, int32, int64,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't import these, just access np.iinfo etc

('uint8', u, [iinfo(uint8).min, iinfo(uint8).max]),
('uint16', u, [iinfo(uint16).min, iinfo(uint16).max]),
('uint32', u, [iinfo(uint32).min, iinfo(uint32).max]),
# ('uint64', u, [iinfo(uint64).min, iinfo(uint64).max]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put a comment on why skipping the uint64

@jreback
Copy link
Contributor

jreback commented Nov 17, 2016

thanks!

jorisvandenbossche pushed a commit to jorisvandenbossche/pandas that referenced this pull request Dec 14, 2016
@verhalenn verhalenn deleted the issue14401 branch February 24, 2017 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: pd.to_numeric(..., downcast='unsigned') should accept 0
4 participants