| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,11 +36,8 @@ | |||
| 36 | 36 | ||
| 37 | 37 | class nf(float): | |
| 38 | 38 | def __repr__(self): | |
| 39 | - str = '%.1f' % (self.__float__(),) | ||
| 40 | - if str[-1] == '0': | ||
| 41 | - return '%.0f' % self.__float__() | ||
| 42 | - else: | ||
| 43 | - return '%.1f' % self.__float__() | ||
| 39 | + s = f'{self:.1f}' | ||
| 40 | + return f'{self:.0f}' if s[-1] == '0' else s | ||
| 44 | 41 | ||
| 45 | 42 | ||
| 46 | 43 | # Basic contour plot | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,7 +38,7 @@ | |||
| 38 | 38 | x=0.05, y=0.10, units='inches') | |
| 39 | 39 | ||
| 40 | 40 | for x, y in zip(xs, ys): | |
| 41 | - plt.plot((x,), (y,), 'ro') | ||
| 41 | + plt.plot(x, y, 'ro') | ||
| 42 | 42 | plt.text(x, y, '%d, %d' % (int(x), int(y)), transform=trans_offset) | |
| 43 | 43 | ||
| 44 | 44 | ||
@@ -49,7 +49,7 @@ | |||
| 49 | 49 | y=6, units='dots') | |
| 50 | 50 | ||
| 51 | 51 | for x, y in zip(xs, ys): | |
| 52 | - plt.polar((x,), (y,), 'ro') | ||
| 52 | + plt.polar(x, y, 'ro') | ||
| 53 | 53 | plt.text(x, y, '%d, %d' % (int(x), int(y)), | |
| 54 | 54 | transform=trans_offset, | |
| 55 | 55 | horizontalalignment='center', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,9 +38,9 @@ def lorenz(x, y, z, s=10, r=28, b=2.667): | |||
| 38 | 38 | num_steps = 10000 | |
| 39 | 39 | ||
| 40 | 40 | # Need one more for the initial values | |
| 41 | - xs = np.empty((num_steps + 1,)) | ||
| 42 | - ys = np.empty((num_steps + 1,)) | ||
| 43 | - zs = np.empty((num_steps + 1,)) | ||
| 41 | + xs = np.empty(num_steps + 1) | ||
| 42 | + ys = np.empty(num_steps + 1) | ||
| 43 | + zs = np.empty(num_steps + 1) | ||
| 44 | 44 | ||
| 45 | 45 | # Set initial values | |
| 46 | 46 | xs[0], ys[0], zs[0] = (0., 1., 1.05) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -790,7 +790,7 @@ def _process_values(self, b=None): | |||
| 790 | 790 | if self.values is not None: | |
| 791 | 791 | self._values = np.array(self.values) | |
| 792 | 792 | if self.boundaries is None: | |
| 793 | - b = np.zeros(len(self.values) + 1, 'd') | ||
| 793 | + b = np.zeros(len(self.values) + 1) | ||
| 794 | 794 | b[1:-1] = 0.5 * (self._values[:-1] - self._values[1:]) | |
| 795 | 795 | b[0] = 2.0 * b[1] - b[2] | |
| 796 | 796 | b[-1] = 2.0 * b[-2] - b[-3] | |
@@ -802,7 +802,7 @@ def _process_values(self, b=None): | |||
| 802 | 802 | # make reasonable ones based on cmap and norm. | |
| 803 | 803 | if isinstance(self.norm, colors.NoNorm): | |
| 804 | 804 | b = self._uniform_y(self.cmap.N + 1) * self.cmap.N - 0.5 | |
| 805 | - v = np.zeros((len(b) - 1,), dtype=np.int16) | ||
| 805 | + v = np.zeros(len(b) - 1, dtype=np.int16) | ||
| 806 | 806 | v[self._inside] = np.arange(self.cmap.N, dtype=np.int16) | |
| 807 | 807 | if self._extend_lower(): | |
| 808 | 808 | v[0] = -1 | |
@@ -818,7 +818,7 @@ def _process_values(self, b=None): | |||
| 818 | 818 | if self._extend_upper(): | |
| 819 | 819 | b = b + [b[-1] + 1] | |
| 820 | 820 | b = np.array(b) | |
| 821 | - v = np.zeros((len(b) - 1,), dtype=float) | ||
| 821 | + v = np.zeros(len(b) - 1) | ||
| 822 | 822 | bi = self.norm.boundaries | |
| 823 | 823 | v[self._inside] = 0.5 * (bi[:-1] + bi[1:]) | |
| 824 | 824 | if self._extend_lower(): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -412,14 +412,15 @@ def makeMappingArray(N, data, gamma=1.0): | |||
| 412 | 412 | raise ValueError("data mapping points must have x in increasing order") | |
| 413 | 413 | # begin generation of lookup table | |
| 414 | 414 | x = x * (N - 1) | |
| 415 | - lut = np.zeros((N,), float) | ||
| 416 | 415 | xind = (N - 1) * np.linspace(0, 1, N) ** gamma | |
| 417 | 416 | ind = np.searchsorted(x, xind)[1:-1] | |
| 418 | 417 | ||
| 419 | 418 | distance = (xind[1:-1] - x[ind - 1]) / (x[ind] - x[ind - 1]) | |
| 420 | - lut[1:-1] = distance * (y0[ind] - y1[ind - 1]) + y1[ind - 1] | ||
| 421 | - lut[0] = y1[0] | ||
| 422 | - lut[-1] = y0[-1] | ||
| 419 | + lut = np.concatenate([ | ||
| 420 | + [y1[0]], | ||
| 421 | + distance * (y0[ind] - y1[ind - 1]) + y1[ind - 1], | ||
| 422 | + [y0[-1]], | ||
| 423 | + ]) | ||
| 423 | 424 | # ensure that the lut is confined to values between 0 and 1 by clipping it | |
| 424 | 425 | return np.clip(lut, 0.0, 1.0) | |
| 425 | 426 | ||
@@ -543,8 +544,7 @@ def __call__(self, X, alpha=None, bytes=False): | |||
| 543 | 544 | # If the bad value is set to have a color, then we | |
| 544 | 545 | # override its alpha just as for any other value. | |
| 545 | 546 | ||
| 546 | - rgba = np.empty(shape=xa.shape + (4,), dtype=lut.dtype) | ||
| 547 | - lut.take(xa, axis=0, mode='clip', out=rgba) | ||
| 547 | + rgba = lut.take(xa, axis=0, mode='clip') | ||
| 548 | 548 | if vtype == 'scalar': | |
| 549 | 549 | rgba = tuple(rgba[0, :]) | |
| 550 | 550 | return rgba | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -201,7 +201,7 @@ def get_path(hatchpattern, density=6): | |||
| 201 | 201 | return Path(np.empty((0, 2))) | |
| 202 | 202 | ||
| 203 | 203 | vertices = np.empty((num_vertices, 2)) | |
| 204 | - codes = np.empty((num_vertices,), np.uint8) | ||
| 204 | + codes = np.empty(num_vertices, Path.code_type) | ||
| 205 | 205 | ||
| 206 | 206 | cursor = 0 | |
| 207 | 207 | for pattern in patterns: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -516,12 +516,12 @@ def _spectral_helper(x, y=None, NFFT=None, Fs=None, detrend_func=None, | |||
| 516 | 516 | # zero pad x and y up to NFFT if they are shorter than NFFT | |
| 517 | 517 | if len(x) < NFFT: | |
| 518 | 518 | n = len(x) | |
| 519 | - x = np.resize(x, (NFFT,)) | ||
| 519 | + x = np.resize(x, NFFT) | ||
| 520 | 520 | x[n:] = 0 | |
| 521 | 521 | ||
| 522 | 522 | if not same_data and len(y) < NFFT: | |
| 523 | 523 | n = len(y) | |
| 524 | - y = np.resize(y, (NFFT,)) | ||
| 524 | + y = np.resize(y, NFFT) | ||
| 525 | 525 | y[n:] = 0 | |
| 526 | 526 | ||
| 527 | 527 | if pad_to is None: | |
@@ -1598,7 +1598,7 @@ def evaluate(self, points): | |||
| 1598 | 1598 | raise ValueError("points have dimension {}, dataset has dimension " | |
| 1599 | 1599 | "{}".format(dim, self.dim)) | |
| 1600 | 1600 | ||
| 1601 | - result = np.zeros((num_m,), dtype=float) | ||
| 1601 | + result = np.zeros(num_m) | ||
| 1602 | 1602 | ||
| 1603 | 1603 | if num_m >= self.num_dp: | |
| 1604 | 1604 | # there are more points than data, so loop over data | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1123,12 +1123,10 @@ def set_theta_direction(self, direction): | |||
| 1123 | 1123 | Theta increases in the counterclockwise direction | |
| 1124 | 1124 | """ | |
| 1125 | 1125 | mtx = self._direction.get_matrix() | |
| 1126 | - if direction in ('clockwise',): | ||
| 1126 | + if direction in ('clockwise', -1): | ||
| 1127 | 1127 | mtx[0, 0] = -1 | |
| 1128 | - elif direction in ('counterclockwise', 'anticlockwise'): | ||
| 1128 | + elif direction in ('counterclockwise', 'anticlockwise', 1): | ||
| 1129 | 1129 | mtx[0, 0] = 1 | |
| 1130 | - elif direction in (1, -1): | ||
| 1131 | - mtx[0, 0] = direction | ||
| 1132 | 1130 | else: | |
| 1133 | 1131 | raise ValueError( | |
| 1134 | 1132 | "direction must be 1, -1, clockwise or counterclockwise") | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -306,9 +306,8 @@ def _init(self): | |||
| 306 | 306 | # Hack: save and restore the Umask | |
| 307 | 307 | _mask = self.Q.Umask | |
| 308 | 308 | self.Q.Umask = ma.nomask | |
| 309 | - self.verts = self.Q._make_verts(np.array([self.U]), | ||
| 310 | - np.zeros((1,)), | ||
| 311 | - self.angle) | ||
| 309 | + self.verts = self.Q._make_verts( | ||
| 310 | + np.array([self.U]), np.zeros(1), self.angle) | ||
| 312 | 311 | self.Q.Umask = _mask | |
| 313 | 312 | self.Q.pivot = _pivot | |
| 314 | 313 | kw = self.Q.polykw | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -630,13 +630,13 @@ def test_const_xy(): | |||
| 630 | 630 | fig = plt.figure() | |
| 631 | 631 | ||
| 632 | 632 | plt.subplot(311) | |
| 633 | - plt.plot(np.arange(10), np.ones((10,))) | ||
| 633 | + plt.plot(np.arange(10), np.ones(10)) | ||
| 634 | 634 | ||
| 635 | 635 | plt.subplot(312) | |
| 636 | - plt.plot(np.ones((10,)), np.arange(10)) | ||
| 636 | + plt.plot(np.ones(10), np.arange(10)) | ||
| 637 | 637 | ||
| 638 | 638 | plt.subplot(313) | |
| 639 | - plt.plot(np.ones((10,)), np.ones((10,)), 'o') | ||
| 639 | + plt.plot(np.ones(10), np.ones(10), 'o') | ||
| 640 | 640 | ||
| 641 | 641 | ||
| 642 | 642 | @image_comparison(baseline_images=['polar_wrap_180', 'polar_wrap_360'], | |
@@ -5198,7 +5198,7 @@ def test_violin_point_mass(): | |||
| 5198 | 5198 | ||
| 5199 | 5199 | ||
| 5200 | 5200 | def generate_errorbar_inputs(): | |
| 5201 | - base_xy = cycler('x', [np.arange(5)]) + cycler('y', [np.ones((5, ))]) | ||
| 5201 | + base_xy = cycler('x', [np.arange(5)]) + cycler('y', [np.ones(5)]) | ||
| 5202 | 5202 | err_cycler = cycler('err', [1, | |
| 5203 | 5203 | [1, 1, 1, 1, 1], | |
| 5204 | 5204 | [[1, 1, 1, 1, 1], | |
| Back | FazBrowse Home | New Git URL |
0 commit comments