Skip to content

ENH: EngFormatter new kwarg 'sep' #6542

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 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5a550f2
ENH: Add the space_sep option to EngFormatter, and docstring updates
afvincent Jun 6, 2016
722f5d6
FIX: force format_eng(-0.0) to be consistent with format_eng(0)
afvincent Jun 6, 2016
3c221ff
Fix docstrings and comments (remove leading spaces)
afvincent Jun 7, 2016
122cfa2
Simplify and move cleaning strip op. from 'format_eng' to '__call__'
afvincent Jun 7, 2016
07f022d
DOC: update the api example engineering_formatter.py
afvincent Jun 19, 2016
e371e5a
More extensive testing of EngFormatter (including 'space_sep' param)
afvincent Feb 11, 2017
3049a2d
space_sep=bool <- sep=string, and adapt tests
afvincent Feb 12, 2017
e0a2ec8
remove unnecessary trailing 'u' characters in strings
afvincent Feb 12, 2017
1621a2d
fix EngFormatter docstring: escape Unicode character codes
afvincent Feb 12, 2017
c82dcff
'fix' docstring: unindent and reorder bullet list + mention regular t…
afvincent Feb 12, 2017
f09a1b4
Update the example
afvincent Feb 12, 2017
dc9409b
fix test docstring PEP8 errors in test_ticker.py
afvincent Feb 12, 2017
0195beb
Add a 'whats_new' entry
afvincent Feb 12, 2017
3ec1dbd
docstring overhaul: fix bullet list and merge duplicated infos betwee…
afvincent Feb 13, 2017
cd2ac88
use named entities instead of raw unicode codes
afvincent Aug 17, 2017
7f1422c
stop mixing C-style and format-based formatting
afvincent Aug 17, 2017
aba7a7f
Small example tweaking to avoid label cluttering
afvincent Aug 17, 2017
b75f20d
fix an issue with {:g} and str format
afvincent Aug 17, 2017
41a69da
get rid of decimal.Decimal + fix rounding special cases like 999.9...
afvincent Aug 19, 2017
556ec20
Fix the related rounding discrepancies in test_ticker
afvincent Aug 19, 2017
a9af431
(try) fix(ing) an exception about raising an int to a negative power
afvincent Aug 19, 2017
0bde03a
fix some anntzer's comments
afvincent Aug 20, 2017
c98ba91
more complete handling of corner-case roundings + add proper tests
afvincent Aug 20, 2017
60b95ab
Fix some additional remarks made by anntzer
afvincent Aug 21, 2017
ac42b94
Deprecate passing a string as *num* argument
afvincent Aug 24, 2017
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
Prev Previous commit
Next Next commit
remove unnecessary trailing 'u' characters in strings
  • Loading branch information
afvincent committed Aug 25, 2017
commit e0a2ec87b59e432c638d87dc43a8d2bef2484c2c
40 changes: 20 additions & 20 deletions lib/matplotlib/tests/test_ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,23 +552,23 @@ class TestEngFormatter(object):
# (input, expected) where ''expected'' corresponds to the outputs
# respectively returned when (places=None, places=0, places=2)
raw_format_data = [
(-1234.56789, (u'-1.23457 k', u'-1 k', u'-1.23 k')),
(-1.23456789, (u'-1.23457', u'-1', u'-1.23')),
(-0.123456789, (u'-123.457 m', u'-123 m', u'-123.46 m')),
(-0.00123456789, (u'-1.23457 m', u'-1 m', u'-1.23 m')),
(-0.0, (u'0', u'0', u'0.00')),
(-0, (u'0', u'0', u'0.00')),
(0, (u'0', u'0', u'0.00')),
(1.23456789e-6, (u'1.23457 \u03bc', u'1 \u03bc', u'1.23 \u03bc')),
(0.123456789, (u'123.457 m', u'123 m', u'123.46 m')),
(0.1, (u'100 m', u'100 m', u'100.00 m')),
(1, (u'1', u'1', u'1.00')),
(1.23456789, (u'1.23457', u'1', u'1.23')),
(999.9, (u'999.9', u'999', u'999.90')),
(1000, (u'1 k', u'1 k', u'1.00 k')),
(1001, (u'1.001 k', u'1 k', u'1.00 k')),
(100001, (u'100.001 k', u'100 k', u'100.00 k')),
(987654.321, (u'987.654 k', u'987 k', u'987.65 k'))
(-1234.56789, ('-1.23457 k', '-1 k', '-1.23 k')),
(-1.23456789, ('-1.23457', '-1', '-1.23')),
(-0.123456789, ('-123.457 m', '-123 m', '-123.46 m')),
(-0.00123456789, ('-1.23457 m', '-1 m', '-1.23 m')),
(-0.0, ('0', '0', '0.00')),
(-0, ('0', '0', '0.00')),
(0, ('0', '0', '0.00')),
(1.23456789e-6, ('1.23457 \u03bc', '1 \u03bc', '1.23 \u03bc')),
(0.123456789, ('123.457 m', '123 m', '123.46 m')),
(0.1, ('100 m', '100 m', '100.00 m')),
(1, ('1', '1', '1.00')),
(1.23456789, ('1.23457', '1', '1.23')),
(999.9, ('999.9', '999', '999.90')),
(1000, ('1 k', '1 k', '1.00 k')),
(1001, ('1.001 k', '1 k', '1.00 k')),
(100001, ('100.001 k', '100 k', '100.00 k')),
(987654.321, ('987.654 k', '987 k', '987.65 k'))
]

@pytest.mark.parametrize('input, expected', raw_format_data)
Expand All @@ -582,8 +582,8 @@ def test_params(self, input, expected):
3. with neihter a unit nor a space separator.
"""

UNIT = u's' # seconds
DIGITS = u'0123456789' # %timeit showed 10-20% faster search than set
UNIT = 's' # seconds
DIGITS = '0123456789' # %timeit showed 10-20% faster search than set

# Case 0: unit='' (default) and sep=' ' (default).
# 'expected' already corresponds to this reference case.
Expand All @@ -599,7 +599,7 @@ def test_params(self, input, expected):
# Case 1: unit=UNIT and sep=' ' (default).
# Append a unit symbol to the reference case.
# Beware of the values in [1, 1000), where there is no prefix!
exp_outputs = (_s + u" " + UNIT if _s[-1] in DIGITS # case w/o prefix
exp_outputs = (_s + " " + UNIT if _s[-1] in DIGITS # case w/o prefix
else _s + UNIT for _s in expected)
formatters = (
mticker.EngFormatter(unit=UNIT), # places=None (default)
Expand Down