Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4f8dc92

Browse files
committed
Add test for LogFormatter with very big numbers
Reported at #27609 . Values < 1e300 that trigger this test failure might be found, but it should be a bit better not to be on the edge of this issue.
1 parent 4a59114 commit 4f8dc92

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lib/matplotlib/tests/test_ticker.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,6 +1843,27 @@ def test_small_range_loglocator(numticks):
18431843
assert (np.diff(np.log10(ll.tick_values(6, 150))) == 1).all()
18441844

18451845

1846+
# https://github.com/matplotlib/matplotlib/pull/27609
1847+
# TODO: This test currently fails, as expected and it needs to be fixed...
1848+
# To do this completely correctly, we should figure out what are our limits
1849+
# for when do integers are interpreted eventually as infinities and why,
1850+
# and perhaps always work with np.float128 to increase accuracy as much as
1851+
# possible. Eitherway, we should document what is our limit and how it is
1852+
# related to the accuracy of np.float{64,128} and Python's native float
1853+
# which seems to be the same as np.float64 for this purpose...
1854+
def test_LogFormatter_almost_inf():
1855+
fig, ax = plt.subplots()
1856+
# TODO: Figure out why 1e400 won't fail, but will make the ax.plot describe
1857+
# 1e400 as inf (and hence not print it, and hence not fail).
1858+
ax.plot([1,2], [1, 1e300])
1859+
ax.set_yscale("log")
1860+
fig.draw_without_rendering()
1861+
almost_inf = ax.get_lines()[0].get_ydata()[1]
1862+
# TODO/WIP: remove of course when the above TODOs are fixed. Perhaps assert
1863+
# something with ydata...
1864+
assert True == False
1865+
1866+
18461867
def test_NullFormatter():
18471868
formatter = mticker.NullFormatter()
18481869
assert formatter(1.0) == ''

0 commit comments

Comments
 (0)