Skip to content
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 #2

Merged
merged 1 commit into from
Nov 27, 2023
Merged

Sourcery refactored master branch #2

merged 1 commit into from
Nov 27, 2023

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Nov 27, 2023

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:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from daedalus November 27, 2023 20:02
return [(x[0] * x[1], x[1] - 1) for x in Fx if (x[1]-1) > -1]
return [(x[0] * x[1], x[1] - 1) for x in Fx if x[1] > 0]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function FormalDerivative refactored with the following changes:

Comment on lines -15 to +17
if b & 1 == 0:
return gcd(a, b >> 1)
else:
return gcd(abs(a - b), min(a, b))
return gcd(a, b >> 1) if b & 1 == 0 else gcd(abs(a - b), min(a, b))
else:
if b & 1 == 1:
return gcd(a >> 1, b)
else:
return 2 * gcd(a >> 1, b >> 1)
return gcd(a >> 1, b) if b & 1 == 1 else 2 * gcd(a >> 1, b >> 1)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function gcd refactored with the following changes:

tmp = []
for n in range(0, N / 2):
tmp.append(histogram[n] * 2)
return tmp
return [histogram[n] * 2 for n in range(0, N / 2)]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function nyquist_norm refactored with the following changes:

r = (f(x + h / 2) - f(x - h / 2)) / h
return r
return (f(x + h / 2) - f(x - h / 2)) / h
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function __df refactored with the following changes:

ret = (1 + (1.0 / x)) ** x
return ret
return (1 + (1.0 / x)) ** x
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function direct_e refactored with the following changes:

Comment on lines -18 to +27
for i in range(max_iterations):
y = f(x0)
yprime = f_prime(x0)
if abs(yprime) < epsilon: # Stop if the denominator is too small
break
x1 = x0 - y / yprime # Do Newton's computation
if abs(x1 - x0) <= tolerance: # Stop when the result is within the desired tolerance
return x1 # x1 is a solution within tolerance and maximum number of iterations
x0 = x1 # Update x0 to start the process again
return None
for _ in range(max_iterations):
y = f(x0)
yprime = f_prime(x0)
if abs(yprime) < epsilon: # Stop if the denominator is too small
break
x1 = x0 - y / yprime # Do Newton's computation
if abs(x1 - x0) <= tolerance: # Stop when the result is within the desired tolerance
return x1 # x1 is a solution within tolerance and maximum number of iterations
x0 = x1 # Update x0 to start the process again
return None
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function newtons_method refactored with the following changes:

if i == 0:
R[i] = P[i]
else:
R[i] = P[i] + Q * R[i - 1]
R[i] = P[i] if i == 0 else P[i] + Q * R[i - 1]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function poly_synthetic_div refactored with the following changes:

Comment on lines -60 to +57
tmp2.append(r)
tmp2.append(-r)
tmp2.extend((r, -r))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_rationals refactored with the following changes:

Comment on lines -9 to +10
sum_ = 0
nipi2 = ipi2 * n
for a in range(1, q+1):
if gcd(a,q) == 1:
sum_ += exp(nipi2 * (a/q))
return sum_
return sum(exp(nipi2 * (a/q)) for a in range(1, q+1) if gcd(a,q) == 1)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function c refactored with the following changes:

for i in range(1,210):
for _ in range(1,210):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test refactored with the following changes:

for i in range(2, int(n ** 0.5) + 1):
if n % i == 0:
return False

return True
return all(n % i != 0 for i in range(2, int(n ** 0.5) + 1))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function isPrime refactored with the following changes:

Comment on lines -32 to +28
factor = sorted(factor)
return factor
return sorted(factor)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function factors refactored with the following changes:

Comment on lines -40 to +35
nD.append(-abs(i))
nD.append(abs(i))
nD.extend((-abs(i), abs(i)))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function addnegatives refactored with the following changes:

Comment on lines -55 to +49
if tmpPoli[len(tmpPoli) - 1] == 0:
if tmpPoli[-1] == 0:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ruffini_step refactored with the following changes:

s = list(map(mul, s[0 : l // 2], s[l // 2 :]))
s = list(map(mul, s[:l // 2], s[l // 2 :]))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SeqMult refactored with the following changes:

if x >= 0:
return x
else:
return -x
return x if x >= 0 else -x
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _abs refactored with the following changes:

Comment on lines -16 to +13
if x == 0:
return 0
else:
return x / _abs(x)
return 0 if x == 0 else x / _abs(x)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function sign refactored with the following changes:

for i in range(2, n):
inv.append((p - p // i) * inv[p % i] % p)
inv.extend((p - p // i) * inv[p % i] % p for i in range(2, n))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function compute_modinv_1_n refactored with the following changes:

Comment on lines -17 to +16
for i in range(1, n):
inv.append(int(invert(i, p)))
inv.extend(int(invert(i, p)) for i in range(1, n))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function compute_modinv_gmpy_1_n refactored with the following changes:

res = 0
for n in range(0, len(vec)):
res += vec[n] * vec[n]

res = sum(vec[n] * vec[n] for n in range(0, len(vec)))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function magnitude refactored with the following changes:

@daedalus daedalus merged commit e2fa1fc into master Nov 27, 2023
0 of 2 checks passed
@daedalus daedalus deleted the sourcery/master branch November 27, 2023 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant