Skip to content

add check for infinity in __call__ of EngFormatter #14214

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 2 commits into from

Conversation

swfiua
Copy link
Contributor

@swfiua swfiua commented Sep 13, 2016

EngFormatter throws an exception if passed 'inf' as below.

This patch checks for infinity and just returns 'inf' in that case. The fix is analagous to the recent fix for NaN:

d0734ba

import pandas
import pandas.core.format as fmt

ef = fmt.EngFormatter()
ef(pandas.np.inf)

...

OverflowError Traceback (most recent call last)
in ()
3
4 ef = fmt.EngFormatter()
----> 5 ef(pandas.np.inf)

/usr/lib/python3/dist-packages/pandas/core/format.py in call(self, num)
2485
2486 if dnum != 0:
-> 2487 pow10 = decimal.Decimal(int(math.floor(dnum.log10() / 3) * 3))
2488 else:
2489 pow10 = decimal.Decimal(0)

OverflowError: cannot convert Infinity to integer

@jreback
Copy link
Contributor

jreback commented Sep 13, 2016

tests pls

@codecov-io
Copy link

codecov-io commented Sep 13, 2016

Current coverage is 85.23% (diff: 50.00%)

Merging #14214 into master will increase coverage by <.01%

@@             master     #14214   diff @@
==========================================
  Files           140        140          
  Lines         50566      50568     +2   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          43102      43104     +2   
  Misses         7464       7464          
  Partials          0          0          

Powered by Codecov. Last update f363236...83f4091

@jreback jreback added Bug Output-Formatting __repr__ of pandas objects, to_string labels Sep 13, 2016
@jreback jreback added this to the 0.19.0 milestone Sep 13, 2016
@jreback
Copy link
Contributor

jreback commented Sep 13, 2016

thanks!

@jreback jreback closed this in 48ad2f4 Sep 13, 2016
@swfiua
Copy link
Contributor Author

swfiua commented Sep 13, 2016

A pleasure. Pandas is magic.

On 13 Sep 2016 19:00, "Jeff Reback" [email protected] wrote:

thanks!


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#14214 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAPW25I6CyKwwpIw8sAuzo3JBXKDx9z-ks5qpxzzgaJpZM4J8CRc
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants