BUG: Fix for to_excel +/- infinity by maxchang · Pull Request #7949 · pandas-dev/pandas (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation7 Commits1 Checks0 Files changed

Conversation

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

[ Show hidden characters]({{ revealButtonHref }})

maxchang

BUG: Previously, a negative sign was being prepended for positive infinity, not for negative infinity. (GH6812)

xref #6812

@jreback

jreback

@@ -122,6 +122,10 @@ cpdef assert_almost_equal(a, b, bint check_less_precise=False):
if np.isinf(a):
assert np.isinf(b), "First object is inf, second isn't"
if np.isposinf(a):

Choose a reason for hiding this comment

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

why did you add this?

@jreback

status of this? (did you see my comments above)?

@maxchang

There was an existing test (test_inf_roundtrip() in test_excel.py) that wrote/read a frame with positive and negative infinity, but it was not catching the error due to an oversight in the underlying comparison. In testing.pyx, assert_almost_equal() was only looking for infinite values, regardless of +/-. Adding the check for +/- there allows test_inf_roundtrip() to work as expected.

@jreback

@maxchang ok, makes sense.

pls rebase and squash and then I think good to go

@maxchang

Previously, a negative sign was being prepended to positive infinite values and was absent for negative infinity. (GH6812)

TST: assert_almost_equals() checks +/- infinity

The existing test_inf_roundtrip should have caught this bug, but the underlying assert_almost_equal was not checking that the two given values were both positive or negative.

@maxchang

@jreback

2 participants

@maxchang @jreback