Skip to content

Commit 2777e5d

Browse files
committed
fix: Correct ruff problems
1 parent 793e564 commit 2777e5d

File tree

5 files changed

+10
-11
lines changed

5 files changed

+10
-11
lines changed

Diff for: conversions/prefix_conversions_string.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def add_si_prefix(value: float) -> str:
9696
for name_prefix, value_prefix in prefixes.items():
9797
numerical_part = value / (10**value_prefix)
9898
if numerical_part > 1:
99-
return f"{str(numerical_part)} {name_prefix}"
99+
return f"{numerical_part!s} {name_prefix}"
100100
return str(value)
101101

102102

@@ -111,7 +111,7 @@ def add_binary_prefix(value: float) -> str:
111111
for prefix in BinaryUnit:
112112
numerical_part = value / (2**prefix.value)
113113
if numerical_part > 1:
114-
return f"{str(numerical_part)} {prefix.name}"
114+
return f"{numerical_part!s} {prefix.name}"
115115
return str(value)
116116

117117

Diff for: conversions/rgb_hsv_conversion.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ def rgb_to_hsv(red: int, green: int, blue: int) -> list[float]:
121121
float_red = red / 255
122122
float_green = green / 255
123123
float_blue = blue / 255
124-
value = max(max(float_red, float_green), float_blue)
125-
chroma = value - min(min(float_red, float_green), float_blue)
124+
value = max(float_red, float_green, float_blue)
125+
chroma = value - min(float_red, float_green, float_blue)
126126
saturation = 0 if value == 0 else chroma / value
127127

128128
if chroma == 0:

Diff for: divide_and_conquer/strassen_matrix_multiplication.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def strassen(matrix1: list, matrix2: list) -> list:
122122
if dimension1[0] == dimension1[1] and dimension2[0] == dimension2[1]:
123123
return [matrix1, matrix2]
124124

125-
maximum = max(max(dimension1), max(dimension2))
125+
maximum = max(dimension1, dimension2)
126126
maxim = int(math.pow(2, math.ceil(math.log2(maximum))))
127127
new_matrix1 = matrix1
128128
new_matrix2 = matrix2

Diff for: maths/euclidean_distance.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
from __future__ import annotations
22

33
from collections.abc import Iterable
4-
from typing import Union
54

65
import numpy as np
76

8-
Vector = Union[Iterable[float], Iterable[int], np.ndarray]
9-
VectorOut = Union[np.float64, int, float]
7+
Vector = Iterable[float] | Iterable[int], np.ndarray
8+
VectorOut = np.float64 | int, float
109

1110

1211
def euclidean_distance(vector_1: Vector, vector_2: Vector) -> VectorOut:

Diff for: physics/horizontal_projectile_motion.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,6 @@ def test_motion() -> None:
147147
# Print results
148148
print()
149149
print("Results: ")
150-
print(f"Horizontal Distance: {str(horizontal_distance(init_vel, angle))} [m]")
151-
print(f"Maximum Height: {str(max_height(init_vel, angle))} [m]")
152-
print(f"Total Time: {str(total_time(init_vel, angle))} [s]")
150+
print(f"Horizontal Distance: {horizontal_distance(init_vel, angle)!s} [m]")
151+
print(f"Maximum Height: {max_height(init_vel, angle)!s} [m]")
152+
print(f"Total Time: {total_time(init_vel, angle)!s} [s]")

0 commit comments

Comments
 (0)