Skip to content

Commit b2c35fa

Browse files
committed
test_engformatter_offset_oom: parametrize center & noise directly
1 parent b7c6f90 commit b2c35fa

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

lib/matplotlib/tests/test_ticker.py

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,40 +1592,38 @@ def test_engformatter_usetex_useMathText():
15921592

15931593

15941594
@pytest.mark.parametrize(
1595-
'oom_center, oom_noise, oom_center_desired, oom_noise_desired', [
1596-
(11, 1, 9, 0),
1597-
(13, 7, 12, 6),
1598-
(1, -2, 0, -3),
1599-
(3, -2, 3, -3),
1600-
(5, -3, 3, -3),
1601-
(2, -3, 0, -3),
1602-
# The following sets of parameters demonstrates that when oom_center-1
1603-
# and oom_noise-2 equal a standard 3*N oom, we get that
1604-
# oom_noise_desired < oom_noise
1605-
(10, 2, 9, 3),
1606-
(1, -7, 0, -6),
1607-
(2, -4, 0, -3),
1608-
(1, -4, 0, -3),
1609-
# Tests where oom_center <= oom_noise, those are probably covered by the
1610-
# part where formatter.offset != 0
1611-
(4, 4, 0, 3),
1612-
(1, 4, 0, 3),
1613-
(1, 3, 0, 3),
1614-
(1, 2, 0, 0),
1615-
(1, 1, 0, 0),
1595+
'data_offset, noise, oom_center_desired, oom_noise_desired', [
1596+
(271_490_000_000.0, 10, 9, 0),
1597+
(27_149_000_000_000.0, 10_000_000, 12, 6),
1598+
(27.149, 0.01, 0, -3),
1599+
(2_714.9, 0.01, 3, -3),
1600+
(271_490.0, 0.001, 3, -3),
1601+
(271.49, 0.001, 0, -3),
1602+
# The following sets of parameters demonstrates that when
1603+
# oom(data_offset)-1 and oom(noise)-2 equal a standard 3*N oom, we get
1604+
# that oom_noise_desired < oom(noise)
1605+
(27_149_000_000.0, 100, 9, +3),
1606+
(27.149, 1e-07, 0, -6),
1607+
(271.49, 0.0001, 0, -3),
1608+
(27.149, 0.0001, 0, -3),
1609+
# Tests where oom(data_offset) <= oom(noise), those are probably
1610+
# covered by the part where formatter.offset != 0
1611+
(27_149.0, 10_000, 0, 3),
1612+
(27.149, 10_000, 0, 3),
1613+
(27.149, 1_000, 0, 3),
1614+
(27.149, 100, 0, 0),
1615+
(27.149, 10, 0, 0),
16161616
]
16171617
)
16181618
def test_engformatter_offset_oom(
1619-
oom_center,
1620-
oom_noise,
1619+
data_offset,
1620+
noise,
16211621
oom_center_desired,
16221622
oom_noise_desired
16231623
):
16241624
UNIT = "eV"
16251625
fig, ax = plt.subplots()
1626-
# Use some random ugly number
1627-
data_offset = 2.7149*10**oom_center
1628-
ydata = data_offset + np.arange(-5, 7, dtype=float)*10**oom_noise
1626+
ydata = data_offset + np.arange(-5, 7, dtype=float)*noise
16291627
ax.plot(ydata)
16301628
formatter = mticker.EngFormatter(useOffset=True, unit=UNIT)
16311629
# So that offset strings will always have the same size

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy