MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_loglocator_properties

Function test_loglocator_properties

lib/matplotlib/tests/test_ticker.py:1961–1983  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1959
1960@mpl.style.context('default')
1961def test_loglocator_properties():
1962 # Test that LogLocator returns ticks satisfying basic desirable properties
1963 # for a wide range of inputs.
1964 max_numticks = 8
1965 pow_end = 20
1966 for numticks, (lo, hi) in itertools.product(
1967 range(1, max_numticks + 1), itertools.combinations(range(pow_end), 2)):
1968 ll = mticker.LogLocator(numticks=numticks)
1969 decades = np.log10(ll.tick_values(10**lo, 10**hi)).round().astype(int)
1970 # There are no more ticks than the requested number, plus exactly one
1971 # tick below and one tick above the limits.
1972 assert len(decades) <= numticks + 2
1973 assert decades[0] < lo <= decades[1]
1974 assert decades[-2] <= hi < decades[-1]
1975 stride, = {*np.diff(decades)} # Extract the (constant) stride.
1976 # Either the ticks are on integer multiples of the stride...
1977 if not (decades % stride == 0).all():
1978 # ... or (for this given stride) no offset would be acceptable,
1979 # i.e. they would either result in fewer ticks than the selected
1980 # solution, or more than the requested number of ticks.
1981 for offset in range(0, stride):
1982 alt_decades = range(lo + offset, hi + 1, stride)
1983 assert len(alt_decades) < len(decades) or len(alt_decades) > numticks
1984
1985
1986def test_NullFormatter():

Callers

nothing calls this directly

Calls 1

tick_valuesMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…