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

Commite3f721f

Browse files
committed
Response to review comments
1 parent37b7993 commite3f721f

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

‎lib/matplotlib/tests/test_ticker.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -582,23 +582,27 @@ def test_percentformatter(self, xmax, decimals, symbol,
582582

583583

584584
classTestEngFormatter(object):
585-
deftest_formatting(self):
586-
"""
587-
Create two instances of EngFormatter with default parameters, with and
588-
without a unit string ('s' for seconds). Test the formatting in some
589-
cases, especially the case when no SI prefix is present, for values in
590-
[1, 1000).
585+
unit_data= ['',u's']
586+
587+
input_data= [0.1,1,999.9,1001]
588+
589+
format_data= [
590+
('',0.1,u'100 m'),
591+
('',1,u'1'),
592+
('',999.9,u'999.9'),
593+
('',1001,u'1.001 k'),
594+
(u's',0.1,u'100 ms'),
595+
(u's',1,u'1 s'),
596+
(u's',999.9,u'999.9 s'),
597+
(u's',1001,u'1.001 ks'),
598+
]
591599

592-
Should not raise exceptions.
600+
@pytest.mark.parametrize('unit, input, expected',format_data)
601+
deftest_formatting(self,unit,input,expected):
602+
"""
603+
Test the formatting of EngFormatter with some inputs, against
604+
instances with and without units. Cases focus on when no SI
605+
prefix is present, for values in [1, 1000).
593606
"""
594-
unitless=mticker.EngFormatter()
595-
assertunitless(0.1)==u'100 m'
596-
assertunitless(1)==u'1'
597-
assertunitless(999.9)==u'999.9'
598-
assertunitless(1001)==u'1.001 k'
599-
600-
with_unit=mticker.EngFormatter(unit=u's')
601-
assertwith_unit(0.1)==u'100 ms'
602-
assertwith_unit(1)==u'1 s'
603-
assertwith_unit(999.9)==u'999.9 s'
604-
assertwith_unit(1001)==u'1.001 ks'
607+
fmt=mticker.EngFormatter(unit)
608+
assertfmt(input)==expected

‎lib/matplotlib/ticker.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,20 @@
88
minor tick locating and formatting. Generic tick locators and
99
formatters are provided, as well as domain specific custom ones.
1010
11-
1211
Default Formatter
1312
-----------------
1413
1514
The default formatter identifies when the x-data being
1615
plotted is a small range on top of a large off set. To
1716
reduce the chances that the ticklabels overlap the ticks
18-
are labeled as deltas from a fixed offset.For example::
17+
are labeled as deltas from a fixed offset. For example::
1918
2019
ax.plot(np.arange(2000, 2010), range(10))
2120
2221
will have tick of 0-9 with an offset of +2e3. If this
2322
is not desired turn off the use of the offset on the default
2423
formatter::
2524
26-
2725
ax.get_xaxis().get_major_formatter().set_useOffset(False)
2826
2927
set the rcParam ``axes.formatter.useoffset=False`` to turn it off

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp