|
3 | 3 | import matplotlib.pyplot as plt |
4 | 4 | from matplotlib.scale import ( |
5 | 5 | AsinhScale, AsinhTransform, |
| 6 | + FuncScale, LogitScale, |
6 | 7 | LogTransform, InvertedLogTransform, |
7 | 8 | SymmetricalLogTransform) |
8 | 9 | import matplotlib.scale as mscale |
|
19 | 20 | import pytest |
20 | 21 |
|
21 | 22 |
|
| 23 | +def test_optional_axis_signature(): |
| 24 | + # There are three types of original signatures possible, and this only tests one |
| 25 | + # example class of each: |
| 26 | + # 1. `axis` without default: LinearScale, FuncScale, FuncScaleLog |
| 27 | + # 2. `axis` with default and more positional parameters: LogitScale |
| 28 | + # 3. `axis` with default and only keyword-only parameters: LogScale, AsinhScale, |
| 29 | + # SymmetricalLogScale |
| 30 | + # Testing with None is sufficient as detection is purely based on the |
| 31 | + # signature structure; no type information is involved. |
| 32 | + axis = None |
| 33 | + |
| 34 | + # Old signature with axis positionally. |
| 35 | + FuncScale(axis, (lambda x: x, lambda x: x)) |
| 36 | + FuncScale(axis, functions=(lambda x: x, lambda x: x)) |
| 37 | + LogitScale(axis) |
| 38 | + LogitScale(axis, 'clip') |
| 39 | + LogitScale(axis, nonpositive='clip') |
| 40 | + LogitScale(axis, use_overline=True) |
| 41 | + AsinhScale(axis) |
| 42 | + AsinhScale(axis, linear_width=2) |
| 43 | + AsinhScale(axis, base=3) |
| 44 | + AsinhScale(axis, subs=[2, 6]) |
| 45 | + # Old signature with axis as keyword. |
| 46 | + FuncScale(axis=axis, functions=(lambda x: x, lambda x: x)) |
| 47 | + LogitScale(axis=axis) |
| 48 | + LogitScale(axis=axis, nonpositive='clip') |
| 49 | + LogitScale(axis=axis, use_overline=True) |
| 50 | + AsinhScale(axis=axis) |
| 51 | + AsinhScale(axis=axis, linear_width=2) |
| 52 | + AsinhScale(axis=axis, base=3) |
| 53 | + AsinhScale(axis=axis, subs=[2, 6]) |
| 54 | + # New signature without axis. |
| 55 | + FuncScale((lambda x: x, lambda x: x)) |
| 56 | + FuncScale(functions=(lambda x: x, lambda x: x)) |
| 57 | + LogitScale() |
| 58 | + LogitScale(nonpositive='clip') |
| 59 | + LogitScale(use_overline=True) |
| 60 | + AsinhScale() |
| 61 | + AsinhScale(linear_width=2) |
| 62 | + AsinhScale(base=3) |
| 63 | + AsinhScale(subs=[2, 6]) |
| 64 | + |
| 65 | + |
22 | 66 | @check_figures_equal() |
23 | 67 | def test_log_scales(fig_test, fig_ref): |
24 | 68 | ax_test = fig_test.add_subplot(122, yscale='log', xscale='symlog') |
|
0 commit comments