Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Already on GitHub?Sign in to your account

Merged
Changes from1 commit
Commits
Show all changes
25 commits
Select commitHold shift + click to select a range
5a550f2
ENH: Add the space_sep option to EngFormatter, and docstring updates
afvincentJun 6, 2016
722f5d6
FIX: force format_eng(-0.0) to be consistent with format_eng(0)
afvincentJun 6, 2016
3c221ff
Fix docstrings and comments (remove leading spaces)
afvincentJun 7, 2016
122cfa2
Simplify and move cleaning strip op. from 'format_eng' to '__call__'
afvincentJun 7, 2016
07f022d
DOC: update the api example engineering_formatter.py
afvincentJun 19, 2016
e371e5a
More extensive testing of EngFormatter (including 'space_sep' param)
afvincentFeb 11, 2017
3049a2d
space_sep=bool <- sep=string, and adapt tests
afvincentFeb 12, 2017
e0a2ec8
remove unnecessary trailing 'u' characters in strings
afvincentFeb 12, 2017
1621a2d
fix EngFormatter docstring: escape Unicode character codes
afvincentFeb 12, 2017
c82dcff
'fix' docstring: unindent and reorder bullet list + mention regular t…
afvincentFeb 12, 2017
f09a1b4
Update the example
afvincentFeb 12, 2017
dc9409b
fix test docstring PEP8 errors in test_ticker.py
afvincentFeb 12, 2017
0195beb
Add a 'whats_new' entry
afvincentFeb 12, 2017
3ec1dbd
docstring overhaul: fix bullet list and merge duplicated infos betwee…
afvincentFeb 13, 2017
cd2ac88
use named entities instead of raw unicode codes
afvincentAug 17, 2017
7f1422c
stop mixing C-style and format-based formatting
afvincentAug 17, 2017
aba7a7f
Small example tweaking to avoid label cluttering
afvincentAug 17, 2017
b75f20d
fix an issue with {:g} and str format
afvincentAug 17, 2017
41a69da
get rid of decimal.Decimal + fix rounding special cases like 999.9...
afvincentAug 19, 2017
556ec20
Fix the related rounding discrepancies in test_ticker
afvincentAug 19, 2017
a9af431
(try) fix(ing) an exception about raising an int to a negative power
afvincentAug 19, 2017
0bde03a
fix some anntzer's comments
afvincentAug 20, 2017
c98ba91
more complete handling of corner-case roundings + add proper tests
afvincentAug 20, 2017
60b95ab
Fix some additional remarks made by anntzer
afvincentAug 21, 2017
ac42b94
Deprecate passing a string as *num* argument
afvincentAug 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
PrevPrevious commit
NextNext commit
remove unnecessary trailing 'u' characters in strings
  • Loading branch information
@afvincent
afvincent committedAug 25, 2017
commite0a2ec87b59e432c638d87dc43a8d2bef2484c2c
40 changes: 20 additions & 20 deletionslib/matplotlib/tests/test_ticker.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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

[8]ページ先頭

©2009-2025 Movatter.jp