Skip to content

Commit

Permalink
Create codespell.yml (TheAlgorithms#1698)
Browse files Browse the repository at this point in the history
* fixup! Format Python code with psf/black push

* Create codespell.yml

* fixup! Format Python code with psf/black push
  • Loading branch information
cclauss authored Jan 18, 2020
1 parent c01d178 commit bfcb95b
Show file tree
Hide file tree
Showing 78 changed files with 206 additions and 188 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# GitHub Action to automate the identification of common misspellings in text files
# https://github.com/codespell-project/codespell
name: codespell
on: [push, pull_request]
jobs:
codespell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
- run: pip install codespell flake8
- run: |
SKIP="./.*,./other/dictionary.txt,./other/words,./project_euler/problem_22/p022_names.txt,*.bak,*.gif,*.jpeg,*.jpg,*.json,*.png,*.pyc"
codespell -L ans,fo,hist,iff,secant,tim --skip=$SKIP
12 changes: 8 additions & 4 deletions DIRECTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,14 @@
* [Longest Sub Array](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/longest_sub_array.py)
* [Matrix Chain Order](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/matrix_chain_order.py)
* [Max Sub Array](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/max_sub_array.py)
* [Max Sum Contigous Subsequence](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/max_sum_contigous_subsequence.py)
* [Max Sum Contiguous Subsequence](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/max_sum_contiguous_subsequence.py)
* [Minimum Partition](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/minimum_partition.py)
* [Rod Cutting](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/rod_cutting.py)
* [Subset Generation](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/subset_generation.py)
* [Sum Of Subset](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/sum_of_subset.py)

## File Transfer
* [Recieve File](https://github.com/TheAlgorithms/Python/blob/master/file_transfer/recieve_file.py)
* [Receive File](https://github.com/TheAlgorithms/Python/blob/master/file_transfer/receive_file.py)
* [Send File](https://github.com/TheAlgorithms/Python/blob/master/file_transfer/send_file.py)

## Fuzzy Logic
Expand Down Expand Up @@ -219,7 +219,7 @@
* [Kahns Algorithm Topo](https://github.com/TheAlgorithms/Python/blob/master/graphs/kahns_algorithm_topo.py)
* [Minimum Spanning Tree Kruskal](https://github.com/TheAlgorithms/Python/blob/master/graphs/minimum_spanning_tree_kruskal.py)
* [Minimum Spanning Tree Prims](https://github.com/TheAlgorithms/Python/blob/master/graphs/minimum_spanning_tree_prims.py)
* [Multi Hueristic Astar](https://github.com/TheAlgorithms/Python/blob/master/graphs/multi_hueristic_astar.py)
* [Multi Heuristic Astar](https://github.com/TheAlgorithms/Python/blob/master/graphs/multi_heuristic_astar.py)
* [Page Rank](https://github.com/TheAlgorithms/Python/blob/master/graphs/page_rank.py)
* [Prim](https://github.com/TheAlgorithms/Python/blob/master/graphs/prim.py)
* [Scc Kosaraju](https://github.com/TheAlgorithms/Python/blob/master/graphs/scc_kosaraju.py)
Expand Down Expand Up @@ -319,6 +319,7 @@
* [Sieve Of Eratosthenes](https://github.com/TheAlgorithms/Python/blob/master/maths/sieve_of_eratosthenes.py)
* [Simpson Rule](https://github.com/TheAlgorithms/Python/blob/master/maths/simpson_rule.py)
* [Softmax](https://github.com/TheAlgorithms/Python/blob/master/maths/softmax.py)
* [Square Root](https://github.com/TheAlgorithms/Python/blob/master/maths/square_root.py)
* [Sum Of Arithmetic Series](https://github.com/TheAlgorithms/Python/blob/master/maths/sum_of_arithmetic_series.py)
* [Test Prime Check](https://github.com/TheAlgorithms/Python/blob/master/maths/test_prime_check.py)
* [Trapezoidal Rule](https://github.com/TheAlgorithms/Python/blob/master/maths/trapezoidal_rule.py)
Expand Down Expand Up @@ -469,6 +470,8 @@
* [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_28/sol1.py)
* Problem 29
* [Solution](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_29/solution.py)
* Problem 30
* [Soln](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_30/soln.py)
* Problem 31
* [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_31/sol1.py)
* Problem 32
Expand Down Expand Up @@ -508,6 +511,7 @@
* [Quick Select](https://github.com/TheAlgorithms/Python/blob/master/searches/quick_select.py)
* [Sentinel Linear Search](https://github.com/TheAlgorithms/Python/blob/master/searches/sentinel_linear_search.py)
* [Simple-Binary-Search](https://github.com/TheAlgorithms/Python/blob/master/searches/simple-binary-search.py)
* [Simulated Annealing](https://github.com/TheAlgorithms/Python/blob/master/searches/simulated_annealing.py)
* [Tabu Search](https://github.com/TheAlgorithms/Python/blob/master/searches/tabu_search.py)
* [Ternary Search](https://github.com/TheAlgorithms/Python/blob/master/searches/ternary_search.py)

Expand Down Expand Up @@ -564,7 +568,7 @@
* [Reverse Words](https://github.com/TheAlgorithms/Python/blob/master/strings/reverse_words.py)
* [Split](https://github.com/TheAlgorithms/Python/blob/master/strings/split.py)
* [Upper](https://github.com/TheAlgorithms/Python/blob/master/strings/upper.py)
* [Word Occurence](https://github.com/TheAlgorithms/Python/blob/master/strings/word_occurence.py)
* [Word Occurrence](https://github.com/TheAlgorithms/Python/blob/master/strings/word_occurrence.py)

## Traversals
* [Binary Tree Traversals](https://github.com/TheAlgorithms/Python/blob/master/traversals/binary_tree_traversals.py)
Expand Down
8 changes: 4 additions & 4 deletions backtracking/n_queens.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def isSafe(board, row, column):

def solve(board, row):
"""
It creates a state space tree and calls the safe function untill it receives a
False Boolean and terminates that brach and backtracks to the next
It creates a state space tree and calls the safe function until it receives a
False Boolean and terminates that branch and backtracks to the next
poosible solution branch.
"""
if row >= len(board):
Expand All @@ -58,7 +58,7 @@ def solve(board, row):
"""
For every row it iterates through each column to check if it is feesible to place a
queen there.
If all the combinations for that particaular branch are successfull the board is
If all the combinations for that particular branch are successful the board is
reinitialized for the next possible combination.
"""
if isSafe(board, row, i):
Expand All @@ -70,7 +70,7 @@ def solve(board, row):

def printboard(board):
"""
Prints the boards that have a successfull combination.
Prints the boards that have a successful combination.
"""
for i in range(len(board)):
for j in range(len(board)):
Expand Down
6 changes: 3 additions & 3 deletions ciphers/hill_cipher.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
Hill Cipher:
The below defined class 'HillCipher' implements the Hill Cipher algorithm.
The Hill Cipher is an algorithm that implements modern linear algebra techniques
In this algortihm, you have an encryption key matrix. This is what will be used
In this algorithm, you have an encryption key matrix. This is what will be used
in encoding and decoding your text.
Algortihm:
Algorithm:
Let the order of the encryption key be N (as it is a square matrix).
Your text is divided into batches of length N and converted to numerical vectors
by a simple mapping starting with A=0 and so on.
The key is then mulitplied with the newly created batch vector to obtain the
The key is then multiplied with the newly created batch vector to obtain the
encoded vector. After each multiplication modular 36 calculations are performed
on the vectors so as to bring the numbers between 0 and 36 and then mapped with
their corresponding alphanumerics.
Expand Down
2 changes: 1 addition & 1 deletion ciphers/rsa_cipher.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def main():
filename = "encrypted_file.txt"
response = input(r"Encrypte\Decrypt [e\d]: ")
response = input(r"Encrypt\Decrypt [e\d]: ")

if response.lower().startswith("e"):
mode = "encrypt"
Expand Down
8 changes: 4 additions & 4 deletions ciphers/rsa_key_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ def makeKeyFiles(name, keySize):

publicKey, privateKey = generateKey(keySize)
print("\nWriting public key to file %s_pubkey.txt..." % name)
with open("%s_pubkey.txt" % name, "w") as fo:
fo.write("{},{},{}".format(keySize, publicKey[0], publicKey[1]))
with open("%s_pubkey.txt" % name, "w") as out_file:
out_file.write("{},{},{}".format(keySize, publicKey[0], publicKey[1]))

print("Writing private key to file %s_privkey.txt..." % name)
with open("%s_privkey.txt" % name, "w") as fo:
fo.write("{},{},{}".format(keySize, privateKey[0], privateKey[1]))
with open("%s_privkey.txt" % name, "w") as out_file:
out_file.write("{},{},{}".format(keySize, privateKey[0], privateKey[1]))


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions compression/burrows_wheeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ def reverse_bwt(bwt_string: str, idx_original_string: int) -> str:
entry_msg = "Provide a string that I will generate its BWT transform: "
s = input(entry_msg).strip()
result = bwt_transform(s)
bwt_output_msg = "Burrows Wheeler tranform for string '{}' results in '{}'"
bwt_output_msg = "Burrows Wheeler transform for string '{}' results in '{}'"
print(bwt_output_msg.format(s, result["bwt_string"]))
original_string = reverse_bwt(result["bwt_string"], result["idx_original_string"])
fmt = (
"Reversing Burrows Wheeler tranform for entry '{}' we get original"
"Reversing Burrows Wheeler transform for entry '{}' we get original"
" string '{}'"
)
print(fmt.format(result["bwt_string"], original_string))
2 changes: 1 addition & 1 deletion compression/huffman.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, freq, left, right):
def parse_file(file_path):
"""
Read the file and build a dict of all letters and their
frequences, then convert the dict into a list of Letters.
frequencies, then convert the dict into a list of Letters.
"""
chars = {}
with open(file_path) as f:
Expand Down
2 changes: 1 addition & 1 deletion compression/peak_signal_to_noise_ratio.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Peak signal-to-noise ratio - PSNR - https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio
Soruce: https://tutorials.techonical.com/how-to-calculate-psnr-value-of-two-images-using-python/
Source: https://tutorials.techonical.com/how-to-calculate-psnr-value-of-two-images-using-python/
"""

import math
Expand Down
2 changes: 1 addition & 1 deletion conversions/decimal_to_octal.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def decimal_to_octal(num: int) -> str:


def main():
"""Print octal equivelents of decimal numbers."""
"""Print octal equivalents of decimal numbers."""
print("\n2 in octal is:")
print(decimal_to_octal(2)) # = 2
print("\n8 in octal is:")
Expand Down
2 changes: 1 addition & 1 deletion data_structures/binary_tree/binary_search_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __repr__(self):

if self.left is None and self.right is None:
return str(self.value)
return pformat({"%s" % (self.value): (self.left, self.right)}, indent=1,)
return pformat({"%s" % (self.value): (self.left, self.right)}, indent=1)


class BinarySearchTree:
Expand Down
2 changes: 1 addition & 1 deletion data_structures/binary_tree/lowest_common_ancestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def swap(a, b):
return a, b


# creating sparse table which saves each nodes 2^ith parent
# creating sparse table which saves each nodes 2^i-th parent
def creatSparse(max_node, parent):
j = 1
while (1 << j) < max_node:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def binomial_coefficient(n: int, k: int) -> int:

def catalan_number(node_count: int) -> int:
"""
We can find Catalan number many ways but here we use Binomial Coefficent because it
We can find Catalan number many ways but here we use Binomial Coefficient because it
does the job in O(n)
return the Catalan number of n using 2nCn/(n+1).
Expand Down
6 changes: 3 additions & 3 deletions data_structures/binary_tree/red_black_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class RedBlackTree:
less strict, so it will perform faster for writing/deleting nodes
and slower for reading in the average case, though, because they're
both balanced binary search trees, both will get the same asymptotic
perfomance.
performance.
To read more about them, https://en.wikipedia.org/wiki/Red–black_tree
Unless otherwise specified, all asymptotic runtimes are specified in
terms of the size of the tree.
Expand All @@ -37,7 +37,7 @@ def __init__(self, label=None, color=0, parent=None, left=None, right=None):
def rotate_left(self):
"""Rotate the subtree rooted at this node to the left and
returns the new root to this subtree.
Perfoming one rotation can be done in O(1).
Performing one rotation can be done in O(1).
"""
parent = self.parent
right = self.right
Expand Down Expand Up @@ -656,7 +656,7 @@ def test_tree_traversal():


def test_tree_chaining():
"""Tests the three different tree chaning functions."""
"""Tests the three different tree chaining functions."""
tree = RedBlackTree(0)
tree = tree.insert(-16).insert(16).insert(8).insert(24).insert(20).insert(22)
if list(tree.inorder_traverse()) != [-16, 0, 8, 16, 20, 22, 24]:
Expand Down
4 changes: 2 additions & 2 deletions data_structures/binary_tree/treap.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __repr__(self):
return f"'{self.value}: {self.prior:.5}'"
else:
return pformat(
{f"{self.value}: {self.prior:.5}": (self.left, self.right)}, indent=1,
{f"{self.value}: {self.prior:.5}": (self.left, self.right)}, indent=1
)

def __str__(self):
Expand Down Expand Up @@ -161,7 +161,7 @@ def main():
"""After each command, program prints treap"""
root = None
print(
"enter numbers to creat a tree, + value to add value into treap, - value to erase all nodes with value. 'q' to quit. "
"enter numbers to create a tree, + value to add value into treap, - value to erase all nodes with value. 'q' to quit. "
)

args = input()
Expand Down
2 changes: 1 addition & 1 deletion data_structures/heap/binomial_heap.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class BinomialHeap:
r"""
Min-oriented priority queue implemented with the Binomial Heap data
structure implemented with the BinomialHeap class. It supports:
- Insert element in a heap with n elemnts: Guaranteed logn, amoratized 1
- Insert element in a heap with n elements: Guaranteed logn, amoratized 1
- Merge (meld) heaps of size m and n: O(logn + logm)
- Delete Min: O(logn)
- Peek (return min without deleting it): O(1)
Expand Down
17 changes: 9 additions & 8 deletions data_structures/heap/heap.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Heap(object):
[1, 5, 7, 9, 11, 15, 25, 100, 103, 107, 201]
>>>
"""

def __init__(self):
self.h = []
self.curr_size = 0
Expand Down Expand Up @@ -107,28 +108,28 @@ def main():
[2, 5, 3, 0, 2, 3, 0, 3],
[6, 1, 2, 7, 9, 3, 4, 5, 10, 8],
[103, 9, 1, 7, 11, 15, 25, 201, 209, 107, 5],
[-45, -2, -5]
[-45, -2, -5],
]:
print('source unsorted list: %s' % unsorted)
print("source unsorted list: %s" % unsorted)

h = Heap()
h.build_heap(unsorted)
print('after build heap: ', end=' ')
print("after build heap: ", end=" ")
h.display()

print('max value: %s' % h.get_max())
print('delete max value: ', end=' ')
print("max value: %s" % h.get_max())
print("delete max value: ", end=" ")
h.display()

h.insert(100)
print('after insert new value 100: ', end=' ')
print("after insert new value 100: ", end=" ")
h.display()

h.heap_sort()
print('heap sort: ', end=' ')
print("heap sort: ", end=" ")
h.display()
print()


if __name__ == '__main__':
if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion data_structures/linked_list/deque_doubly.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Operations:
1. insertion in the front -> O(1)
2. insertion in the end -> O(1)
3. remove fron the front -> O(1)
3. remove from the front -> O(1)
4. remove from the end -> O(1)
"""

Expand Down
2 changes: 1 addition & 1 deletion data_structures/linked_list/doubly_linked_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- This is an example of a double ended, doubly linked list.
- Each link references the next link and the previous one.
- A Doubly Linked List (DLL) contains an extra pointer, typically called previous pointer, together with next pointer and data which are there in singly linked list.
- Advantages over SLL - IT can be traversed in both forward and backward direction.,Delete operation is more efficent"""
- Advantages over SLL - IT can be traversed in both forward and backward direction.,Delete operation is more efficient"""


class LinkedList: # making main class named linked list
Expand Down
2 changes: 1 addition & 1 deletion data_structures/linked_list/singly_linked_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __repr__(self): # String representation/visualization of a Linked Lists
# END represents end of the LinkedList
return string_repr + "END"

# Indexing Support. Used to get a node at particaular position
# Indexing Support. Used to get a node at particular position
def __getitem__(self, index):
current = self.head

Expand Down
2 changes: 1 addition & 1 deletion data_structures/linked_list/swap_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self):
def print_list(self):
temp = self.head
while temp is not None:
print(temp.data, end=' ')
print(temp.data, end=" ")
temp = temp.next
print()

Expand Down
2 changes: 1 addition & 1 deletion data_structures/stacks/postfix_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def Solve(Postfix):

Stack.append(
str(Opr[x](int(A), int(B)))
) # evaluate the 2 values poped from stack & push result to stack
) # evaluate the 2 values popped from stack & push result to stack
print(
x.rjust(8),
("push(" + A + x + B + ")").ljust(12),
Expand Down
2 changes: 1 addition & 1 deletion data_structures/stacks/stock_span_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def calculateSpan(price, S):
# Calculate span values for rest of the elements
for i in range(1, n):

# Pop elements from stack whlie stack is not
# Pop elements from stack while stack is not
# empty and top of stack is smaller than price[i]
while len(st) > 0 and price[st[0]] <= price[i]:
st.pop()
Expand Down
6 changes: 3 additions & 3 deletions digital_image_processing/index_calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ def NDRE(self):
# instantiating the class with the values
#cl = indexCalculation(red=red, green=green, blue=blue, redEdge=redEdge, nir=nir)
# how set the values after instantiate the class cl, (for update the data or when dont
# how set the values after instantiate the class cl, (for update the data or when don't
# instantiating the class with the values)
cl.setMatrices(red=red, green=green, blue=blue, redEdge=redEdge, nir=nir)
Expand All @@ -551,8 +551,8 @@ def NDRE(self):
redEdge=redEdge, nir=nir).astype(np.float64)
indexValue_form2 = cl.CCCI()
# calculating the index with the values directly -- you can set just the values preferred --
# note: the *calculation* fuction performs the function *setMatrices*
# calculating the index with the values directly -- you can set just the values
# preferred note: the *calculation* function performs the function *setMatrices*
indexValue_form3 = cl.calculation("CCCI", red=red, green=green, blue=blue,
redEdge=redEdge, nir=nir).astype(np.float64)
Expand Down
2 changes: 1 addition & 1 deletion digital_image_processing/test_digital_image_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_gen_gaussian_kernel():
# canny.py
def test_canny():
canny_img = imread("digital_image_processing/image_data/lena_small.jpg", 0)
# assert ambiguos array for all == True
# assert ambiguous array for all == True
assert canny_img.all()
canny_array = canny.canny(canny_img)
# assert canny array for at least one True
Expand Down
Loading

0 comments on commit bfcb95b

Please sign in to comment.