-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Bug: Made it so that 0 was included in uint8 #14412
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
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3d2ce5b
Made it so that 0 was included in uint8
81b4965
Added a test to check uint8 with 0
b6331a5
Added release note to issue 14401 resolve.
8a836b2
Edited mistakes in whatsnew
3427e4f
Added tests for the max and min values of all dtypes to to_numeric
0da1918
Changed the tests so that it iterated through a dictionary.
c6be0eb
Changed the test to work with python 3.x
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -401,6 +401,62 @@ def test_downcast(self): | |
res = pd.to_numeric(data, downcast=downcast) | ||
tm.assert_numpy_array_equal(res, expected) | ||
|
||
# check that the smallest and largest values in each integer type pass to each type. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is still overly verbose. do something like.
|
||
integer_dtype_min_max = { | ||
'int8': [np.iinfo(np.int8).min, np.iinfo(np.int8).max], | ||
'int16': [np.iinfo(np.int16).min, np.iinfo(np.int16).max], | ||
'int32': [np.iinfo(np.int32).min, np.iinfo(np.int32).max], | ||
'int64': [np.iinfo(np.int64).min, np.iinfo(np.int64).max] | ||
} | ||
|
||
for dtype, min_max in integer_dtype_min_max.items(): | ||
series = pd.to_numeric(pd.Series(min_max), downcast = 'integer') | ||
tm.assert_equal(series.dtype, dtype) | ||
|
||
|
||
unsigned_dtype_min_max = { | ||
'uint8': [np.iinfo(np.uint8).min, np.iinfo(np.uint8).max], | ||
'uint16': [np.iinfo(np.uint16).min, np.iinfo(np.uint16).max], | ||
'uint32': [np.iinfo(np.uint32).min, np.iinfo(np.uint32).max], | ||
# 'uint64': [np.iinfo(np.uint64).min, np.iinfo(np.uint64).max] | ||
} | ||
|
||
for dtype, min_max in unsigned_dtype_min_max.items(): | ||
series = pd.to_numeric(pd.Series(min_max), downcast = 'unsigned') | ||
tm.assert_equal(series.dtype, dtype) | ||
|
||
#check to see if the minimum number to shift integer types actually shifts | ||
|
||
integer_dtype_min_max_plus = { | ||
'int16': [np.iinfo(np.int8).min, np.iinfo(np.int8).max + 1], | ||
'int32': [np.iinfo(np.int16).min, np.iinfo(np.int16).max + 1], | ||
'int64': [np.iinfo(np.int32).min, np.iinfo(np.int32).max + 1], | ||
} | ||
|
||
for dtype, min_max in integer_dtype_min_max_plus.items(): | ||
series = pd.to_numeric(pd.Series(min_max), downcast = 'integer') | ||
tm.assert_equal(series.dtype, dtype) | ||
|
||
integer_dtype_min_max_minus = { | ||
'int16': [np.iinfo(np.int8).min - 1, np.iinfo(np.int16).max], | ||
'int32': [np.iinfo(np.int16).min - 1, np.iinfo(np.int32).max], | ||
'int64': [np.iinfo(np.int32).min - 1, np.iinfo(np.int64).max] | ||
} | ||
|
||
for dtype, min_max in integer_dtype_min_max_minus.items(): | ||
series = pd.to_numeric(pd.Series(min_max), downcast = 'integer') | ||
tm.assert_equal(series.dtype, dtype) | ||
|
||
unsigned_dtype_min_max_plus = { | ||
'uint16': [np.iinfo(np.uint8).min, np.iinfo(np.uint8).max + 1], | ||
'uint32': [np.iinfo(np.uint16).min, np.iinfo(np.uint16).max + 1], | ||
# 'uint64': [np.iinfo(np.uint32).min, np.iinfo(np.uint32).max + 1], | ||
} | ||
|
||
for dtype, min_max in unsigned_dtype_min_max_plus.items(): | ||
series = pd.to_numeric(pd.Series(min_max), downcast = 'unsigned') | ||
tm.assert_equal(series.dtype, dtype) | ||
|
||
if __name__ == '__main__': | ||
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'], | ||
exit=False) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
just make a single entry