diff --git a/lib/matplotlib/_constrained_layout.py b/lib/matplotlib/_constrained_layout.py index cb2eca62057c..1e943c8e5cd3 100644 --- a/lib/matplotlib/_constrained_layout.py +++ b/lib/matplotlib/_constrained_layout.py @@ -77,19 +77,13 @@ def get_axall_tightbbox(ax, renderer): def in_same_column(colnum0min, colnum0max, colnumCmin, colnumCmax): - if colnum0min >= colnumCmin and colnum0min <= colnumCmax: - return True - if colnum0max >= colnumCmin and colnum0max <= colnumCmax: - return True - return False + return (colnumCmin <= colnum0min <= colnumCmax + or colnumCmin <= colnum0max <= colnumCmax) def in_same_row(rownum0min, rownum0max, rownumCmin, rownumCmax): - if rownum0min >= rownumCmin and rownum0min <= rownumCmax: - return True - if rownum0max >= rownumCmin and rownum0max <= rownumCmax: - return True - return False + return (rownumCmin <= rownum0min <= rownumCmax + or rownumCmin <= rownum0max <= rownumCmax) ###################################################### diff --git a/lib/matplotlib/backends/backend_webagg_core.py b/lib/matplotlib/backends/backend_webagg_core.py index ab8fda933b98..aa954f95a0a0 100644 --- a/lib/matplotlib/backends/backend_webagg_core.py +++ b/lib/matplotlib/backends/backend_webagg_core.py @@ -88,21 +88,21 @@ def _handle_key(key): code = int(key[key.index('k') + 1:]) value = chr(code) # letter keys - if code >= 65 and code <= 90: + if 65 <= code <= 90: if 'shift+' in key: key = key.replace('shift+', '') else: value = value.lower() # number keys - elif code >= 48 and code <= 57: + elif 48 <= code <= 57: if 'shift+' in key: value = ')!@#$%^&*('[int(value)] key = key.replace('shift+', '') # function keys - elif code >= 112 and code <= 123: + elif 112 <= code <= 123: value = 'f%s' % (code - 111) # number pad keys - elif code >= 96 and code <= 105: + elif 96 <= code <= 105: value = '%s' % (code - 96) # keys with shift alternatives elif code in _SHIFT_LUT and 'shift+' in key: diff --git a/lib/matplotlib/backends/backend_wx.py b/lib/matplotlib/backends/backend_wx.py index d307edc1fc21..dfbf23340492 100644 --- a/lib/matplotlib/backends/backend_wx.py +++ b/lib/matplotlib/backends/backend_wx.py @@ -489,7 +489,7 @@ def set_linewidth(self, w): w = float(w) DEBUG_MSG("set_linewidth()", 1, self) self.select() - if w > 0 and w < 1: + if 0 < w < 1: w = 1 GraphicsContextBase.set_linewidth(self, w) lw = int(self.renderer.points_to_pixels(self._linewidth)) diff --git a/lib/matplotlib/collections.py b/lib/matplotlib/collections.py index aee38d4e1f42..59f6bfca5986 100644 --- a/lib/matplotlib/collections.py +++ b/lib/matplotlib/collections.py @@ -304,8 +304,7 @@ def draw(self, renderer): combined_transform = transform extents = paths[0].get_extents(combined_transform) width, height = renderer.get_canvas_width_height() - if (extents.width < width and - extents.height < height): + if extents.width < width and extents.height < height: do_single_path_optimization = True if self._joinstyle: diff --git a/lib/matplotlib/mathtext.py b/lib/matplotlib/mathtext.py index 8b4aa04f5842..dcb13a0ee494 100644 --- a/lib/matplotlib/mathtext.py +++ b/lib/matplotlib/mathtext.py @@ -1000,7 +1000,7 @@ def _map_virtual_font(self, fontname, font_class, uniindex): else: lo = mid + 1 - if uniindex >= range[0] and uniindex <= range[1]: + if range[0] <= uniindex <= range[1]: uniindex = uniindex - range[0] + range[3] fontname = range[2] elif not doing_sans_conversion: diff --git a/lib/matplotlib/projections/polar.py b/lib/matplotlib/projections/polar.py index fb139ff01cb3..f5537005dc30 100644 --- a/lib/matplotlib/projections/polar.py +++ b/lib/matplotlib/projections/polar.py @@ -1344,7 +1344,7 @@ def start_pan(self, x, y, button): if button == 1: epsilon = np.pi / 45.0 t, r = self.transData.inverted().transform_point((x, y)) - if t >= angle - epsilon and t <= angle + epsilon: + if angle - epsilon <= t <= angle + epsilon: mode = 'drag_r_labels' elif button == 3: mode = 'zoom' diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index 3afaff8a03eb..9463dbdfa2de 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -501,7 +501,7 @@ def figure(num=None, # autoincrement if None, else integer from 1-N if figManager is None: max_open_warning = rcParams['figure.max_open_warning'] - if (max_open_warning >= 1 and len(allnums) >= max_open_warning): + if len(allnums) >= max_open_warning >= 1: warnings.warn( "More than %d figures have been opened. Figures " "created through the pyplot interface " diff --git a/lib/matplotlib/ticker.py b/lib/matplotlib/ticker.py index 47de3e105ebe..41b1c88d9bec 100644 --- a/lib/matplotlib/ticker.py +++ b/lib/matplotlib/ticker.py @@ -2413,25 +2413,25 @@ def tick_values(self, vmin, vmax): # major ticks if not self.minor: ticklocs = [] - if (decade_min <= -1): + if decade_min <= -1: expo = np.arange(decade_min, min(0, decade_max + 1)) ticklocs.extend(list(10**expo)) - if (decade_min <= 0) and (decade_max >= 0): + if decade_min <= 0 <= decade_max: ticklocs.append(0.5) - if (decade_max >= 1): + if decade_max >= 1: expo = -np.arange(max(1, decade_min), decade_max + 1) ticklocs.extend(list(1 - 10**expo)) # minor ticks else: ticklocs = [] - if (decade_min <= -2): + if decade_min <= -2: expo = np.arange(decade_min, min(-1, decade_max)) newticks = np.outer(np.arange(2, 10), 10**expo).ravel() ticklocs.extend(list(newticks)) - if (decade_min <= 0) and (decade_max >= 0): + if decade_min <= 0 <= decade_max: ticklocs.extend([0.2, 0.3, 0.4, 0.6, 0.7, 0.8]) - if (decade_max >= 2): + if decade_max >= 2: expo = -np.arange(max(2, decade_min), decade_max + 1) newticks = 1 - np.outer(np.arange(2, 10), 10**expo).ravel() ticklocs.extend(list(newticks))