8000 Merge pull request #13855 from anntzer/ternary · timhoffm/matplotlib@b9fa7b7 · GitHub
[go: up one dir, main page]

Skip to content

Commit b9fa7b7

Browse files
authored
Merge pull request matplotlib#13855 from anntzer/ternary
`a and b or c` -> `b if a else c`
2 parents f26774c + 143f700 commit b9fa7b7

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

examples/tests/backend_driver_sgskip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ def drive(backend, directories, python=['python'], switches=[]):
418418

419419

420420
def parse_options():
421-
doc = (__doc__ and __doc__.split('\n\n')) or " "
421+
doc = __doc__.split("\n\n") if __doc__ else " "
422422
op = OptionParser(description=doc[0].strip(),
423423
usage='%prog [options] [--] [backends and switches]',
424424
#epilog='\n'.join(doc[1:]) # epilog not supported on my python2.4 machine: JDH

lib/matplotlib/axes/_axes.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3017,17 +3017,17 @@ def get_next_color():
30173017
if labeldistance is not None:
30183018
xt = x + labeldistance * radius * math.cos(thetam)
30193019
yt = y + labeldistance * radius * math.sin(thetam)
3020-
label_alignment_h = xt > 0 and 'left' or 'right'
3020+
label_alignment_h = 'left' if xt > 0 else 'right'
30213021
label_alignment_v = 'center'
30223022
label_rotation = 'horizontal'
30233023
if rotatelabels:
3024-
label_alignment_v = yt > 0 and 'bottom' or 'top'
3025-
label_rotation = np.rad2deg(thetam) + (0 if xt > 0
3026-
else 180)
3024+
label_alignment_v = 'bottom' if yt > 0 else 'top'
3025+
label_rotation = (np.rad2deg(thetam)
3026+
+ (0 if xt > 0 else 180))
30273027
props = dict(horizontalalignment=label_alignment_h,
3028-
verticalalignment=label_alignment_v,
3029-
rotation=label_rotation,
3030-
size=rcParams['xtick.labelsize'])
3028+
verticalalignment=label_alignment_v,
3029+
rotation=label_rotation,
3030+
size=rcParams['xtick.labelsize'])
30313031
props.update(textprops)
30323032

30333033
t = self.text(xt, yt, label, **props)

lib/matplotlib/hatch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def __init__(self, hatch, density):
9898
(self.num_rows // 2) * (self.num_rows))
9999
self.num_vertices = (self.num_shapes *
100100
len(self.shape_vertices) *
101-
(self.filled and 1 or 2))
101+
(1 if self.filled else 2))
102102

103103
def set_vertices_and_codes(self, vertices, codes):
104104
offset = 1.0 / self.num_rows

0 commit comments

Comments
 (0)
0