Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ed4d28d

Browse files
committed
Simplify some comparisons
1 parent c041352 commit ed4d28d

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

examples/images_contours_and_fields/image_zcoord.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
def format_coord(x, y):
2828
col = int(x + 0.5)
2929
row = int(y + 0.5)
30-
if col >= 0 and col < numcols and row >= 0 and row < numrows:
30+
if 0 <= col < numcols and 0 <= row < numrows:
3131
z = X[row, col]
3232
return 'x=%1.4f, y=%1.4f, z=%1.4f' % (x, y, z)
3333
else:

lib/matplotlib/backends/backend_agg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def draw_path(self, gc, path, transform, rgbFace=None):
124124
nmax = rcParams['agg.path.chunksize'] # here at least for testing
125125
npts = path.vertices.shape[0]
126126

127-
if (nmax > 100 and npts > nmax and path.should_simplify and
127+
if (npts > nmax > 100 and path.should_simplify and
128128
rgbFace is None and gc.get_hatch() is None):
129129
nch = np.ceil(npts / nmax)
130130
chsize = int(np.ceil(npts / nch))

lib/matplotlib/streamplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ def within_grid(self, xi, yi):
352352
"""Return True if point is a valid index of grid."""
353353
# Note that xi/yi can be floats; so, for example, we can't simply check
354354
# `xi < self.nx` since *xi* can be `self.nx - 1 < xi < self.nx`
355-
return xi >= 0 and xi <= self.nx - 1 and yi >= 0 and yi <= self.ny - 1
355+
return 0 <= xi <= self.nx - 1 and 0 <= yi <= self.ny - 1
356356

357357

358358
class StreamMask:

0 commit comments

Comments
 (0)