Skip to content

Create codespell.yml #1696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jan 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
- run: pip install codespell flake8
- run: codespell -L ans --skip="./.*,./other/dictionary.txt,./other/words,./project_euler/problem_22/p022_names.txt,*.jpg,*.png,*.jpeg,*.gif"
- 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
9 changes: 5 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 @@ -511,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 @@ -567,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
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/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
2 changes: 1 addition & 1 deletion dynamic_programming/bitmask.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def CountWaysUtil(self, mask, taskno):
if self.dp[mask][taskno] != -1:
return self.dp[mask][taskno]

# Number of ways when we dont this task in the arrangement
# Number of ways when we don't this task in the arrangement
total_ways_util = self.CountWaysUtil(mask, taskno + 1)

# now assign the tasks one by one to all possible persons and recursively assign for the remaining tasks.
Expand Down
4 changes: 2 additions & 2 deletions dynamic_programming/knapsack.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def knapsack_with_example_solution(W: int, wt: list, val: list):

W: int, the total maximum weight for the given knapsack problem.
wt: list, the vector of weights for all items where wt[i] is the weight
of the ith item.
of the i-th item.
val: list, the vector of values for all items where val[i] is the value
of te ith item
of the i-th item

Returns
-------
Expand Down
2 changes: 1 addition & 1 deletion dynamic_programming/longest_sub_array.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Auther : Yvonne
Author : Yvonne

This is a pure Python implementation of Dynamic Programming solution to the longest_sub_array problem.

Expand Down
23 changes: 10 additions & 13 deletions dynamic_programming/subset_generation.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# python program to print all subset combination of n element in given set of r element .
# Python program to print all subset combinations of n element in given set of r element.
# arr[] ---> Input Array
# data[] ---> Temporary array to store current combination
# start & end ---> Staring and Ending indexes in arr[]
# index ---> Current index in data[]
# r ---> Size of a combination to be printed
def combinationUtil(arr, n, r, index, data, i):
def combination_util(arr, n, r, index, data, i):
# Current combination is ready to be printed,
# print it
if index == r:
Expand All @@ -15,29 +15,26 @@ def combinationUtil(arr, n, r, index, data, i):
# When no more elements are there to put in data[]
if i >= n:
return
# current is included, put next at next
# location
# current is included, put next at next location
data[index] = arr[i]
combinationUtil(arr, n, r, index + 1, data, i + 1)
combination_util(arr, n, r, index + 1, data, i + 1)
# current is excluded, replace it with
# next (Note that i+1 is passed, but
# index is not changed)
combinationUtil(arr, n, r, index, data, i + 1)
combination_util(arr, n, r, index, data, i + 1)
# The main function that prints all combinations
# of size r in arr[] of size n. This function
# mainly uses combinationUtil()


def printcombination(arr, n, r):
# A temporary array to store all combination
# one by one
def print_combination(arr, n, r):
# A temporary array to store all combination one by one
data = [0] * r
# Print all combination using temprary
# array 'data[]'
combinationUtil(arr, n, r, 0, data, 0)
# Print all combination using temporary array 'data[]'
combination_util(arr, n, r, 0, data, 0)


# Driver function to check for above function
arr = [10, 20, 30, 40, 50]
printcombination(arr, len(arr), 3)
print_combination(arr, len(arr), 3)
# This code is contributed by Ambuj sahu
File renamed without changes.
Loading