Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tabulate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1021,8 +1021,11 @@ def _afterpoint(string):
2
>>> _afterpoint("123,456.78")
2
>>> _afterpoint(" 123,456.78 ")
2

"""
string = string.strip()
if _isnumber(string) or _isnumber_with_thousands_separator(string):
if _isint(string):
return -1
Expand Down
10 changes: 10 additions & 0 deletions test/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,16 @@ def test_column_with_mixed_value_types():
assert_equal(table, expected)


def test_decimal_alignment_with_thousands_separator():
"Regression: decimal alignment must work for comma-grouped floats (issue #248)"
result = tabulate([[34454634.345], [3.0]], headers=["doesnt work"], floatfmt="17,.4f", tablefmt="simple")
rows = [row for row in result.splitlines() if "." in row and any(c.isdigit() for c in row)]
assert len(rows) == 2
# the decimal points of both rows must sit in the same column
dot_cols = {row.index(".") for row in rows}
assert len(dot_cols) == 1


def test_latex_escape_special_chars():
"Regression: escape special characters in LaTeX output (issue #32)"
expected = "\n".join(
Expand Down