Skip to content

Commit

Permalink
isort --profile black . (TheAlgorithms#2181)
Browse files Browse the repository at this point in the history
* updating DIRECTORY.md

* isort --profile black .

* Black after

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
  • Loading branch information
cclauss and github-actions authored Jul 6, 2020
1 parent cd3e8f9 commit 5f4da5d
Show file tree
Hide file tree
Showing 80 changed files with 123 additions and 127 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/autoblack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
if: failure()
run: |
black .
isort --profile black --recursive .
isort --profile black .
git config --global user.name github-actions
git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
Expand Down
2 changes: 2 additions & 0 deletions DIRECTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@
* [Finding Bridges](https://github.com/TheAlgorithms/Python/blob/master/graphs/finding_bridges.py)
* [Frequent Pattern Graph Miner](https://github.com/TheAlgorithms/Python/blob/master/graphs/frequent_pattern_graph_miner.py)
* [G Topological Sort](https://github.com/TheAlgorithms/Python/blob/master/graphs/g_topological_sort.py)
* [Gale Shapley Bigraph](https://github.com/TheAlgorithms/Python/blob/master/graphs/gale_shapley_bigraph.py)
* [Graph List](https://github.com/TheAlgorithms/Python/blob/master/graphs/graph_list.py)
* [Graph Matrix](https://github.com/TheAlgorithms/Python/blob/master/graphs/graph_matrix.py)
* [Graphs Floyd Warshall](https://github.com/TheAlgorithms/Python/blob/master/graphs/graphs_floyd_warshall.py)
Expand Down Expand Up @@ -596,6 +597,7 @@

## Searches
* [Binary Search](https://github.com/TheAlgorithms/Python/blob/master/searches/binary_search.py)
* [Double Linear Search](https://github.com/TheAlgorithms/Python/blob/master/searches/double_linear_search.py)
* [Fibonacci Search](https://github.com/TheAlgorithms/Python/blob/master/searches/fibonacci_search.py)
* [Hill Climbing](https://github.com/TheAlgorithms/Python/blob/master/searches/hill_climbing.py)
* [Interpolation Search](https://github.com/TheAlgorithms/Python/blob/master/searches/interpolation_search.py)
Expand Down
3 changes: 2 additions & 1 deletion arithmetic_analysis/in_static_equilibrium.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
mypy : passed
"""

from numpy import array, cos, sin, radians, cross # type: ignore
from typing import List

from numpy import array, cos, cross, radians, sin # type: ignore


def polar_force(
magnitude: float, angle: float, radian_mode: bool = False
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 @@ -2,9 +2,9 @@
# Author: Syed Haseeb Shah (github.com/QuantumNovice)
# The Newton-Raphson method (also known as Newton's method) is a way to
# quickly find a good approximation for the root of a real-valued function

from decimal import Decimal
from math import * # noqa: F401, F403

from sympy import diff


Expand Down
2 changes: 1 addition & 1 deletion ciphers/hill_cipher.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
https://www.youtube.com/watch?v=4RhLNDqcjpA
"""

import string

import numpy


Expand Down
2 changes: 1 addition & 1 deletion ciphers/playfair_cipher.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import string
import itertools
import string


def chunker(seq, size):
Expand Down
2 changes: 1 addition & 1 deletion compression/burrows_wheeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
original character. The BWT is thus a "free" method of improving the efficiency
of text compression algorithms, costing only some extra computation.
"""
from typing import List, Dict
from typing import Dict, List


def all_rotations(s: str) -> List[str]:
Expand Down
2 changes: 1 addition & 1 deletion computer_vision/harriscorner.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
import cv2
import numpy as np

"""
Harris Corner Detector
Expand Down
2 changes: 1 addition & 1 deletion data_structures/binary_tree/non_recursive_segment_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
>>> st.query(0, 2)
[1, 2, 3]
"""
from typing import List, Callable, TypeVar
from typing import Callable, List, TypeVar

T = TypeVar("T")

Expand Down
3 changes: 1 addition & 2 deletions data_structures/binary_tree/segment_tree_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
allowing queries to be done later in log(N) time
function takes 2 values and returns a same type value
"""

from queue import Queue
from collections.abc import Sequence
from queue import Queue


class SegmentTreeNode(object):
Expand Down
3 changes: 1 addition & 2 deletions data_structures/hashing/double_hash.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python3

from hash_table import HashTable
from number_theory.prime_numbers import next_prime, check_prime
from number_theory.prime_numbers import check_prime, next_prime


class DoubleHash(HashTable):
Expand Down
3 changes: 2 additions & 1 deletion data_structures/hashing/hash_table_with_linked_list.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from hash_table import HashTable
from collections import deque

from hash_table import HashTable


class HashTableWithLinkedList(HashTable):
def __init__(self, *args, **kwargs):
Expand Down
3 changes: 1 addition & 2 deletions digital_image_processing/convert_to_negative.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"""
Implemented an algorithm using opencv to convert a colored image into its negative
"""

from cv2 import imread, imshow, waitKey, destroyAllWindows
from cv2 import destroyAllWindows, imread, imshow, waitKey


def convert_to_negative(img):
Expand Down
2 changes: 1 addition & 1 deletion digital_image_processing/dithering/burkes.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
Implementation Burke's algorithm (dithering)
"""
from cv2 import destroyAllWindows, imread, imshow, waitKey
import numpy as np
from cv2 import destroyAllWindows, imread, imshow, waitKey


class Burkes:
Expand Down
1 change: 1 addition & 0 deletions digital_image_processing/edge_detection/canny.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import cv2
import numpy as np

from digital_image_processing.filters.convolve import img_convolve
from digital_image_processing.filters.sobel_filter import sobel_filter

Expand Down
4 changes: 2 additions & 2 deletions digital_image_processing/filters/bilateral_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
Output:
img:A 2d zero padded image with values in between 0 and 1
"""
import math
import sys

import cv2
import numpy as np
import math
import sys


def vec_gaussian(img: np.ndarray, variance: float) -> np.ndarray:
Expand Down
4 changes: 2 additions & 2 deletions digital_image_processing/filters/convolve.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# @Author : lightXu
# @File : convolve.py
# @Time : 2019/7/8 0008 下午 16:13
from cv2 import imread, cvtColor, COLOR_BGR2GRAY, imshow, waitKey
from numpy import array, zeros, ravel, pad, dot, uint8
from cv2 import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey
from numpy import array, dot, pad, ravel, uint8, zeros


def im2col(image, block_size):
Expand Down
5 changes: 3 additions & 2 deletions digital_image_processing/filters/gaussian_filter.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""
Implementation of gaussian filter algorithm
"""
from cv2 import imread, cvtColor, COLOR_BGR2GRAY, imshow, waitKey
from numpy import pi, mgrid, exp, square, zeros, ravel, dot, uint8
from itertools import product

from cv2 import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey
from numpy import dot, exp, mgrid, pi, ravel, square, uint8, zeros


def gen_gaussian_kernel(k_size, sigma):
center = k_size // 2
Expand Down
5 changes: 2 additions & 3 deletions digital_image_processing/filters/median_filter.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""
Implementation of median filter algorithm
"""

from cv2 import imread, cvtColor, COLOR_BGR2GRAY, imshow, waitKey
from numpy import zeros_like, ravel, sort, multiply, divide, int8
from cv2 import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey
from numpy import divide, int8, multiply, ravel, sort, zeros_like


def median_filter(gray_img, mask=3):
Expand Down
3 changes: 2 additions & 1 deletion digital_image_processing/filters/sobel_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# @File : sobel_filter.py
# @Time : 2019/7/8 0008 下午 16:26
import numpy as np
from cv2 import imread, cvtColor, COLOR_BGR2GRAY, imshow, waitKey
from cv2 import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey

from digital_image_processing.filters.convolve import img_convolve


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
import copy
import os

import numpy as np

import cv2
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import pyplot as plt


class contrastStretch:
Expand Down
2 changes: 1 addition & 1 deletion digital_image_processing/resize/resize.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
""" Multiple image resizing techniques """
import numpy as np
from cv2 import imread, imshow, waitKey, destroyAllWindows
from cv2 import destroyAllWindows, imread, imshow, waitKey


class NearestNeighbour:
Expand Down
4 changes: 2 additions & 2 deletions digital_image_processing/rotation/rotation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from matplotlib import pyplot as plt
import numpy as np
import cv2
import numpy as np
from matplotlib import pyplot as plt


def get_rotation(
Expand Down
3 changes: 1 addition & 2 deletions digital_image_processing/sepia.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"""
Implemented an algorithm using opencv to tone an image with sepia technique
"""

from cv2 import imread, imshow, waitKey, destroyAllWindows
from cv2 import destroyAllWindows, imread, imshow, waitKey


def make_sepia(img, factor: int):
Expand Down
24 changes: 12 additions & 12 deletions digital_image_processing/test_digital_image_processing.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
"""
PyTest's for Digital Image Processing
"""

import digital_image_processing.edge_detection.canny as canny
import digital_image_processing.filters.gaussian_filter as gg
import digital_image_processing.filters.median_filter as med
import digital_image_processing.filters.sobel_filter as sob
import digital_image_processing.filters.convolve as conv
import digital_image_processing.change_contrast as cc
import digital_image_processing.convert_to_negative as cn
import digital_image_processing.sepia as sp
import digital_image_processing.dithering.burkes as bs
import digital_image_processing.resize.resize as rs
from cv2 import imread, cvtColor, COLOR_BGR2GRAY
from cv2 import COLOR_BGR2GRAY, cvtColor, imread
from numpy import array, uint8
from PIL import Image

from digital_image_processing import change_contrast as cc
from digital_image_processing import convert_to_negative as cn
from digital_image_processing import sepia as sp
from digital_image_processing.dithering import burkes as bs
from digital_image_processing.edge_detection import canny as canny
from digital_image_processing.filters import convolve as conv
from digital_image_processing.filters import gaussian_filter as gg
from digital_image_processing.filters import median_filter as med
from digital_image_processing.filters import sobel_filter as sob
from digital_image_processing.resize import resize as rs

img = imread(r"digital_image_processing/image_data/lena_small.jpg")
gray = cvtColor(img, COLOR_BGR2GRAY)

Expand Down
2 changes: 1 addition & 1 deletion dynamic_programming/fractional_knapsack.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from itertools import accumulate
from bisect import bisect
from itertools import accumulate


def fracKnapsack(vl, wt, W, n):
Expand Down
3 changes: 2 additions & 1 deletion dynamic_programming/max_sub_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ def max_sub_array(nums: List[int]) -> int:
A random simulation of this algorithm.
"""
import time
import matplotlib.pyplot as plt
from random import randint

from matplotlib import pyplot as plt

inputs = [10, 100, 1000, 10000, 50000, 100000, 200000, 300000, 400000, 500000]
tim = []
for i in inputs:
Expand Down
2 changes: 0 additions & 2 deletions dynamic_programming/optimal_binary_search_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
# frequencies will be placed near the root of the tree while the nodes
# with low frequencies will be placed near the leaves of the tree thus
# reducing search time in the most frequent instances.

import sys

from random import randint


Expand Down
3 changes: 1 addition & 2 deletions fuzzy_logic/fuzzy_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import numpy as np
import skfuzzy as fuzz


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

# Plot each set A, set B and each operation result using plot() and subplot().
import matplotlib.pyplot as plt
from matplotlib import pyplot as plt

plt.figure()

Expand Down
1 change: 1 addition & 0 deletions geodesy/lamberts_ellipsoidal_distance.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from math import atan, cos, radians, sin, tan

from haversine_distance import haversine_distance


Expand Down
4 changes: 2 additions & 2 deletions graphics/bezier_curve.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# https://en.wikipedia.org/wiki/B%C3%A9zier_curve
# https://www.tutorialspoint.com/computer_graphics/computer_graphics_curves.htm

from typing import List, Tuple

from scipy.special import comb


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

to_plot_x: List[float] = [] # x coordinates of points to plot
to_plot_y: List[float] = [] # y coordinates of points to plot
Expand Down
1 change: 0 additions & 1 deletion graphs/basic_graphs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from collections import deque


if __name__ == "__main__":
# Accept No. of Nodes and edges
n, m = map(int, input().split(" "))
Expand Down
3 changes: 1 addition & 2 deletions graphs/breadth_first_search_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
mark w as explored
add w to Q (at the end)
"""

from typing import Set, Dict
from typing import Dict, Set

G = {
"A": ["B", "C"],
Expand Down
3 changes: 1 addition & 2 deletions graphs/depth_first_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
if v unexplored:
DFS(G, v)
"""

from typing import Set, Dict
from typing import Dict, Set


def depth_first_search(graph: Dict, start: str) -> Set[int]:
Expand Down
4 changes: 2 additions & 2 deletions graphs/directed_and_undirected_(weighted)_graph.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections import deque
import random as rand
import math as math
import random as rand
import time
from collections import deque

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

Expand Down
1 change: 1 addition & 0 deletions graphs/multi_heuristic_astar.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import heapq

import numpy as np


Expand Down
1 change: 1 addition & 0 deletions greedy_method/test_knapsack.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest

import greedy_knapsack as kp


Expand Down
Loading

0 comments on commit 5f4da5d

Please sign in to comment.