|
2 | 2 |
|
3 | 3 | import matplotlib.pyplot as plt
|
4 | 4 | from matplotlib.scale import (
|
5 |
| - AsinhTransform, |
| 5 | + AsinhScale, AsinhTransform, |
6 | 6 | LogTransform, InvertedLogTransform,
|
7 | 7 | SymmetricalLogTransform)
|
8 | 8 | import matplotlib.scale as mscale
|
@@ -222,17 +222,38 @@ def test_scale_deepcopy():
|
222 | 222 | assert sc._transform is not sc2._transform
|
223 | 223 |
|
224 | 224 |
|
225 |
| -def test_asinh_transforms(): |
226 |
| - a0 = 17.0 |
227 |
| - a = np.linspace(-50, 50, 100) |
| 225 | +class TestAsinhScale: |
| 226 | + def test_transforms(self): |
| 227 | + a0 = 17.0 |
| 228 | + a = np.linspace(-50, 50, 100) |
228 | 229 |
|
229 |
| - forward = AsinhTransform(a0) |
230 |
| - inverse = forward.inverted() |
231 |
| - invinv = inverse.inverted() |
| 230 | + forward = AsinhTransform(a0) |
| 231 | + inverse = forward.inverted() |
| 232 | + invinv = inverse.inverted() |
232 | 233 |
|
233 |
| - a_forward = forward.transform_non_affine(a) |
234 |
| - a_inverted = inverse.transform_non_affine(a_forward) |
235 |
| - assert_allclose(a_inverted, a) |
| 234 | + a_forward = forward.transform_non_affine(a) |
| 235 | + a_inverted = inverse.transform_non_affine(a_forward) |
| 236 | + assert_allclose(a_inverted, a) |
236 | 237 |
|
237 |
| - a_invinv = invinv.transform_non_affine(a) |
238 |
| - assert_allclose(a_invinv, a0 * np.asinh(a / a0)) |
| 238 | + a_invinv = invinv.transform_non_affine(a) |
| 239 | + assert_allclose(a_invinv, a0 * np.arcsinh(a / a0)) |
| 240 | + |
| 241 | + def test_init(self): |
| 242 | + fig, ax = plt.subplots() |
| 243 | + |
| 244 | + s = AsinhScale(axis=None, linear_width=23.0) |
| 245 | + assert s.linear_width == 23 |
| 246 | + |
| 247 | + tx = s.get_transform() |
| 248 | + assert isinstance(tx, AsinhTransform) |
| 249 | + assert tx.linear_width == s.linear_width |
| 250 | + |
| 251 | + def test_bad_scale(self): |
| 252 | + fig, ax = plt.subplots() |
| 253 | + |
| 254 | + with pytest.raises(ValueError): |
| 255 | + AsinhScale(axis=None, linear_width=0) |
| 256 | + with pytest.raises(ValueError): |
| 257 | + AsinhScale(axis=None, linear_width=-1) |
| 258 | + s0 = AsinhScale(axis=None, ) |
| 259 | + s1 = AsinhScale(axis=None, linear_width=3.0) |
0 commit comments