Skip to content

Commit

Permalink
Merge pull request #726 from wireservice/infinityerror
Browse files Browse the repository at this point in the history
Don't calculate precision of infinity
  • Loading branch information
jpmckinney committed Sep 28, 2019
2 parents e3078dc + adf37bf commit cfb165b
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion .travis.yml
@@ -1,7 +1,6 @@
language: python
python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "3.6"
Expand Down
3 changes: 2 additions & 1 deletion agate/table/print_table.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# pylint: disable=W0212

import math
import sys

from babel.numbers import format_decimal
Expand Down Expand Up @@ -95,7 +96,7 @@ def print_table(self, max_rows=20, max_columns=6, output=sys.stdout, max_column_
v = ellipsis
elif v is None:
v = ''
elif number_formatters[j] is not None:
elif number_formatters[j] is not None and not math.isinf(v):
v = format_decimal(
v,
format=number_formatters[j],
Expand Down
2 changes: 1 addition & 1 deletion agate/utils.py
Expand Up @@ -133,7 +133,7 @@ def max_precision(values):
precision = getcontext().prec

for value in values:
if value is None or math.isnan(value):
if value is None or math.isnan(value) or math.isinf(value):
continue

sign, digits, exponent = value.normalize().as_tuple()
Expand Down
2 changes: 1 addition & 1 deletion docs/install.rst
Expand Up @@ -45,7 +45,7 @@ Supported platforms
agate supports the following versions of Python:

* Python 2.7
* Python 3.3+
* Python 3.4+
* `PyPy <http://pypy.org/>`_ versions >= 4.0.0

It is tested primarily on OSX, but due to its minimal dependencies it should work perfectly on both Linux and Windows.
Expand Down
1 change: 0 additions & 1 deletion setup.py
Expand Up @@ -33,7 +33,6 @@
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
Expand Down

0 comments on commit cfb165b

Please sign in to comment.