Skip to content

Commit 2e8c824

Browse files
committed
ENH: Responded to review comments:
Changed default inputs in example transformer class Removed level of nesting in initializer of said class Moved out one test into a separate method
1 parent 904bd51 commit 2e8c824

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

examples/ticks_and_spines/tick_transform_formatter.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class LinearTransform:
3434
a linear transformation.
3535
"""
3636

37-
def __init__(self, in_start=None, in_end=None, out_start=None, out_end=None):
37+
def __init__(self, in_start=0.0, in_end=None, out_start=0.0, out_end=None):
3838
"""
3939
Sets up the transformation such that `in_start` gets mapped to
4040
`out_start` and `in_end` gets mapped to `out_end`. The following
@@ -56,24 +56,19 @@ def __init__(self, in_start=None, in_end=None, out_start=None, out_end=None):
5656
- both ends are missing: set ranges to 1.0
5757
- one end is missing: set it to the other end
5858
"""
59-
self._in_offset = 0.0 if in_start is None else in_start
60-
self._out_offset = 0.0 if out_start is None else out_start
61-
62-
if in_end is None:
63-
if out_end is None:
64-
self._in_scale = 1.0
65-
else:
66-
self._in_scale = out_end - self._in_offset
67-
else:
59+
if in_end is not None:
6860
self._in_scale = in_end - self._in_offset
69-
70-
if out_end is None:
71-
if in_end is None:
72-
self._out_scale = 1.0
73-
else:
74-
self._out_scale = in_end - self._out_offset
61+
elif out_end is None:
62+
self._in_scale = 1.0
7563
else:
64+
self._in_scale = out_end - self._in_offset
65+
66+
if out_end not is None:
7667
self._out_scale = out_end - self._out_offset
68+
elif in_end is None:
69+
self._out_scale = 1.0
70+
else:
71+
self._out_scale = in_end - self._out_offset
7772

7873
def __call__(self, x):
7974
"""
@@ -92,8 +87,7 @@ def __call__(self, x):
9287
if counts.min() < 0:
9388
counts += counts.min()
9489

95-
fig = plt.figure()
96-
ax1 = fig.add_subplot(111)
90+
fig, ax1 = plt.subplots()
9791
ax2 = fig.add_subplot(111, sharex=ax1, sharey=ax1, frameon=False)
9892

9993
ax1.plot(temp_C, counts, drawstyle='steps-mid')

lib/matplotlib/tests/test_ticker.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -719,9 +719,10 @@ def test_set_locs(self, fmt):
719719
assert fmt.locs == locs
720720
assert fmt.formatter.locs == xlocs
721721

722-
fmt.set_locs(None)
723-
assert fmt.locs is None
724-
assert fmt.formatter.locs is None
722+
def test_clear_locs(self, loc_fmt):
723+
loc_fmt.set_locs(None)
724+
assert loc_fmt.locs is None
725+
assert loc_fmt.formatter.locs is None
725726

726727
def test_fix_minus(self, fmt):
727728
val = '-19.0'

0 commit comments

Comments
 (0)