Skip to content

Commit 5f4da5d

Browse files
cclaussgithub-actions
and
github-actions
authored
isort --profile black . (TheAlgorithms#2181)
* updating DIRECTORY.md * isort --profile black . * Black after * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
1 parent cd3e8f9 commit 5f4da5d

File tree

80 files changed

+123
-127
lines changed

Some content is hidden

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

80 files changed

+123
-127
lines changed

.github/workflows/autoblack.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
if: failure()
1818
run: |
1919
black .
20-
isort --profile black --recursive .
20+
isort --profile black .
2121
git config --global user.name github-actions
2222
git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com'
2323
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY

DIRECTORY.md

+2
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@
253253
* [Finding Bridges](https://github.com/TheAlgorithms/Python/blob/master/graphs/finding_bridges.py)
254254
* [Frequent Pattern Graph Miner](https://github.com/TheAlgorithms/Python/blob/master/graphs/frequent_pattern_graph_miner.py)
255255
* [G Topological Sort](https://github.com/TheAlgorithms/Python/blob/master/graphs/g_topological_sort.py)
256+
* [Gale Shapley Bigraph](https://github.com/TheAlgorithms/Python/blob/master/graphs/gale_shapley_bigraph.py)
256257
* [Graph List](https://github.com/TheAlgorithms/Python/blob/master/graphs/graph_list.py)
257258
* [Graph Matrix](https://github.com/TheAlgorithms/Python/blob/master/graphs/graph_matrix.py)
258259
* [Graphs Floyd Warshall](https://github.com/TheAlgorithms/Python/blob/master/graphs/graphs_floyd_warshall.py)
@@ -596,6 +597,7 @@
596597

597598
## Searches
598599
* [Binary Search](https://github.com/TheAlgorithms/Python/blob/master/searches/binary_search.py)
600+
* [Double Linear Search](https://github.com/TheAlgorithms/Python/blob/master/searches/double_linear_search.py)
599601
* [Fibonacci Search](https://github.com/TheAlgorithms/Python/blob/master/searches/fibonacci_search.py)
600602
* [Hill Climbing](https://github.com/TheAlgorithms/Python/blob/master/searches/hill_climbing.py)
601603
* [Interpolation Search](https://github.com/TheAlgorithms/Python/blob/master/searches/interpolation_search.py)

arithmetic_analysis/in_static_equilibrium.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
mypy : passed
77
"""
88

9-
from numpy import array, cos, sin, radians, cross # type: ignore
109
from typing import List
1110

11+
from numpy import array, cos, cross, radians, sin # type: ignore
12+
1213

1314
def polar_force(
1415
magnitude: float, angle: float, radian_mode: bool = False

arithmetic_analysis/newton_raphson.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# Author: Syed Haseeb Shah (github.com/QuantumNovice)
33
# The Newton-Raphson method (also known as Newton's method) is a way to
44
# quickly find a good approximation for the root of a real-valued function
5-
65
from decimal import Decimal
76
from math import * # noqa: F401, F403
7+
88
from sympy import diff
99

1010

ciphers/hill_cipher.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
https://www.youtube.com/watch?v=4RhLNDqcjpA
3636
3737
"""
38-
3938
import string
39+
4040
import numpy
4141

4242

ciphers/playfair_cipher.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import string
21
import itertools
2+
import string
33

44

55
def chunker(seq, size):

compression/burrows_wheeler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
original character. The BWT is thus a "free" method of improving the efficiency
1111
of text compression algorithms, costing only some extra computation.
1212
"""
13-
from typing import List, Dict
13+
from typing import Dict, List
1414

1515

1616
def all_rotations(s: str) -> List[str]:

computer_vision/harriscorner.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import numpy as np
21
import cv2
2+
import numpy as np
33

44
"""
55
Harris Corner Detector

data_structures/binary_tree/non_recursive_segment_tree.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
>>> st.query(0, 2)
3636
[1, 2, 3]
3737
"""
38-
from typing import List, Callable, TypeVar
38+
from typing import Callable, List, TypeVar
3939

4040
T = TypeVar("T")
4141

data_structures/binary_tree/segment_tree_other.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
allowing queries to be done later in log(N) time
44
function takes 2 values and returns a same type value
55
"""
6-
7-
from queue import Queue
86
from collections.abc import Sequence
7+
from queue import Queue
98

109

1110
class SegmentTreeNode(object):

data_structures/hashing/double_hash.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python3
2-
32
from hash_table import HashTable
4-
from number_theory.prime_numbers import next_prime, check_prime
3+
from number_theory.prime_numbers import check_prime, next_prime
54

65

76
class DoubleHash(HashTable):

data_structures/hashing/hash_table_with_linked_list.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from hash_table import HashTable
21
from collections import deque
32

3+
from hash_table import HashTable
4+
45

56
class HashTableWithLinkedList(HashTable):
67
def __init__(self, *args, **kwargs):

digital_image_processing/convert_to_negative.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
"""
22
Implemented an algorithm using opencv to convert a colored image into its negative
33
"""
4-
5-
from cv2 import imread, imshow, waitKey, destroyAllWindows
4+
from cv2 import destroyAllWindows, imread, imshow, waitKey
65

76

87
def convert_to_negative(img):

digital_image_processing/dithering/burkes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""
22
Implementation Burke's algorithm (dithering)
33
"""
4-
from cv2 import destroyAllWindows, imread, imshow, waitKey
54
import numpy as np
5+
from cv2 import destroyAllWindows, imread, imshow, waitKey
66

77

88
class Burkes:

digital_image_processing/edge_detection/canny.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import cv2
22
import numpy as np
3+
34
from digital_image_processing.filters.convolve import img_convolve
45
from digital_image_processing.filters.sobel_filter import sobel_filter
56

digital_image_processing/filters/bilateral_filter.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
Output:
1010
img:A 2d zero padded image with values in between 0 and 1
1111
"""
12+
import math
13+
import sys
1214

1315
import cv2
1416
import numpy as np
15-
import math
16-
import sys
1717

1818

1919
def vec_gaussian(img: np.ndarray, variance: float) -> np.ndarray:

digital_image_processing/filters/convolve.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# @Author : lightXu
22
# @File : convolve.py
33
# @Time : 2019/7/8 0008 下午 16:13
4-
from cv2 import imread, cvtColor, COLOR_BGR2GRAY, imshow, waitKey
5-
from numpy import array, zeros, ravel, pad, dot, uint8
4+
from cv2 import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey
5+
from numpy import array, dot, pad, ravel, uint8, zeros
66

77

88
def im2col(image, block_size):

digital_image_processing/filters/gaussian_filter.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
"""
22
Implementation of gaussian filter algorithm
33
"""
4-
from cv2 import imread, cvtColor, COLOR_BGR2GRAY, imshow, waitKey
5-
from numpy import pi, mgrid, exp, square, zeros, ravel, dot, uint8
64
from itertools import product
75

6+
from cv2 import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey
7+
from numpy import dot, exp, mgrid, pi, ravel, square, uint8, zeros
8+
89

910
def gen_gaussian_kernel(k_size, sigma):
1011
center = k_size // 2

digital_image_processing/filters/median_filter.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
"""
22
Implementation of median filter algorithm
33
"""
4-
5-
from cv2 import imread, cvtColor, COLOR_BGR2GRAY, imshow, waitKey
6-
from numpy import zeros_like, ravel, sort, multiply, divide, int8
4+
from cv2 import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey
5+
from numpy import divide, int8, multiply, ravel, sort, zeros_like
76

87

98
def median_filter(gray_img, mask=3):

digital_image_processing/filters/sobel_filter.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# @File : sobel_filter.py
33
# @Time : 2019/7/8 0008 下午 16:26
44
import numpy as np
5-
from cv2 import imread, cvtColor, COLOR_BGR2GRAY, imshow, waitKey
5+
from cv2 import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey
6+
67
from digital_image_processing.filters.convolve import img_convolve
78

89

digital_image_processing/histogram_equalization/histogram_stretch.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
import copy
77
import os
88

9-
import numpy as np
10-
119
import cv2
12-
import matplotlib.pyplot as plt
10+
import numpy as np
11+
from matplotlib import pyplot as plt
1312

1413

1514
class contrastStretch:

digital_image_processing/resize/resize.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
""" Multiple image resizing techniques """
22
import numpy as np
3-
from cv2 import imread, imshow, waitKey, destroyAllWindows
3+
from cv2 import destroyAllWindows, imread, imshow, waitKey
44

55

66
class NearestNeighbour:

digital_image_processing/rotation/rotation.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from matplotlib import pyplot as plt
2-
import numpy as np
31
import cv2
2+
import numpy as np
3+
from matplotlib import pyplot as plt
44

55

66
def get_rotation(

digital_image_processing/sepia.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
"""
22
Implemented an algorithm using opencv to tone an image with sepia technique
33
"""
4-
5-
from cv2 import imread, imshow, waitKey, destroyAllWindows
4+
from cv2 import destroyAllWindows, imread, imshow, waitKey
65

76

87
def make_sepia(img, factor: int):

digital_image_processing/test_digital_image_processing.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
"""
22
PyTest's for Digital Image Processing
33
"""
4-
5-
import digital_image_processing.edge_detection.canny as canny
6-
import digital_image_processing.filters.gaussian_filter as gg
7-
import digital_image_processing.filters.median_filter as med
8-
import digital_image_processing.filters.sobel_filter as sob
9-
import digital_image_processing.filters.convolve as conv
10-
import digital_image_processing.change_contrast as cc
11-
import digital_image_processing.convert_to_negative as cn
12-
import digital_image_processing.sepia as sp
13-
import digital_image_processing.dithering.burkes as bs
14-
import digital_image_processing.resize.resize as rs
15-
from cv2 import imread, cvtColor, COLOR_BGR2GRAY
4+
from cv2 import COLOR_BGR2GRAY, cvtColor, imread
165
from numpy import array, uint8
176
from PIL import Image
187

8+
from digital_image_processing import change_contrast as cc
9+
from digital_image_processing import convert_to_negative as cn
10+
from digital_image_processing import sepia as sp
11+
from digital_image_processing.dithering import burkes as bs
12+
from digital_image_processing.edge_detection import canny as canny
13+
from digital_image_processing.filters import convolve as conv
14+
from digital_image_processing.filters import gaussian_filter as gg
15+
from digital_image_processing.filters import median_filter as med
16+
from digital_image_processing.filters import sobel_filter as sob
17+
from digital_image_processing.resize import resize as rs
18+
1919
img = imread(r"digital_image_processing/image_data/lena_small.jpg")
2020
gray = cvtColor(img, COLOR_BGR2GRAY)
2121

dynamic_programming/fractional_knapsack.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from itertools import accumulate
21
from bisect import bisect
2+
from itertools import accumulate
33

44

55
def fracKnapsack(vl, wt, W, n):

dynamic_programming/max_sub_array.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@ def max_sub_array(nums: List[int]) -> int:
7373
A random simulation of this algorithm.
7474
"""
7575
import time
76-
import matplotlib.pyplot as plt
7776
from random import randint
7877

78+
from matplotlib import pyplot as plt
79+
7980
inputs = [10, 100, 1000, 10000, 50000, 100000, 200000, 300000, 400000, 500000]
8081
tim = []
8182
for i in inputs:

dynamic_programming/optimal_binary_search_tree.py

-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
# frequencies will be placed near the root of the tree while the nodes
1717
# with low frequencies will be placed near the leaves of the tree thus
1818
# reducing search time in the most frequent instances.
19-
2019
import sys
21-
2220
from random import randint
2321

2422

fuzzy_logic/fuzzy_operations.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import numpy as np
1010
import skfuzzy as fuzz
1111

12-
1312
if __name__ == "__main__":
1413
# Create universe of discourse in Python using linspace ()
1514
X = np.linspace(start=0, stop=75, num=75, endpoint=True, retstep=False)
@@ -45,7 +44,7 @@
4544
# max-product composition
4645

4746
# Plot each set A, set B and each operation result using plot() and subplot().
48-
import matplotlib.pyplot as plt
47+
from matplotlib import pyplot as plt
4948

5049
plt.figure()
5150

geodesy/lamberts_ellipsoidal_distance.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from math import atan, cos, radians, sin, tan
2+
23
from haversine_distance import haversine_distance
34

45

graphics/bezier_curve.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# https://en.wikipedia.org/wiki/B%C3%A9zier_curve
22
# https://www.tutorialspoint.com/computer_graphics/computer_graphics_curves.htm
3-
43
from typing import List, Tuple
4+
55
from scipy.special import comb
66

77

@@ -78,7 +78,7 @@ def plot_curve(self, step_size: float = 0.01):
7878
step_size: defines the step(s) at which to evaluate the Bezier curve.
7979
The smaller the step size, the finer the curve produced.
8080
"""
81-
import matplotlib.pyplot as plt
81+
from matplotlib import pyplot as plt
8282

8383
to_plot_x: List[float] = [] # x coordinates of points to plot
8484
to_plot_y: List[float] = [] # y coordinates of points to plot

graphs/basic_graphs.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from collections import deque
22

3-
43
if __name__ == "__main__":
54
# Accept No. of Nodes and edges
65
n, m = map(int, input().split(" "))

graphs/breadth_first_search_2.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
mark w as explored
1313
add w to Q (at the end)
1414
"""
15-
16-
from typing import Set, Dict
15+
from typing import Dict, Set
1716

1817
G = {
1918
"A": ["B", "C"],

graphs/depth_first_search.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
if v unexplored:
1212
DFS(G, v)
1313
"""
14-
15-
from typing import Set, Dict
14+
from typing import Dict, Set
1615

1716

1817
def depth_first_search(graph: Dict, start: str) -> Set[int]:

graphs/directed_and_undirected_(weighted)_graph.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from collections import deque
2-
import random as rand
31
import math as math
2+
import random as rand
43
import time
4+
from collections import deque
55

66
# the default weight is 1 if not assigned but all the implementation is weighted
77

graphs/multi_heuristic_astar.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import heapq
2+
23
import numpy as np
34

45

greedy_method/test_knapsack.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import unittest
2+
23
import greedy_knapsack as kp
34

45

0 commit comments

Comments
 (0)