Skip to content

Upgrade CodeSee workflow to version 2 #1

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arithmetic_analysis/bisection.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def bisection(
return
else:
mid = start + (end - start) / 2.0
while abs(start - mid) > 10 ** -7: # until we achieve precise equals to 10^-7
while abs(start - mid) > 10**-7: # until we achieve precise equals to 10^-7
if function(mid) == 0:
return mid
elif function(mid) * function(start) < 0:
Expand Down
2 changes: 1 addition & 1 deletion arithmetic_analysis/in_static_equilibrium.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def polar_force(


def in_static_equilibrium(
forces: array, location: array, eps: float = 10 ** -1
forces: array, location: array, eps: float = 10**-1
) -> bool:
"""
Check if a system is in equilibrium.
Expand Down
2 changes: 1 addition & 1 deletion arithmetic_analysis/intersection.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def intersection(
x_n2 = x_n1 - (
function(x_n1) / ((function(x_n1) - function(x_n)) / (x_n1 - x_n))
)
if abs(x_n2 - x_n1) < 10 ** -5:
if abs(x_n2 - x_n1) < 10**-5:
return x_n2
x_n = x_n1
x_n1 = x_n2
Expand Down
6 changes: 3 additions & 3 deletions arithmetic_analysis/newton_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ def newton(function, function1, startingInt):
x_n = startingInt
while True:
x_n1 = x_n - function(x_n) / function1(x_n)
if abs(x_n - x_n1) < 10 ** -5:
if abs(x_n - x_n1) < 10**-5:
return x_n1
x_n = x_n1


def f(x):
return (x ** 3) - (2 * x) - 5
return (x**3) - (2 * x) - 5


def f1(x):
return 3 * (x ** 2) - 2
return 3 * (x**2) - 2


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion arithmetic_analysis/newton_raphson.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from sympy import diff


def newton_raphson(func: str, a: int, precision: int = 10 ** -10) -> float:
def newton_raphson(func: str, a: int, precision: int = 10**-10) -> float:
"""Finds root from the point 'a' onwards by Newton-Raphson method
>>> newton_raphson("sin(x)", 2)
3.1415926536808043
Expand Down
2 changes: 1 addition & 1 deletion ciphers/deterministic_miller_rabin.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def miller_rabin(n, allow_probable=False):
for prime in plist:
pr = False
for r in range(s):
m = pow(prime, d * 2 ** r, n)
m = pow(prime, d * 2**r, n)
# see article for analysis explanation for m
if (r == 0 and m == 1) or ((m + 1) % n == 0):
pr = True
Expand Down
2 changes: 1 addition & 1 deletion ciphers/rabin_miller.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def rabinMiller(num):
return False
else:
i = i + 1
v = (v ** 2) % num
v = (v**2) % num
return True


Expand Down
4 changes: 2 additions & 2 deletions ciphers/rsa_cipher.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def getTextFromBlocks(blockInts, messageLength, blockSize=DEFAULT_BLOCK_SIZE):
blockMessage = []
for i in range(blockSize - 1, -1, -1):
if len(message) + i < messageLength:
asciiNumber = blockInt // (BYTE_SIZE ** i)
blockInt = blockInt % (BYTE_SIZE ** i)
asciiNumber = blockInt // (BYTE_SIZE**i)
blockInt = blockInt % (BYTE_SIZE**i)
blockMessage.insert(0, chr(asciiNumber))
message.extend(blockMessage)
return "".join(message)
Expand Down
2 changes: 1 addition & 1 deletion ciphers/rsa_factorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def rsafactor(d: int, e: int, N: int) -> List[int]:
while True:
if t % 2 == 0:
t = t // 2
x = (g ** t) % N
x = (g**t) % N
y = math.gcd(x - 1, N)
if x > 1 and y > 1:
p = y
Expand Down
8 changes: 4 additions & 4 deletions computer_vision/harriscorner.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def detect(self, img_path: str):
color_img = img.copy()
color_img = cv2.cvtColor(color_img, cv2.COLOR_GRAY2RGB)
dy, dx = np.gradient(img)
ixx = dx ** 2
iyy = dy ** 2
ixx = dx**2
iyy = dy**2
ixy = dx * dy
k = 0.04
offset = self.window_size // 2
Expand All @@ -56,9 +56,9 @@ def detect(self, img_path: str):
y - offset : y + offset + 1, x - offset : x + offset + 1
].sum()

det = (wxx * wyy) - (wxy ** 2)
det = (wxx * wyy) - (wxy**2)
trace = wxx + wyy
r = det - k * (trace ** 2)
r = det - k * (trace**2)
# Can change the value
if r > 0.5:
corner_list.append([x, y, r])
Expand Down
6 changes: 3 additions & 3 deletions digital_image_processing/index_calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def CVI(self):
https://www.indexdatabase.de/db/i-single.php?id=391
:return: index
"""
return self.nir * (self.red / (self.green ** 2))
return self.nir * (self.red / (self.green**2))

def GLI(self):
"""
Expand Down Expand Up @@ -295,7 +295,7 @@ def ATSAVI(self, X=0.08, a=1.22, b=0.03):
"""
return a * (
(self.nir - a * self.red - b)
/ (a * self.nir + self.red - a * b + X * (1 + a ** 2))
/ (a * self.nir + self.red - a * b + X * (1 + a**2))
)

def BWDRVI(self):
Expand Down Expand Up @@ -363,7 +363,7 @@ def GEMI(self):
https://www.indexdatabase.de/db/i-single.php?id=25
:return: index
"""
n = (2 * (self.nir ** 2 - self.red ** 2) + 1.5 * self.nir + 0.5 * self.red) / (
n = (2 * (self.nir**2 - self.red**2) + 1.5 * self.nir + 0.5 * self.red) / (
self.nir + self.red + 0.5
)
return n * (1 - 0.25 * n) - (self.red - 0.125) / (1 - self.red)
Expand Down
2 changes: 1 addition & 1 deletion graphics/bezier_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def basis_function(self, t: float) -> List[float]:
for i in range(len(self.list_of_points)):
# basis function for each i
output_values.append(
comb(self.degree, i) * ((1 - t) ** (self.degree - i)) * (t ** i)
comb(self.degree, i) * ((1 - t) ** (self.degree - i)) * (t**i)
)
# the basis must sum up to 1 for it to produce a valid Bezier curve.
assert round(sum(output_values), 5) == 1
Expand Down
2 changes: 1 addition & 1 deletion graphs/bidirectional_a_star.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def calculate_heuristic(self) -> float:
if HEURISTIC == 1:
return abs(dx) + abs(dy)
else:
return sqrt(dy ** 2 + dx ** 2)
return sqrt(dy**2 + dx**2)

def __lt__(self, other) -> bool:
return self.f_cost < other.f_cost
Expand Down
4 changes: 2 additions & 2 deletions hashes/chaos_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def xorshift(X, Y):
params_space[key] = (machine_time * 0.01 + r * 1.01) % 1 + 3

# Choosing Chaotic Data
X = int(buffer_space[(key + 2) % m] * (10 ** 10))
Y = int(buffer_space[(key - 2) % m] * (10 ** 10))
X = int(buffer_space[(key + 2) % m] * (10**10))
Y = int(buffer_space[(key - 2) % m] * (10**10))

# Machine Time
machine_time += 1
Expand Down
2 changes: 1 addition & 1 deletion hashes/hamming_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def emitterConverter(sizePar, data):
>>> emitterConverter(4, "101010111111")
['1', '1', '1', '1', '0', '1', '0', '0', '1', '0', '1', '1', '1', '1', '1', '1']
"""
if sizePar + len(data) <= 2 ** sizePar - (len(data) - 1):
if sizePar + len(data) <= 2**sizePar - (len(data) - 1):
print("ERROR - size of parity don't match with size of data")
exit(0)

Expand Down
6 changes: 3 additions & 3 deletions hashes/md5.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def not32(i):

def sum32(a, b):
""" """
return (a + b) % 2 ** 32
return (a + b) % 2**32


def leftrot32(i, s):
Expand All @@ -115,7 +115,7 @@ def md5me(testString):
bs += format(ord(i), "08b")
bs = pad(bs)

tvals = [int(2 ** 32 * abs(math.sin(i + 1))) for i in range(64)]
tvals = [int(2**32 * abs(math.sin(i + 1))) for i in range(64)]

a0 = 0x67452301
b0 = 0xEFCDAB89
Expand Down Expand Up @@ -212,7 +212,7 @@ def md5me(testString):
dtemp = D
D = C
C = B
B = sum32(B, leftrot32((A + f + tvals[i] + m[g]) % 2 ** 32, s[i]))
B = sum32(B, leftrot32((A + f + tvals[i] + m[g]) % 2**32, s[i]))
A = dtemp
a0 = sum32(a0, A)
b0 = sum32(b0, B)
Expand Down
2 changes: 1 addition & 1 deletion linear_algebra/src/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def euclidLength(self):
"""
summe = 0
for c in self.__components:
summe += c ** 2
summe += c**2
return math.sqrt(summe)

def __add__(self, other):
Expand Down
2 changes: 1 addition & 1 deletion machine_learning/k_means_clust.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def compute_heterogeneity(data, k, centroids, cluster_assignment):
distances = pairwise_distances(
member_data_points, [centroids[i]], metric="euclidean"
)
squared_distances = distances ** 2
squared_distances = distances**2
heterogeneity += np.sum(squared_distances)

return heterogeneity
Expand Down
8 changes: 4 additions & 4 deletions machine_learning/sequential_minimum_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,15 +339,15 @@ def _get_new_alpha(self, i1, i2, a1, a2, e1, e2, y1, y2):
ol = (
l1 * f1
+ L * f2
+ 1 / 2 * l1 ** 2 * K(i1, i1)
+ 1 / 2 * L ** 2 * K(i2, i2)
+ 1 / 2 * l1**2 * K(i1, i1)
+ 1 / 2 * L**2 * K(i2, i2)
+ s * L * l1 * K(i1, i2)
)
oh = (
h1 * f1
+ H * f2
+ 1 / 2 * h1 ** 2 * K(i1, i1)
+ 1 / 2 * H ** 2 * K(i2, i2)
+ 1 / 2 * h1**2 * K(i1, i1)
+ 1 / 2 * H**2 * K(i2, i2)
+ s * H * h1 * K(i1, i2)
)
"""
Expand Down
2 changes: 1 addition & 1 deletion maths/area_under_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def trapezoidal_area(
if __name__ == "__main__":

def f(x):
return x ** 3 + x ** 2
return x**3 + x**2

print("f(x) = x^3 + x^2")
print("The area between the curve, x = -5, x = 5 and the x axis is:")
Expand Down
2 changes: 1 addition & 1 deletion maths/armstrong_numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def armstrong_number(n: int) -> bool:
temp = n
while temp > 0:
rem = temp % 10
sum += rem ** number_of_digits
sum += rem**number_of_digits
temp //= 10
return n == sum

Expand Down
4 changes: 2 additions & 2 deletions maths/basic_maths.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ def sum_of_divisors(n: int) -> int:
temp += 1
n = int(n / 2)
if temp > 1:
s *= (2 ** temp - 1) / (2 - 1)
s *= (2**temp - 1) / (2 - 1)
for i in range(3, int(math.sqrt(n)) + 1, 2):
temp = 1
while n % i == 0:
temp += 1
n = int(n / i)
if temp > 1:
s *= (i ** temp - 1) / (i - 1)
s *= (i**temp - 1) / (i - 1)
return int(s)


Expand Down
2 changes: 1 addition & 1 deletion maths/gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def gaussian(x, mu: float = 0.0, sigma: float = 1.0) -> int:
>>> gaussian(2523, mu=234234, sigma=3425)
0.0
"""
return 1 / sqrt(2 * pi * sigma ** 2) * exp(-((x - mu) ** 2) / 2 * sigma ** 2)
return 1 / sqrt(2 * pi * sigma**2) * exp(-((x - mu) ** 2) / 2 * sigma**2)


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions maths/karatsuba.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def karatsuba(a, b):
m1 = max(len(str(a)), len(str(b)))
m2 = m1 // 2

a1, a2 = divmod(a, 10 ** m2)
b1, b2 = divmod(b, 10 ** m2)
a1, a2 = divmod(a, 10**m2)
b1, b2 = divmod(b, 10**m2)

x = karatsuba(a2, b2)
y = karatsuba((a1 + a2), (b1 + b2))
Expand Down
2 changes: 1 addition & 1 deletion maths/monte_carlo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def pi_estimator(iterations: int):
"""
# A local function to see if a dot lands in the circle.
def is_in_circle(x: float, y: float) -> bool:
distance_from_centre = sqrt((x ** 2) + (y ** 2))
distance_from_centre = sqrt((x**2) + (y**2))
# Our circle has a radius of 1, so a distance
# greater than 1 would land outside the circle.
return distance_from_centre <= 1
Expand Down
2 changes: 1 addition & 1 deletion maths/numerical_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def trapezoidal_area(
if __name__ == "__main__":

def f(x):
return x ** 3
return x**3

print("f(x) = x^3")
print("The area between the curve, x = -10, x = 10 and the x axis is:")
Expand Down
2 changes: 1 addition & 1 deletion maths/pi_monte_carlo_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def is_in_unit_circle(self) -> bool:
True, if the point lies in the unit circle
False, otherwise
"""
return (self.x ** 2 + self.y ** 2) <= 1
return (self.x**2 + self.y**2) <= 1

@classmethod
def random_unit_square(cls):
Expand Down
2 changes: 1 addition & 1 deletion maths/polynomial_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def evaluate_poly(poly: Sequence[float], x: float) -> float:
>>> evaluate_poly((0.0, 0.0, 5.0, 9.3, 7.0), 10.0)
79800.0
"""
return sum(c * (x ** i) for i, c in enumerate(poly))
return sum(c * (x**i) for i, c in enumerate(poly))


def horner(poly: Sequence[float], x: float) -> float:
Expand Down
2 changes: 1 addition & 1 deletion maths/radix2_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __DFT(self, which):
next_ncol = self.C_max_length // 2
while next_ncol > 0:
new_dft = [[] for i in range(next_ncol)]
root = self.root ** next_ncol
root = self.root**next_ncol

# First half of next step
current_root = 1
Expand Down
2 changes: 1 addition & 1 deletion maths/segmented_sieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ def sieve(n):
return prime


print(sieve(10 ** 6))
print(sieve(10**6))
4 changes: 2 additions & 2 deletions project_euler/problem_06/sol1.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def solution(n):
suma = 0
sumb = 0
for i in range(1, n + 1):
suma += i ** 2
suma += i**2
sumb += i
sum = sumb ** 2 - suma
sum = sumb**2 - suma
return sum


Expand Down
2 changes: 1 addition & 1 deletion project_euler/problem_07/sol2.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


def isprime(number):
for i in range(2, int(number ** 0.5) + 1):
for i in range(2, int(number**0.5) + 1):
if number % i == 0:
return False
return True
Expand Down
2 changes: 1 addition & 1 deletion project_euler/problem_09/sol1.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def solution():
for b in range(400):
for c in range(500):
if a < b < c:
if (a ** 2) + (b ** 2) == (c ** 2):
if (a**2) + (b**2) == (c**2):
if (a + b + c) == 1000:
return a * b * c

Expand Down
2 changes: 1 addition & 1 deletion project_euler/problem_10/sol3.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def prime_sum(n: int) -> int:
list_[0] = 1
list_[1] = 1

for i in range(2, int(n ** 0.5) + 1):
for i in range(2, int(n**0.5) + 1):
if list_[i] == 0:
for j in range(i * i, n + 1, i):
list_[j] = 1
Expand Down
Loading