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

Method test_minor

lib/matplotlib/tests/test_ticker.py:511–534  ·  view source on GitHub ↗

In large scale, test the presence of minor, and assert no minor when major are subsampled.

(self, lims, expected_low_ticks)

Source from the content-addressed store, hash-verified

509 zip(ref_basic_limits, ref_basic_major_ticks),
510 )
511 def test_minor(self, lims, expected_low_ticks):
512 """
513 In large scale, test the presence of minor,
514 and assert no minor when major are subsampled.
515 """
516
517 expected_ticks = sorted(
518 [*expected_low_ticks, 0.5, *(1 - expected_low_ticks)]
519 )
520 basic_needed = len(expected_ticks)
521 loc = mticker.LogitLocator(nbins=100)
522 minor_loc = mticker.LogitLocator(nbins=100, minor=True)
523 for nbins in range(basic_needed, 2, -1):
524 loc.set_params(nbins=nbins)
525 minor_loc.set_params(nbins=nbins)
526 major_ticks = loc.tick_values(*lims)
527 minor_ticks = minor_loc.tick_values(*lims)
528 if len(major_ticks) >= len(expected_ticks):
529 # no subsample, we must have a lot of minors ticks
530 assert (len(major_ticks) - 1) * 5 < len(minor_ticks)
531 else:
532 # subsample
533 _LogitHelper.assert_almost_equal(
534 sorted([*major_ticks, *minor_ticks]), expected_ticks)
535
536 def test_minor_attr(self):
537 loc = mticker.LogitLocator(nbins=100)

Callers

nothing calls this directly

Calls 3

set_paramsMethod · 0.95
tick_valuesMethod · 0.95
assert_almost_equalMethod · 0.80

Tested by

no test coverage detected