| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d4f0963 commit 5981aa4
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -130,6 +130,14 @@ def test_view_limits_round_numbers_with_offset(self): | |||
| 130 | 130 | loc = mticker.MultipleLocator(base=3.147, offset=1.3) | |
| 131 | 131 | assert_almost_equal(loc.view_limits(-4, 4), (-4.994, 4.447)) | |
| 132 | 132 | ||
| 133 | + def test_view_limits_single_bin(self): | ||
| 134 | + """ | ||
| 135 | + Test that 'round_numbers' works properly with a single bin. | ||
| 136 | + """ | ||
| 137 | + with mpl.rc_context({'axes.autolimit_mode': 'round_numbers'}): | ||
| 138 | + loc = mticker.MaxNLocator(nbins=1) | ||
| 139 | + assert_almost_equal(loc.view_limits(-2.3, 2.3), (-4, 4)) | ||
| 140 | + | ||
| 133 | 141 | def test_set_params(self): | |
| 134 | 142 | """ | |
| 135 | 143 | Create multiple locator with 0.7 base, and change it to something else. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2137,7 +2137,10 @@ def _raw_ticks(self, vmin, vmax): | |||
| 2137 | 2137 | large_steps = large_steps & (floored_vmaxs >= _vmax) | |
| 2138 | 2138 | ||
| 2139 | 2139 | # Find index of smallest large step | |
| 2140 | - istep = np.nonzero(large_steps)[0][0] | ||
| 2140 | + if any(large_steps): | ||
| 2141 | + istep = np.nonzero(large_steps)[0][0] | ||
| 2142 | + else: | ||
| 2143 | + istep = len(steps) - 1 | ||
| 2141 | 2144 | ||
| 2142 | 2145 | # Start at smallest of the steps greater than the raw step, and check | |
| 2143 | 2146 | # if it provides enough ticks. If not, work backwards through | |
| Back | FazBrowse Home | New Git URL |
0 commit comments