-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery refactored master branch #1
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to GitHub API limits, only the first 60 comments can be shown.
name="sim_{}".format(stage), | ||
name=f"sim_{stage}", | ||
wavelength=1550, | ||
eps=eps, | ||
solver_info=solver_info, | ||
sources=[ | ||
maxwell.WaveguideModeSource(center=[-1400, 0, 0], | ||
extents=[0, 2500, 1000], | ||
normal=[1, 0, 0], | ||
mode_num=0, | ||
power=1) | ||
maxwell.WaveguideModeSource( | ||
center=[-1400, 0, 0], | ||
extents=[0, 2500, 1000], | ||
normal=[1, 0, 0], | ||
mode_num=0, | ||
power=1, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function make_objective
refactored with the following changes:
- Replace call to format with f-string [×2] (
use-fstring-for-formatting
)
name="sim_{}".format(stage), | ||
name=f"sim_{stage}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function make_objective
refactored with the following changes:
- Replace call to format with f-string [×2] (
use-fstring-for-formatting
)
plt.imshow( | ||
np.abs(data["monitor_data"]["sim_{}.eps".format(stage)][1].squeeze())) | ||
plt.imshow(np.abs(data["monitor_data"][f"sim_{stage}.eps"][1].squeeze())) | ||
plt.colorbar() | ||
plt.subplot(1, 2, 2) | ||
plt.imshow( | ||
np.abs(data["monitor_data"]["sim_{}.field".format(stage)][1].squeeze())) | ||
plt.imshow(np.abs(data["monitor_data"][f"sim_{stage}.field"][1].squeeze())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function visualize
refactored with the following changes:
- Replace call to format with f-string [×2] (
use-fstring-for-formatting
)
print("x: {}, y: {}, obj: {}".format(x_val.array, y_val.array, | ||
obj_val.array)) | ||
print(f"x: {x_val.array}, y: {y_val.array}, obj: {obj_val.array}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function main
refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting
)
print("x: {}, y: {}, obj: {}".format(x_val.array, y_val.array, | ||
obj_val.array)) | ||
print(f"x: {x_val.array}, y: {y_val.array}, obj: {obj_val.array}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function main
refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting
)
fields = { | ||
return { | ||
'wavenumber': wavenumber, | ||
'E': unvec(e, shape), | ||
'H': unvec(h, shape), | ||
} | ||
|
||
return fields |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function solve_waveguide_mode_2d
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
results = { | ||
return { | ||
'wavenumber': fields_2d['wavenumber'], | ||
'H': H, | ||
'E': E, | ||
} | ||
|
||
return results |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function solve_waveguide_mode
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
exp_iphi = np.exp( | ||
1j * polarity * wavenumber * dxes[1][int(axis)][slices[int(axis)]]) | ||
exp_iphi = np.exp(1j * polarity * wavenumber * dxes[1][axis][slices[axis]]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function compute_source
refactored with the following changes:
- Remove unnecessary casts to int, str, float or bool [×4] (
remove-unnecessary-cast
)
if polarity == 1: | ||
Mslice = copy.deepcopy(slices) | ||
Jslice = copy.deepcopy(slices) | ||
Jslice[axis] = slice(Jslice[axis].start + 1, Jslice[axis].stop + 1) | ||
elif polarity == -1: | ||
if polarity == -1: | ||
Mslice = copy.deepcopy(slices) | ||
Mslice[axis] = slice(Mslice[axis].start - 1, Mslice[axis].stop - 1) | ||
Jslice = copy.deepcopy(slices) | ||
|
||
elif polarity == 1: | ||
Mslice = copy.deepcopy(slices) | ||
Jslice = copy.deepcopy(slices) | ||
Jslice[axis] = slice(Jslice[axis].start + 1, Jslice[axis].stop + 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function compute_source_angle
refactored with the following changes:
- Simplify conditional into switch-like form (
switch
)
dn[0:npts] = 1 | ||
dn[:npts] = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function compute_overlap_e
refactored with the following changes:
- Replace a[0:x] with a[:x] and a[x:len(a)] with a[x:] (
remove-redundant-slice-index
)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.10%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. 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! Help us improve this quality report! |
Branch
master
refactored 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
master
branch, then run:Help us improve this pull request!