Conversation
| if self.cont_n != 0: | ||
| self.cont = self.ax3.contour(self.x, self.y, self.amp, self.cont_n, cmap=plt.get_cmap(self.style)) | ||
| else: | ||
| if self.cont_n == 0: | ||
| self.cont = self.ax3.contour(self.x, self.y, self.amp, cmap=plt.get_cmap(self.style)) | ||
| else: | ||
| self.cont = self.ax3.contour(self.x, self.y, self.amp, self.cont_n, cmap=plt.get_cmap(self.style)) | ||
| self.cont.set_norm( | ||
| norm.MyNormalize(vmin=self.amp.min(), vmax=self.amp.max(), stretch=self.stretch, clip=True)) | ||
| else: | ||
| extent = (min(self.x), max(self.x), min(self.y), max(self.y)) | ||
| if self.cont_n != 0: | ||
| self.cont = self.ax3.contour(self.x, self.y, self.amp, self.cont_n, colors='w', aspect='auto', | ||
| linewidths=0.75, origin='lower') | ||
| if self.cont_n == 0: | ||
| self.im = self.ax3.imshow(self.amp, extent=extent, cmap=plt.get_cmap(self.style), aspect='auto', | ||
| interpolation='bilinear', origin='lower') | ||
| self.cont.set_norm( | ||
| norm.MyNormalize(vmin=self.amp.min(), vmax=self.amp.max(), stretch=self.stretch, clip=True)) | ||
| self.im.set_norm( | ||
| norm.MyNormalize(vmin=self.amp.min(), vmax=self.amp.max(), stretch=self.stretch, clip=True)) | ||
| else: | ||
| self.cont = self.ax3.contour(self.x, self.y, self.amp, self.cont_n, colors='w', aspect='auto', | ||
| linewidths=0.75, origin='lower') | ||
| self.im = self.ax3.imshow(self.amp, extent=extent, cmap=plt.get_cmap(self.style), aspect='auto', | ||
| interpolation='bilinear', origin='lower') | ||
| self.im.set_norm( | ||
| self.cont.set_norm( | ||
| norm.MyNormalize(vmin=self.amp.min(), vmax=self.amp.max(), stretch=self.stretch, clip=True)) | ||
|
|
||
| self.im.set_norm( | ||
| norm.MyNormalize(vmin=self.amp.min(), vmax=self.amp.max(), stretch=self.stretch, clip=True)) |
There was a problem hiding this comment.
Function RIXS.plot_contour refactored with the following changes:
- Hoist repeated code outside conditional statement (
hoist-statement-from-if)
| elif event.inaxes == self.ax2 and event.button == 1: | ||
| elif event.button == 1: |
There was a problem hiding this comment.
Function RIXS.zoompick refactored with the following changes:
- Remove redundant conditional (
remove-redundant-if)
| elif event.inaxes == self.ax3: | ||
| else: |
There was a problem hiding this comment.
Function RIXS.onpick refactored with the following changes:
- Remove redundant conditional (
remove-redundant-if)
| if np.max(data) != 0: | ||
| norm = data / np.max(data) | ||
| else: | ||
| norm = data | ||
| return norm | ||
| return data / np.max(data) if np.max(data) != 0 else data |
There was a problem hiding this comment.
Function RIXS.norm_XAS refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
| if np.equal(vmid, None): | ||
| if stretch == 'Log': | ||
| if vmin > 0: | ||
| self.midpoint = vmax / vmin | ||
| elif vmin <= 0: | ||
| if stretch == 'Log': | ||
| if np.equal(vmid, None): | ||
| if vmin <= 0: | ||
| vmin = 0.00001 | ||
| self.midpoint = vmax / vmin | ||
| else: | ||
| raise Exception("When using a Log stretch, if vmin < 0, then vmid has to be specified") | ||
| elif stretch == 'Arcsinh' or stretch == 'Arccosh': | ||
| self.midpoint = -1. / 30. | ||
| self.midpoint = vmax / vmin | ||
| else: | ||
| self.midpoint = None | ||
| else: | ||
| if stretch == 'Log': | ||
| if vmin < vmid: | ||
| raise Exception("When using a Log stretch, vmin should be larger than vmid") | ||
| self.midpoint = (vmax - vmid) / (vmin - vmid) | ||
| elif stretch == 'Arcsinh' or stretch == 'Arccosh': | ||
| self.midpoint = (vmid - vmin) / (vmax - vmin) | ||
|
|
||
| else: | ||
| self.midpoint = None | ||
| elif stretch in ['Arcsinh', 'Arccosh']: | ||
| self.midpoint = -1. / 30. | ||
| else: | ||
| self.midpoint = None |
There was a problem hiding this comment.
Function MyNormalize.__init__ refactored with the following changes:
- Remove redundant conditional (
remove-redundant-if) - Hoist repeated code outside conditional statement (
hoist-statement-from-if) - Hoist repeated code outside conditional statement (
hoist-statement-from-if) - Swap if/else to remove empty if body (
remove-pass-body) - Replace multiple comparisons of same variable with
inoperator (merge-comparisons)
Sourcery Code Quality Report (beta)✅ Merging this PR will increase code quality in the affected files by 0.06 out of 10.
Here are some functions in these files that still need a tune-up:
Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Let us know what you think of it by mentioning @sourcery-ai in a comment. |
Branch
masterrefactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
masterbranch, then run: