The Wayback Machine - https://web.archive.org/web/20200831053816/https://github.com/TheAlgorithms/Python/commit/5f4da5d616926dbe77ece828986b8d19c7d65cb5
Skip to content
Permalink
Browse files

isort --profile black . (#2181)

* 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 committed Jul 6, 2020
1 parent cd3e8f9 commit 5f4da5d616926dbe77ece828986b8d19c7d65cb5
Showing with 123 additions and 127 deletions.
  1. +1 −1 .github/workflows/autoblack.yml
  2. +2 −0 DIRECTORY.md
  3. +2 −1 arithmetic_analysis/in_static_equilibrium.py
  4. +1 −1 arithmetic_analysis/newton_raphson.py
  5. +1 −1 ciphers/hill_cipher.py
  6. +1 −1 ciphers/playfair_cipher.py
  7. +1 −1 compression/burrows_wheeler.py
  8. +1 −1 computer_vision/harriscorner.py
  9. +1 −1 data_structures/binary_tree/non_recursive_segment_tree.py
  10. +1 −2 data_structures/binary_tree/segment_tree_other.py
  11. +1 −2 data_structures/hashing/double_hash.py
  12. +2 −1 data_structures/hashing/hash_table_with_linked_list.py
  13. +1 −2 digital_image_processing/convert_to_negative.py
  14. +1 −1 digital_image_processing/dithering/burkes.py
  15. +1 −0 digital_image_processing/edge_detection/canny.py
  16. +2 −2 digital_image_processing/filters/bilateral_filter.py
  17. +2 −2 digital_image_processing/filters/convolve.py
  18. +3 −2 digital_image_processing/filters/gaussian_filter.py
  19. +2 −3 digital_image_processing/filters/median_filter.py
  20. +2 −1 digital_image_processing/filters/sobel_filter.py
  21. +2 −3 digital_image_processing/histogram_equalization/histogram_stretch.py
  22. +1 −1 digital_image_processing/resize/resize.py
  23. +2 −2 digital_image_processing/rotation/rotation.py
  24. +1 −2 digital_image_processing/sepia.py
  25. +12 −12 digital_image_processing/test_digital_image_processing.py
  26. +1 −1 dynamic_programming/fractional_knapsack.py
  27. +2 −1 dynamic_programming/max_sub_array.py
  28. +0 −2 dynamic_programming/optimal_binary_search_tree.py
  29. +1 −2 fuzzy_logic/fuzzy_operations.py
  30. +1 −0 geodesy/lamberts_ellipsoidal_distance.py
  31. +2 −2 graphics/bezier_curve.py
  32. +0 −1 graphs/basic_graphs.py
  33. +1 −2 graphs/breadth_first_search_2.py
  34. +1 −2 graphs/depth_first_search.py
  35. +2 −2 graphs/directed_and_undirected_(weighted)_graph.py
  36. +1 −0 graphs/multi_heuristic_astar.py
  37. +1 −0 greedy_method/test_knapsack.py
  38. +1 −2 hashes/sha1.py
  39. +9 −2 linear_algebra/src/test_linear_algebra.py
  40. +3 −4 machine_learning/gaussian_naive_bayes.py
  41. +3 −2 machine_learning/k_means_clust.py
  42. +2 −1 machine_learning/k_nearest_neighbours.py
  43. +1 −1 machine_learning/knn_sklearn.py
  44. +1 −3 machine_learning/linear_discriminant_analysis.py
  45. +1 −1 machine_learning/linear_regression.py
  46. +2 −4 machine_learning/logistic_regression.py
  47. +2 −4 machine_learning/lstm/lstm_prediction.py
  48. +0 −1 machine_learning/multilayer_perceptron_classifier.py
  49. +1 −1 machine_learning/polymonial_regression.py
  50. +2 −3 machine_learning/random_forest_classifier.py
  51. +2 −4 machine_learning/random_forest_regressor.py
  52. +1 −1 machine_learning/sequential_minimum_optimization.py
  53. +1 −1 machine_learning/support_vector_machines.py
  54. +1 −1 maths/3n_plus_1.py
  55. +2 −2 maths/fibonacci.py
  56. +2 −1 maths/gamma.py
  57. +1 −1 maths/gaussian.py
  58. +1 −1 maths/line_length.py
  59. +1 −1 maths/mobius_function.py
  60. +1 −2 maths/newton_raphson.py
  61. +1 −1 maths/prime_numbers.py
  62. +1 −1 maths/relu.py
  63. +1 −1 maths/volume.py
  64. +1 −1 maths/zellers_congruence.py
  65. +3 −1 matrix/tests/test_matrix_operation.py
  66. +1 −2 neural_network/back_propagation_neural_network.py
  67. +2 −1 neural_network/convolution_neural_network.py
  68. +1 −1 other/least_recently_used.py
  69. +1 −1 other/sierpinski_triangle.py
  70. +1 −1 project_euler/problem_07/sol3.py
  71. +0 −1 project_euler/problem_42/solution42.py
  72. +1 −1 scheduling/shortest_job_first.py
  73. +1 −1 scripts/validate_filenames.py
  74. +1 −1 searches/hill_climbing.py
  75. +1 −1 searches/simulated_annealing.py
  76. +1 −2 searches/tabu_search.py
  77. +1 −1 sorts/external_sort.py
  78. +1 −0 sorts/random_normal_distribution_quicksort.py
  79. +1 −2 web_programming/crawl_google_results.py
  80. +1 −1 web_programming/get_imdbtop.py
@@ -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
@@ -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)
@@ -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)
@@ -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
@@ -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


@@ -35,8 +35,8 @@
https://www.youtube.com/watch?v=4RhLNDqcjpA
"""

import string

import numpy


@@ -1,5 +1,5 @@
import string
import itertools
import string


def chunker(seq, size):
@@ -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]:
@@ -1,5 +1,5 @@
import numpy as np
import cv2
import numpy as np

"""
Harris Corner Detector
@@ -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")

@@ -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):
@@ -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):
@@ -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):
@@ -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):
@@ -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:
@@ -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

@@ -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:
@@ -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):
@@ -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
@@ -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):
@@ -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


@@ -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:
@@ -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:
@@ -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(
@@ -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):
@@ -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)

@@ -1,5 +1,5 @@
from itertools import accumulate
from bisect import bisect
from itertools import accumulate


def fracKnapsack(vl, wt, W, n):
@@ -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:
@@ -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


@@ -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)
@@ -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()

@@ -1,4 +1,5 @@
from math import atan, cos, radians, sin, tan

from haversine_distance import haversine_distance


@@ -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


@@ -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
@@ -1,6 +1,5 @@
from collections import deque


if __name__ == "__main__":
# Accept No. of Nodes and edges
n, m = map(int, input().split(" "))
@@ -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"],
@@ -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]:
@@ -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

@@ -1,4 +1,5 @@
import heapq

import numpy as np


@@ -1,4 +1,5 @@
import unittest

import greedy_knapsack as kp


0 comments on commit 5f4da5d

Please sign in to comment.
You can’t perform that action at this time.