-
Notifications
You must be signed in to change notification settings - Fork 10
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 main branch #4
base: main
Are you sure you want to change the base?
Conversation
85397ac
to
1ccbdf8
Compare
|
||
code = GrayCode(bitsSymb) | ||
a = list(code.generate_gray()) | ||
|
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 GrayMapping
refactored with the following changes:
- Replace range(0, x) with range(x) (
remove-zero-from-range
)
|
||
hdDecision_vec = np.vectorize(hdDecision, excluded = [1]) | ||
index_list = hdDecision_vec(symb, const[:,0]) | ||
demod_bits = dec2bitarray(index_list, int(np.log2(M))) | ||
|
||
return demod_bits | ||
|
||
hdDecision_vec = np.vectorize(hdDecision, excluded = [1]) | ||
index_list = hdDecision_vec(symb, const[:,0]) | ||
return dec2bitarray(index_list, int(np.log2(M))) |
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 demodulateGray
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
|
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.
Lines 161-320
refactored with the following changes:
- Hoist statements out of for/while loops (
hoist-statement-from-loop
)
σ = np.sqrt(σ2_s) | ||
σ = np.sqrt(σ2_s) | ||
Is = normal(μ, σ, Namostras) | ||
|
||
# plotas as primeiras 1000 amostras | ||
plt.plot(Is[0:1000],linewidth = 0.8); | ||
plt.plot(Is[:1000], linewidth = 0.8); |
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.
Lines 148-152
refactored with the following changes:
- Replace a[0:x] with a[:x] and a[x:len(a)] with a[x:] (
remove-redundant-slice-index
)
Ao = Ai*np.cos(0.5/Vπ*(u+Vb)*π) | ||
|
||
return Ao | ||
return Ai*np.cos(0.5/Vπ*(u+Vb)*π) |
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 mzm
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
def dbp(Ei, Fs, Ltotal, Lspan, hz=0.5, alpha=0.2, gamma=1.3, D=16, Fc=193.1e12): | ||
def dbp(Ei, Fs, Ltotal, Lspan, hz=0.5, alpha=0.2, gamma=1.3, D=16, Fc=193.1e12): |
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 dbp
refactored with the following changes:
- Replace unused for index with underscore [×2] (
for-index-underscore
) - Replace range(0, x) with range(x) [×2] (
remove-zero-from-range
)
Ao = Ai*np.cos(0.5/Vπ*(u+Vb)*π) | ||
|
||
return Ao | ||
return Ai*np.cos(0.5/Vπ*(u+Vb)*π) |
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 mzm
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
Ao = mzm(Ai/np.sqrt(2), Vπ, u.real, VbI) + 1j*mzm(Ai/np.sqrt(2), Vπ, u.imag, VbQ) | ||
|
||
return Ao | ||
return mzm(Ai / np.sqrt(2), Vπ, u.real, VbI) + 1j * mzm( | ||
Ai / np.sqrt(2), Vπ, u.imag, VbQ | ||
) |
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 iqm
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
|
||
# optical hybrid transfer matrix | ||
T = np.array([[ 1/2, 1j/2, 1j/2, -1/2], | ||
[ 1j/2, -1/2, 1/2, 1j/2], | ||
[ 1j/2, 1/2, -1j/2, -1/2], | ||
[-1/2, 1j/2, -1/2, 1j/2]]) | ||
|
||
Ei = np.array([E1, np.zeros((E1.size,)), | ||
np.zeros((E1.size,)), E2]) | ||
|
||
Eo = T@Ei | ||
|
||
return Eo | ||
|
||
return T@Ei |
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 hybrid_2x4_90deg
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
def ssfm(Ei, Fs, paramCh): | ||
def ssfm(Ei, Fs, paramCh): |
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 ssfm
refactored with the following changes:
- Replace unused for index with underscore [×2] (
for-index-underscore
) - Simplify conditional into switch-like form (
switch
) - Use x is None rather than x == None (
none-compare
)
def manakov_ssf(Ei, Fs, paramCh): | ||
def manakov_ssf(Ei, Fs, paramCh): |
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 manakov_ssf
refactored with the following changes:
- Replace unused for index with underscore [×2] (
for-index-underscore
) - Simplify conditional into switch-like form (
switch
) - Use x is None rather than x == None (
none-compare
)
σ2 = 2*np.pi*lw*Ts | ||
σ2 = 2*np.pi*lw*Ts | ||
phi = np.zeros(Nsamples) | ||
for ind in range(0, Nsamples-1): | ||
|
||
for ind in range(Nsamples-1): | ||
phi[ind+1] = phi[ind] + normal(0, np.sqrt(σ2)) | ||
|
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 phaseNoise
refactored with the following changes:
- Replace range(0, x) with range(x) (
remove-zero-from-range
)
|
||
# transmitter parameters | ||
Ts = 1/param.Rs # symbol period [s] | ||
Fa = 1/(Ts/param.SpS) # sampling frequency [samples/s] | ||
Ta = 1/Fa # sampling period [s] | ||
|
||
# central frequencies of the WDM channels | ||
freqGrid = np.arange(-np.floor(param.Nch/2), np.floor(param.Nch/2)+1,1)*param.freqSpac | ||
|
||
if (param.Nch % 2) == 0: | ||
freqGrid += param.freqSpac/2 | ||
|
||
# IQM parameters | ||
Ai = 1 | ||
Vπ = 2 | ||
Vb = -Vπ | ||
Pch = 10**(param.Pch_dBm/10)*1e-3 # optical signal power per WDM channel | ||
|
||
π = np.pi | ||
|
||
t = np.arange(0, int(((param.Nbits)/np.log2(param.M))*param.SpS)) | ||
|
||
# allocate array | ||
sigTxWDM = np.zeros((len(t), param.Nmodes), dtype='complex') | ||
symbTxWDM = np.zeros((int(len(t)/param.SpS), param.Nmodes, param.Nch), dtype='complex') | ||
|
||
symbTxWDM = np.zeros( | ||
(len(t) // param.SpS, param.Nmodes, param.Nch), dtype='complex' | ||
) | ||
|
||
|
||
Psig = 0 | ||
for indMode in range(0, param.Nmodes): | ||
|
||
for indMode in range(param.Nmodes): | ||
print('Mode #%d'%(indMode)) | ||
for indCh in range(0, param.Nch): | ||
|
||
for indCh in range(param.Nch): |
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 simpleWDMTx
refactored with the following changes:
- Simplify division expressions (
simplify-division
) - Replace range(0, x) with range(x) [×2] (
remove-zero-from-range
)
y = sig[0:Nsamples].real | ||
y = sig[:Nsamples].real |
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 eyediagram
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 decrease code quality in the affected files by 0.19%.
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
main
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
main
branch, then run:Help us improve this pull request!