-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Fix precise_xstrtod segfault on long exponent #38789
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f42b65a
WIP
mzeitlin11 bb77ab2
BUG: precise_xstrtod segfault
mzeitlin11 3a0ac2e
Fix typo
mzeitlin11 7b0cc62
Fix whatsnew
mzeitlin11 1011a1b
Parameterize test
mzeitlin11 39dd79c
Fix quotes
mzeitlin11 58bbed5
xfail inconsistent test
mzeitlin11 0f5f103
Add issue number to xfail
mzeitlin11 013a31f
Fix merge conflict
mzeitlin11 0a48ed8
Keep extra line
mzeitlin11 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
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 |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
import pytest | ||
|
||
from pandas._libs.tslib import Timestamp | ||
from pandas.compat import is_platform_linux | ||
from pandas.errors import DtypeWarning, EmptyDataError, ParserError | ||
import pandas.util._test_decorators as td | ||
|
||
|
@@ -1259,15 +1260,14 @@ def test_float_parser(all_parsers): | |
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
def test_scientific_no_exponent(all_parsers): | ||
def test_scientific_no_exponent(all_parsers_all_precisions): | ||
# see gh-12215 | ||
df = DataFrame.from_dict({"w": ["2e"], "x": ["3E"], "y": ["42e"], "z": ["632E"]}) | ||
data = df.to_csv(index=False) | ||
parser = all_parsers | ||
parser, precision = all_parsers_all_precisions | ||
|
||
for precision in parser.float_precision_choices: | ||
df_roundtrip = parser.read_csv(StringIO(data), float_precision=precision) | ||
tm.assert_frame_equal(df_roundtrip, df) | ||
df_roundtrip = parser.read_csv(StringIO(data), float_precision=precision) | ||
tm.assert_frame_equal(df_roundtrip, df) | ||
|
||
|
||
@pytest.mark.parametrize("conv", [None, np.int64, np.uint64]) | ||
|
@@ -1351,6 +1351,35 @@ def test_numeric_range_too_wide(all_parsers, exp_data): | |
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
@pytest.mark.parametrize("neg_exp", [-617, -100000, -99999999999999999]) | ||
def test_very_negative_exponent(all_parsers_all_precisions, neg_exp): | ||
# GH#38753 | ||
parser, precision = all_parsers_all_precisions | ||
data = f"data\n10E{neg_exp}" | ||
result = parser.read_csv(StringIO(data), float_precision=precision) | ||
expected = DataFrame({"data": [0.0]}) | ||
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
@pytest.mark.parametrize("exp", [999999999999999999, -999999999999999999]) | ||
def test_too_many_exponent_digits(all_parsers_all_precisions, exp, request): | ||
# GH#38753 | ||
parser, precision = all_parsers_all_precisions | ||
data = f"data\n10E{exp}" | ||
result = parser.read_csv(StringIO(data), float_precision=precision) | ||
if precision == "round_trip": | ||
if exp == 999999999999999999 and is_platform_linux(): | ||
mark = pytest.mark.xfail(reason="GH38794, on Linux gives object result") | ||
request.node.add_marker(mark) | ||
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 discrepancy is unrelated, occurs on master, have opened #38794 for it 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. kk can you put the issue number in the xfail itself. |
||
|
||
value = np.inf if exp > 0 else 0.0 | ||
expected = DataFrame({"data": [value]}) | ||
else: | ||
expected = DataFrame({"data": [f"10E{exp}"]}) | ||
|
||
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
@pytest.mark.parametrize("iterator", [True, False]) | ||
def test_empty_with_nrows_chunksize(all_parsers, iterator): | ||
# see gh-9535 | ||
|
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.
Uh oh!
There was an error while loading. Please reload this page.