From 143f700a56ff464acad411364821e7fe2c72ef13 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Wed, 3 Apr 2019 00:10:00 +0200 Subject: [PATCH] `a and b or c` -> `b if a else c` --- examples/tests/backend_driver_sgskip.py | 2 +- lib/matplotlib/axes/_axes.py | 14 +++++++------- lib/matplotlib/hatch.py | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/tests/backend_driver_sgskip.py b/examples/tests/backend_driver_sgskip.py index 8878c6273bce..46f25f7019fc 100644 --- a/examples/tests/backend_driver_sgskip.py +++ b/examples/tests/backend_driver_sgskip.py @@ -418,7 +418,7 @@ def drive(backend, directories, python=['python'], switches=[]): def parse_options(): - doc = (__doc__ and __doc__.split('\n\n')) or " " + doc = __doc__.split("\n\n") if __doc__ else " " op = OptionParser(description=doc[0].strip(), usage='%prog [options] [--] [backends and switches]', #epilog='\n'.join(doc[1:]) # epilog not supported on my python2.4 machine: JDH diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 4630a7568818..d414d5771cdc 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -2996,17 +2996,17 @@ def get_next_color(): if labeldistance is not None: xt = x + labeldistance * radius * math.cos(thetam) yt = y + labeldistance * radius * math.sin(thetam) - label_alignment_h = xt > 0 and 'left' or 'right' + label_alignment_h = 'left' if xt > 0 else 'right' label_alignment_v = 'center' label_rotation = 'horizontal' if rotatelabels: - label_alignment_v = yt > 0 and 'bottom' or 'top' - label_rotation = np.rad2deg(thetam) + (0 if xt > 0 - else 180) + label_alignment_v = 'bottom' if yt > 0 else 'top' + label_rotation = (np.rad2deg(thetam) + + (0 if xt > 0 else 180)) props = dict(horizontalalignment=label_alignment_h, - verticalalignment=label_alignment_v, - rotation=label_rotation, - size=rcParams['xtick.labelsize']) + verticalalignment=label_alignment_v, + rotation=label_rotation, + size=rcParams['xtick.labelsize']) props.update(textprops) t = self.text(xt, yt, label, **props) diff --git a/lib/matplotlib/hatch.py b/lib/matplotlib/hatch.py index f52c03c36fb2..01c030102981 100644 --- a/lib/matplotlib/hatch.py +++ b/lib/matplotlib/hatch.py @@ -98,7 +98,7 @@ def __init__(self, hatch, density): (self.num_rows // 2) * (self.num_rows)) self.num_vertices = (self.num_shapes * len(self.shape_vertices) * - (self.filled and 1 or 2)) + (1 if self.filled else 2)) def set_vertices_and_codes(self, vertices, codes): offset = 1.0 / self.num_rows