Skip to content

Commit 4700297

Browse files
Enable ruff RUF002 rule (TheAlgorithms#11377)
* Enable ruff RUF002 rule * Fix --------- Co-authored-by: Christian Clauss <cclauss@me.com>
1 parent 79dc7c9 commit 4700297

File tree

69 files changed

+132
-131
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+132
-131
lines changed

backtracking/sudoku.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
2-
Given a partially filled 9×9 2D array, the objective is to fill a 9×9
2+
Given a partially filled 9x9 2D array, the objective is to fill a 9x9
33
square grid with digits numbered 1 to 9, so that every row, column, and
4-
and each of the nine 3×3 sub-grids contains all of the digits.
4+
and each of the nine 3x3 sub-grids contains all of the digits.
55
66
This can be solved using Backtracking and is similar to n-queens.
77
We check to see if a cell is safe or not and recursively call the

bit_manipulation/single_bit_manipulation_operations.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ def set_bit(number: int, position: int) -> int:
88
Set the bit at position to 1.
99
1010
Details: perform bitwise or for given number and X.
11-
Where X is a number with all the bits zeroes and bit on given
12-
position one.
11+
Where X is a number with all the bits - zeroes and bit on given
12+
position - one.
1313
1414
>>> set_bit(0b1101, 1) # 0b1111
1515
15
@@ -26,8 +26,8 @@ def clear_bit(number: int, position: int) -> int:
2626
Set the bit at position to 0.
2727
2828
Details: perform bitwise and for given number and X.
29-
Where X is a number with all the bits ones and bit on given
30-
position zero.
29+
Where X is a number with all the bits - ones and bit on given
30+
position - zero.
3131
3232
>>> clear_bit(0b10010, 1) # 0b10000
3333
16
@@ -42,8 +42,8 @@ def flip_bit(number: int, position: int) -> int:
4242
Flip the bit at position.
4343
4444
Details: perform bitwise xor for given number and X.
45-
Where X is a number with all the bits zeroes and bit on given
46-
position one.
45+
Where X is a number with all the bits - zeroes and bit on given
46+
position - one.
4747
4848
>>> flip_bit(0b101, 1) # 0b111
4949
7
@@ -79,7 +79,7 @@ def get_bit(number: int, position: int) -> int:
7979
Get the bit at the given position
8080
8181
Details: perform bitwise and for the given number and X,
82-
Where X is a number with all the bits zeroes and bit on given position one.
82+
Where X is a number with all the bits - zeroes and bit on given position - one.
8383
If the result is not equal to 0, then the bit on the given position is 1, else 0.
8484
8585
>>> get_bit(0b1010, 0)

compression/burrows_wheeler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
https://en.wikipedia.org/wiki/Burrows%E2%80%93Wheeler_transform
33
4-
The BurrowsWheeler transform (BWT, also called block-sorting compression)
4+
The Burrows-Wheeler transform (BWT, also called block-sorting compression)
55
rearranges a character string into runs of similar characters. This is useful
66
for compression, since it tends to be easy to compress a string that has runs
77
of repeated characters by techniques such as move-to-front transform and

compression/lempel_ziv.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
One of the several implementations of LempelZivWelch compression algorithm
2+
One of the several implementations of Lempel-Ziv-Welch compression algorithm
33
https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch
44
"""
55

@@ -43,7 +43,7 @@ def add_key_to_lexicon(
4343

4444
def compress_data(data_bits: str) -> str:
4545
"""
46-
Compresses given data_bits using LempelZivWelch compression algorithm
46+
Compresses given data_bits using Lempel-Ziv-Welch compression algorithm
4747
and returns the result as a string
4848
"""
4949
lexicon = {"0": "0", "1": "1"}

compression/lempel_ziv_decompress.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
One of the several implementations of LempelZivWelch decompression algorithm
2+
One of the several implementations of Lempel-Ziv-Welch decompression algorithm
33
https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch
44
"""
55

@@ -26,7 +26,7 @@ def read_file_binary(file_path: str) -> str:
2626

2727
def decompress_data(data_bits: str) -> str:
2828
"""
29-
Decompresses given data_bits using LempelZivWelch compression algorithm
29+
Decompresses given data_bits using Lempel-Ziv-Welch compression algorithm
3030
and returns the result as a string
3131
"""
3232
lexicon = {"0": "0", "1": "1"}

data_structures/binary_tree/red_black_tree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class RedBlackTree:
1717
and slower for reading in the average case, though, because they're
1818
both balanced binary search trees, both will get the same asymptotic
1919
performance.
20-
To read more about them, https://en.wikipedia.org/wiki/Redblack_tree
20+
To read more about them, https://en.wikipedia.org/wiki/Red-black_tree
2121
Unless otherwise specified, all asymptotic runtimes are specified in
2222
terms of the size of the tree.
2323
"""

digital_image_processing/edge_detection/canny.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ def detect_high_low_threshold(
7474
image_shape, destination, threshold_low, threshold_high, weak, strong
7575
):
7676
"""
77-
High-Low threshold detection. If an edge pixels gradient value is higher
77+
High-Low threshold detection. If an edge pixel's gradient value is higher
7878
than the high threshold value, it is marked as a strong edge pixel. If an
79-
edge pixels gradient value is smaller than the high threshold value and
79+
edge pixel's gradient value is smaller than the high threshold value and
8080
larger than the low threshold value, it is marked as a weak edge pixel. If
8181
an edge pixel's value is smaller than the low threshold value, it will be
8282
suppressed.

digital_image_processing/index_calculation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def arv12(self):
182182
Atmospherically Resistant Vegetation Index 2
183183
https://www.indexdatabase.de/db/i-single.php?id=396
184184
:return: index
185-
0.18+1.17*(self.nirself.red)/(self.nir+self.red)
185+
-0.18+1.17*(self.nir-self.red)/(self.nir+self.red)
186186
"""
187187
return -0.18 + (1.17 * ((self.nir - self.red) / (self.nir + self.red)))
188188

dynamic_programming/combination_sum_iv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
The basic idea is to go over recursively to find the way such that the sum
1919
of chosen elements is “tar”. For every element, we have two choices
2020
1. Include the element in our set of chosen elements.
21-
2. Dont include the element in our set of chosen elements.
21+
2. Don't include the element in our set of chosen elements.
2222
"""
2323

2424

electronics/coulombs_law.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ def couloumbs_law(
2020
2121
Reference
2222
----------
23-
Coulomb (1785) "Premier mémoire sur lélectricité et le magnétisme,"
24-
Histoire de lAcadémie Royale des Sciences, pp. 569577.
23+
Coulomb (1785) "Premier mémoire sur l'électricité et le magnétisme,"
24+
Histoire de l'Académie Royale des Sciences, pp. 569-577.
2525
2626
Parameters
2727
----------

0 commit comments

Comments
 (0)