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

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions examples/event_handling/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,14 @@ def downsample(self, xstart, xend):
xdata = xdata[::ratio]
ydata = ydata[::ratio]

print("using {} of {} visible points".format(
len(ydata), np.sum(mask)))
print("using {} of {} visible points".format(len(ydata), np.sum(mask)))

return xdata, ydata

def update(self, ax):
# Update the line
lims = ax.viewLim
if np.abs(lims.width - self.delta) > 1e-8:
if abs(lims.width - self.delta) > 1e-8:
self.delta = lims.width
xstart, xend = lims.intervalx
self.line.set_data(*self.downsample(xstart, xend))
Expand Down
4 changes: 2 additions & 2 deletions examples/specialty_plots/hinton_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def hinton(matrix, max_weight=None, ax=None):
ax = ax if ax is not None else plt.gca()

if not max_weight:
max_weight = 2 ** np.ceil(np.log(np.abs(matrix).max()) / np.log(2))
max_weight = 2 ** np.ceil(np.log2(np.abs(matrix).max()))

ax.patch.set_facecolor('gray')
ax.set_aspect('equal', 'box')
Expand All @@ -28,7 +28,7 @@ def hinton(matrix, max_weight=None, ax=None):

for (x, y), w in np.ndenumerate(matrix):
color = 'white' if w > 0 else 'black'
size = np.sqrt(np.abs(w) / max_weight)
size = np.sqrt(abs(w) / max_weight)
rect = plt.Rectangle([x - size / 2, y - size / 2], size, size,
facecolor=color, edgecolor=color)
ax.add_patch(rect)
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6276,8 +6276,8 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
else:
dx = np.diff(x)
dy = np.diff(y)
if (np.ptp(dx) < 0.01 * np.abs(dx.mean()) and
np.ptp(dy) < 0.01 * np.abs(dy.mean())):
if (np.ptp(dx) < 0.01 * abs(dx.mean()) and
np.ptp(dy) < 0.01 * abs(dy.mean())):
style = "image"
else:
style = "pcolorimage"
Expand Down
6 changes: 3 additions & 3 deletions lib/matplotlib/bezier.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_intersection(cx1, cy1, cos_t1, sin_t1,
c, d = sin_t2, -cos_t2

ad_bc = a * d - b * c
if np.abs(ad_bc) < 1.0e-12:
if abs(ad_bc) < 1e-12:
raise ValueError("Given lines do not intersect. Please verify that "
"the angles are not equal or differ by 180 degrees.")

Expand Down Expand Up @@ -368,10 +368,10 @@ def check_if_parallel(dx1, dy1, dx2, dy2, tolerance=1.e-5):
"""
theta1 = np.arctan2(dx1, dy1)
theta2 = np.arctan2(dx2, dy2)
dtheta = np.abs(theta1 - theta2)
dtheta = abs(theta1 - theta2)
if dtheta < tolerance:
return 1
elif np.abs(dtheta - np.pi) < tolerance:
elif abs(dtheta - np.pi) < tolerance:
return -1
else:
return False
Expand Down
8 changes: 2 additions & 6 deletions lib/matplotlib/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,19 +330,15 @@ def _set_nothing(self):
self._filled = False

def _set_custom_marker(self, path):
verts = path.vertices
rescale = max(np.max(np.abs(verts[:, 0])),
np.max(np.abs(verts[:, 1])))
rescale = np.max(np.abs(path.vertices)) # max of x's and y's.
self._transform = Affine2D().scale(0.5 / rescale)
self._path = path

def _set_path_marker(self):
self._set_custom_marker(self._marker)

def _set_vertices(self):
verts = self._marker
marker = Path(verts)
self._set_custom_marker(marker)
self._set_custom_marker(Path(self._marker))

def _set_tuple_marker(self):
marker = self._marker
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/sankey.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def add(self, patchlabel='', flows=None, orientations=None, labels='',
raise ValueError(
"'trunklength' is negative, which is not allowed because it "
"would cause poor layout")
if np.abs(np.sum(flows)) > self.tolerance:
if abs(np.sum(flows)) > self.tolerance:
_log.info("The sum of the flows is nonzero (%f; patchlabel=%r); "
"is the system not at steady state?",
np.sum(flows), patchlabel)
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ def test_format_data_short(self, N):
x2 = 1 - float(fx[2:])
else:
x2 = float(fx)
assert np.abs(x - x2) < 1 / N
assert abs(x - x2) < 1 / N


class TestFormatStrFormatter:
Expand Down
10 changes: 5 additions & 5 deletions lib/matplotlib/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ def __call__(self, x, pos=None):
return ''
else:
xp = (x - self.offset) / (10. ** self.orderOfMagnitude)
if np.abs(xp) < 1e-8:
if abs(xp) < 1e-8:
xp = 0
if self._useLocale:
s = locale.format_string(self.format, (xp,))
Expand Down Expand Up @@ -792,7 +792,7 @@ def _set_format(self):
@cbook.deprecated("3.1")
def pprint_val(self, x):
xp = (x - self.offset) / (10. ** self.orderOfMagnitude)
if np.abs(xp) < 1e-8:
if abs(xp) < 1e-8:
xp = 0
if self._useLocale:
return locale.format_string(self.format, (xp,))
Expand Down Expand Up @@ -1123,7 +1123,7 @@ def __call__(self, x, pos=None):
else:
base = '%s' % b

if np.abs(fx) < min_exp:
if abs(fx) < min_exp:
if usetex:
return r'${0}{1:g}$'.format(sign_string, x)
else:
Expand Down Expand Up @@ -2269,7 +2269,7 @@ def is_decade(x, base=10, *, rtol=1e-10):
return False
if x == 0.0:
return True
lx = np.log(np.abs(x)) / np.log(base)
lx = np.log(abs(x)) / np.log(base)
return is_close_to_int(lx, atol=rtol)


Expand Down Expand Up @@ -2614,7 +2614,7 @@ def get_log_range(lo, hi):
a_lo, a_hi = (0, 0)
if has_a:
a_upper_lim = min(-linthresh, vmax)
a_lo, a_hi = get_log_range(np.abs(a_upper_lim), np.abs(vmin) + 1)
a_lo, a_hi = get_log_range(abs(a_upper_lim), abs(vmin) + 1)

c_lo, c_hi = (0, 0)
if has_c:
Expand Down