Skip to content

Commit b7f13d9

Browse files
cclausspoyea
authored andcommitted
Travis CI: Run black, doctest, flake8, mypy, and pytest (TheAlgorithms#964)
* Travis CI: Add type checking with mypy * Create requirements.txt * script: mypy --ignore-missing-stubs=cv2,numpy . * Delete requirements.txt * script: mypy --ignore-missing-imports . * Run doctests * Disable doctest -v other/detecting_english_programmatically.py * Pytest * No | * pytest || true * Run black doctest flake8 mypy pytest * after_success: Build Directory.md * Typo in filename: Dictionary.txt --> dictionary.txt' Discovered via doctest run in TheAlgorithms#964 * python -m doctest -v * pip install black flake8 mypy pytest * pytest --doctest-glob='*.py' * pytest --doctest-modules * pytest --doctest-modules ./sorts * pytest --doctest-modules ./ciphers ./other ./searches ./sorts ./strings || true * if __name__ == "__main__": * if __name__ == "__main__": * if __name__ == '__main__': * if __name__ == '__main__': * if __name__ == '__main__': * Create requirements.txt * Update requirements.txt * if __name__ == "__main__": * Lose the doctests * if __name__ == '__main__': * Remove print-a-tuple * doctest: Added missing spaces * Update tabu_search.py * The >>> are not doctests so change to >>) * Travis CI: Run black, doctest, flake8, mypy, and pytest * Link to the separate DIRECTORY.md file * Update README.md
1 parent 2b36528 commit b7f13d9

11 files changed

+56
-365
lines changed

.travis.yml

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
language: python
22
dist: xenial # required for Python >= 3.7
33
python: 3.7
4-
install: pip install flake8
5-
script: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
4+
cache: pip
5+
install: pip install -r requirements.txt
6+
before_script:
7+
- black --check . || true
8+
- flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
9+
script:
10+
- mypy --ignore-missing-imports .
11+
- pytest --doctest-modules ./ciphers ./other ./searches ./sorts ./strings
12+
after_success:
13+
- python ./~script.py
14+
- cat DIRECTORY.md

README.md

+4-335
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ These implementations are for learning purposes. They may be less efficient than
1212

1313
Anup Kumar Panwar
1414
  [[Gmail](mailto:[email protected]?Subject=The%20Algorithms%20-%20Python)
15-
  [Gihub](https://github.com/anupkumarpanwar)
15+
  [GitHub](https://github.com/anupkumarpanwar)
1616
  [LinkedIn](https://www.linkedin.com/in/anupkumarpanwar/)]
1717

1818
Chetan Kaushik
1919
  [[Gmail](mailto:[email protected]?Subject=The%20Algorithms%20-%20Python)
20-
  [Gihub](https://github.com/dynamitechetan)
20+
  [GitHub](https://github.com/dynamitechetan)
2121
  [LinkedIn](https://www.linkedin.com/in/chetankaushik/)]
2222

2323
## Contribution Guidelines
@@ -28,337 +28,6 @@ Read our [Contribution Guidelines](CONTRIBUTING.md) before you contribute.
2828

2929
We're on [Gitter](https://gitter.im/TheAlgorithms)! Please join us.
3030

31-
# Algorithms
31+
## Algorithms
3232

33-
## Hashes
34-
35-
- [Md5](./hashes/md5.py)
36-
- [Chaos Machine](./hashes/chaos_machine.py)
37-
- [Sha1](./hashes/sha1.py)
38-
39-
## File Transfer Protocol
40-
41-
- [Ftp Client Server](./file_transfer_protocol/ftp_client_server.py)
42-
- [Ftp Send Receive](./file_transfer_protocol/ftp_send_receive.py)
43-
44-
## Backtracking
45-
46-
- [N Queens](./backtracking/n_queens.py)
47-
- [Sum Of Subsets](./backtracking/sum_of_subsets.py)
48-
- [All Subsequences](./backtracking/all_subsequences.py)
49-
- [All Permutations](./backtracking/all_permutations.py)
50-
51-
## Ciphers
52-
53-
- [Transposition Cipher](./ciphers/transposition_cipher.py)
54-
- [Atbash](./ciphers/Atbash.py)
55-
- [Rot13](./ciphers/rot13.py)
56-
- [Rabin Miller](./ciphers/rabin_miller.py)
57-
- [Transposition Cipher Encrypt Decrypt File](./ciphers/transposition_cipher_encrypt_decrypt_file.py)
58-
- [Affine Cipher](./ciphers/affine_cipher.py)
59-
- [Trafid Cipher](./ciphers/trafid_cipher.py)
60-
- [Base16](./ciphers/base16.py)
61-
- [Elgamal Key Generator](./ciphers/elgamal_key_generator.py)
62-
- [Rsa Cipher](./ciphers/rsa_cipher.py)
63-
- [Prehistoric Men.txt](./ciphers/prehistoric_men.txt)
64-
- [Vigenere Cipher](./ciphers/vigenere_cipher.py)
65-
- [Xor Cipher](./ciphers/xor_cipher.py)
66-
- [Brute Force Caesar Cipher](./ciphers/brute_force_caesar_cipher.py)
67-
- [Rsa Key Generator](./ciphers/rsa_key_generator.py)
68-
- [Simple Substitution Cipher](./ciphers/simple_substitution_cipher.py)
69-
- [Playfair Cipher](./ciphers/playfair_cipher.py)
70-
- [Morse Code Implementation](./ciphers/morse_Code_implementation.py)
71-
- [Base32](./ciphers/base32.py)
72-
- [Base85](./ciphers/base85.py)
73-
- [Base64 Cipher](./ciphers/base64_cipher.py)
74-
- [Onepad Cipher](./ciphers/onepad_cipher.py)
75-
- [Caesar Cipher](./ciphers/caesar_cipher.py)
76-
- [Hill Cipher](./ciphers/hill_cipher.py)
77-
- [Cryptomath Module](./ciphers/cryptomath_module.py)
78-
79-
## Arithmetic Analysis
80-
81-
- [Bisection](./arithmetic_analysis/bisection.py)
82-
- [Newton Method](./arithmetic_analysis/newton_method.py)
83-
- [Newton Raphson Method](./arithmetic_analysis/newton_raphson_method.py)
84-
- [Intersection](./arithmetic_analysis/intersection.py)
85-
- [Lu Decomposition](./arithmetic_analysis/lu_decomposition.py)
86-
87-
## Boolean Algebra
88-
89-
- [Quine Mc Cluskey](./boolean_algebra/quine_mc_cluskey.py)
90-
91-
## Traversals
92-
93-
- [Binary Tree Traversals](./traversals/binary_tree_traversals.py)
94-
95-
## Maths
96-
97-
- [Average](./maths/average.py)
98-
- [Abs Max](./maths/abs_Max.py)
99-
- [Average Median](./maths/average_median.py)
100-
- [Trapezoidal Rule](./maths/trapezoidal_rule.py)
101-
- [Prime Check](./maths/Prime_Check.py)
102-
- [Modular Exponential](./maths/modular_exponential.py)
103-
- [Newton Raphson](./maths/newton_raphson.py)
104-
- [Factorial Recursive](./maths/factorial_recursive.py)
105-
- [Extended Euclidean Algorithm](./maths/extended_euclidean_algorithm.py)
106-
- [Greater Common Divisor](./maths/greater_common_divisor.py)
107-
- [Fibonacci](./maths/fibonacci.py)
108-
- [Find Lcm](./maths/find_lcm.py)
109-
- [Find Max](./maths/Find_Max.py)
110-
- [Fermat Little Theorem](./maths/fermat_little_theorem.py)
111-
- [Factorial Python](./maths/factorial_python.py)
112-
- [Fibonacci Sequence Recursion](./maths/fibonacci_sequence_recursion.py)
113-
- [Sieve Of Eratosthenes](./maths/sieve_of_eratosthenes.py)
114-
- [Abs Min](./maths/abs_Min.py)
115-
- [Lucas Series](./maths/lucasSeries.py)
116-
- [Segmented Sieve](./maths/segmented_sieve.py)
117-
- [Find Min](./maths/Find_Min.py)
118-
- [Abs](./maths/abs.py)
119-
- [Simpson Rule](./maths/simpson_rule.py)
120-
- [Basic Maths](./maths/basic_maths.py)
121-
- [3n+1](./maths/3n+1.py)
122-
- [Binary Exponentiation](./maths/Binary_Exponentiation.py)
123-
124-
## Digital Image Processing
125-
126-
- ## Filters
127-
128-
- [Median Filter](./digital_image_processing/filters/median_filter.py)
129-
- [Gaussian Filter](./digital_image_processing/filters/gaussian_filter.py)
130-
131-
132-
## Compression
133-
134-
- [Peak Signal To Noise Ratio](./compression/peak_signal_to_noise_ratio.py)
135-
- [Huffman](./compression/huffman.py)
136-
137-
## Graphs
138-
139-
- [BFS Shortest Path](./graphs/bfs_shortest_path.py)
140-
- [Directed And Undirected (Weighted) Graph](<./graphs/Directed_and_Undirected_(Weighted)_Graph.py>)
141-
- [Minimum Spanning Tree Prims](./graphs/minimum_spanning_tree_prims.py)
142-
- [Graph Matrix](./graphs/graph_matrix.py)
143-
- [Basic Graphs](./graphs/basic_graphs.py)
144-
- [Dijkstra 2](./graphs/dijkstra_2.py)
145-
- [Tarjans Strongly Connected Components](./graphs/tarjans_scc.py)
146-
- [Check Bipartite Graph BFS](./graphs/check_bipartite_graph_bfs.py)
147-
- [Depth First Search](./graphs/depth_first_search.py)
148-
- [Kahns Algorithm Long](./graphs/kahns_algorithm_long.py)
149-
- [Breadth First Search](./graphs/breadth_first_search.py)
150-
- [Dijkstra](./graphs/dijkstra.py)
151-
- [Articulation Points](./graphs/articulation_points.py)
152-
- [Bellman Ford](./graphs/bellman_ford.py)
153-
- [Check Bipartite Graph Dfs](./graphs/check_bipartite_graph_dfs.py)
154-
- [Strongly Connected Components Kosaraju](./graphs/scc_kosaraju.py)
155-
- [Multi Hueristic Astar](./graphs/multi_hueristic_astar.py)
156-
- [Page Rank](./graphs/page_rank.py)
157-
- [Eulerian Path And Circuit For Undirected Graph](./graphs/Eulerian_path_and_circuit_for_undirected_graph.py)
158-
- [Edmonds Karp Multiple Source And Sink](./graphs/edmonds_karp_multiple_source_and_sink.py)
159-
- [Floyd Warshall](./graphs/floyd_warshall.py)
160-
- [Minimum Spanning Tree Kruskal](./graphs/minimum_spanning_tree_kruskal.py)
161-
- [Prim](./graphs/prim.py)
162-
- [Kahns Algorithm Topo](./graphs/kahns_algorithm_topo.py)
163-
- [BFS](./graphs/BFS.py)
164-
- [Finding Bridges](./graphs/finding_bridges.py)
165-
- [Graph List](./graphs/graph_list.py)
166-
- [Dijkstra Algorithm](./graphs/dijkstra_algorithm.py)
167-
- [A Star](./graphs/a_star.py)
168-
- [Even Tree](./graphs/even_tree.py)
169-
- [DFS](./graphs/DFS.py)
170-
171-
## Networking Flow
172-
173-
- [Minimum Cut](./networking_flow/minimum_cut.py)
174-
- [Ford Fulkerson](./networking_flow/ford_fulkerson.py)
175-
176-
## Matrix
177-
178-
- [Matrix Operation](./matrix/matrix_operation.py)
179-
- [Searching In Sorted Matrix](./matrix/searching_in_sorted_matrix.py)
180-
- [Spiral Print](./matrix/spiral_print.py)
181-
182-
## Searches
183-
184-
- [Quick Select](./searches/quick_select.py)
185-
- [Binary Search](./searches/binary_search.py)
186-
- [Interpolation Search](./searches/interpolation_search.py)
187-
- [Jump Search](./searches/jump_search.py)
188-
- [Linear Search](./searches/linear_search.py)
189-
- [Ternary Search](./searches/ternary_search.py)
190-
- [Tabu Search](./searches/tabu_search.py)
191-
- [Sentinel Linear Search](./searches/sentinel_linear_search.py)
192-
193-
## Conversions
194-
195-
- [Decimal To Binary](./conversions/decimal_to_binary.py)
196-
- [Decimal To Octal](./conversions/decimal_to_octal.py)
197-
198-
## Dynamic Programming
199-
200-
- [Fractional Knapsack](./dynamic_programming/Fractional_Knapsack.py)
201-
- [Sum Of Subset](./dynamic_programming/sum_of_subset.py)
202-
- [Fast Fibonacci](./dynamic_programming/fast_fibonacci.py)
203-
- [Bitmask](./dynamic_programming/bitmask.py)
204-
- [Abbreviation](./dynamic_programming/abbreviation.py)
205-
- [Rod Cutting](./dynamic_programming/rod_cutting.py)
206-
- [Knapsack](./dynamic_programming/knapsack.py)
207-
- [Max Sub Array](./dynamic_programming/max_sub_array.py)
208-
- [Fibonacci](./dynamic_programming/fibonacci.py)
209-
- [Minimum Partition](./dynamic_programming/minimum_partition.py)
210-
- [K Means Clustering Tensorflow](./dynamic_programming/k_means_clustering_tensorflow.py)
211-
- [Coin Change](./dynamic_programming/coin_change.py)
212-
- [Subset Generation](./dynamic_programming/subset_generation.py)
213-
- [Floyd Warshall](./dynamic_programming/floyd_warshall.py)
214-
- [Longest Sub Array](./dynamic_programming/longest_sub_array.py)
215-
- [Integer Partition](./dynamic_programming/integer_partition.py)
216-
- [Matrix Chain Order](./dynamic_programming/matrix_chain_order.py)
217-
- [Edit Distance](./dynamic_programming/edit_distance.py)
218-
- [Longest Common Subsequence](./dynamic_programming/longest_common_subsequence.py)
219-
- [Longest Increasing Subsequence O(nlogn)](<./dynamic_programming/longest_increasing_subsequence_O(nlogn).py>)
220-
- [Longest Increasing Subsequence](./dynamic_programming/longest_increasing_subsequence.py)
221-
222-
## Divide And Conquer
223-
224-
- [Max Subarray Sum](./divide_and_conquer/max_subarray_sum.py)
225-
- [Closest Pair Of Points](./divide_and_conquer/closest_pair_of_points.py)
226-
227-
## Strings
228-
229-
- [Knuth Morris Pratt](./strings/knuth_morris_pratt.py)
230-
- [Rabin Karp](./strings/rabin_karp.py)
231-
- [Naive String Search](./strings/naive_String_Search.py)
232-
- [Levenshtein Distance](./strings/levenshtein_distance.py)
233-
- [Min Cost String Conversion](./strings/min_cost_string_conversion.py)
234-
- [Boyer Moore Search](./strings/Boyer_Moore_Search.py)
235-
- [Manacher](./strings/manacher.py)
236-
237-
## Sorts
238-
239-
- [Quick Sort](./sorts/quick_sort.py)
240-
- [Selection Sort](./sorts/selection_sort.py)
241-
- [Bitonic Sort](./sorts/Bitonic_Sort.py)
242-
- [Cycle Sort](./sorts/cycle_sort.py)
243-
- [Comb Sort](./sorts/comb_sort.py)
244-
- [Topological Sort](./sorts/topological_sort.py)
245-
- [Merge Sort Fastest](./sorts/merge_sort_fastest.py)
246-
- [Random Pivot Quick Sort](./sorts/random_pivot_quick_sort.py)
247-
- [Heap Sort](./sorts/heap_sort.py)
248-
- [Insertion Sort](./sorts/insertion_sort.py)
249-
- [Counting Sort](./sorts/counting_sort.py)
250-
- [Bucket Sort](./sorts/bucket_sort.py)
251-
- [Quick Sort 3 Partition](./sorts/quick_sort_3_partition.py)
252-
- [Bogo Sort](./sorts/bogo_sort.py)
253-
- [Shell Sort](./sorts/shell_sort.py)
254-
- [Pigeon Sort](./sorts/pigeon_sort.py)
255-
- [Odd-Even Transposition Parallel](./sorts/Odd-Even_transposition_parallel.py)
256-
- [Tree Sort](./sorts/tree_sort.py)
257-
- [Cocktail Shaker Sort](./sorts/cocktail_shaker_sort.py)
258-
- [Random Normal Distribution Quicksort](./sorts/random_normal_distribution_quicksort.py)
259-
- [Wiggle Sort](./sorts/wiggle_sort.py)
260-
- [Pancake Sort](./sorts/pancake_sort.py)
261-
- [External Sort](./sorts/external_sort.py)
262-
- [Tim Sort](./sorts/tim_sort.py)
263-
- [Sorting Graphs.png](./sorts/sorting_graphs.png)
264-
- [Radix Sort](./sorts/radix_sort.py)
265-
- [Odd-Even Transposition Single-threaded](./sorts/Odd-Even_transposition_single-threaded.py)
266-
- [Bubble Sort](./sorts/bubble_sort.py)
267-
- [Gnome Sort](./sorts/gnome_sort.py)
268-
- [Merge Sort](./sorts/merge_sort.py)
269-
270-
## Machine Learning
271-
272-
- [Perceptron](./machine_learning/perceptron.py)
273-
- [Random Forest Classifier](./machine_learning/random_forest_classification/random_forest_classifier.ipynb)
274-
- [NaiveBayes.ipynb](./machine_learning/NaiveBayes.ipynb)
275-
- [Scoring Functions](./machine_learning/scoring_functions.py)
276-
- [Logistic Regression](./machine_learning/logistic_regression.py)
277-
- [Gradient Descent](./machine_learning/gradient_descent.py)
278-
- [Linear Regression](./machine_learning/linear_regression.py)
279-
- [Random Forest Regression](./machine_learning/random_forest_regression/random_forest_regression.py)
280-
- [Random Forest Regression](./machine_learning/random_forest_regression/random_forest_regression.ipynb)
281-
- [Reuters One Vs Rest Classifier.ipynb](./machine_learning/reuters_one_vs_rest_classifier.ipynb)
282-
- [Decision Tree](./machine_learning/decision_tree.py)
283-
- [Knn Sklearn](./machine_learning/knn_sklearn.py)
284-
- [K Means Clust](./machine_learning/k_means_clust.py)
285-
286-
## Neural Network
287-
288-
- [Perceptron](./neural_network/perceptron.py)
289-
- [Fully Connected Neural Network](./neural_network/fully_connected_neural_network.ipynb)
290-
- [Convolution Neural Network](./neural_network/convolution_neural_network.py)
291-
- [Back Propagation Neural Network](./neural_network/back_propagation_neural_network.py)
292-
293-
## Data Structures
294-
295-
- ## Binary Tree
296-
297-
- [Basic Binary Tree](./data_structures/binary_tree/basic_binary_tree.py)
298-
- [Red Black Tree](./data_structures/binary_tree/red_black_tree.py)
299-
- [Fenwick Tree](./data_structures/binary_tree/fenwick_tree.py)
300-
- [Treap](./data_structures/binary_tree/treap.py)
301-
- [AVL Tree](./data_structures/binary_tree/AVL_tree.py)
302-
- [Segment Tree](./data_structures/binary_tree/segment_tree.py)
303-
- [Lazy Segment Tree](./data_structures/binary_tree/lazy_segment_tree.py)
304-
- [Binary Search Tree](./data_structures/binary_tree/binary_search_tree.py)
305-
306-
- ## Trie
307-
308-
- [Trie](./data_structures/trie/trie.py)
309-
310-
- ## Linked List
311-
312-
- [Swap Nodes](./data_structures/linked_list/swap_nodes.py)
313-
- [Doubly Linked List](./data_structures/linked_list/doubly_linked_list.py)
314-
- [Singly Linked List](./data_structures/linked_list/singly_linked_list.py)
315-
- [Is Palindrome](./data_structures/linked_list/is_Palindrome.py)
316-
317-
- ## Stacks
318-
319-
- [Postfix Evaluation](./data_structures/stacks/postfix_evaluation.py)
320-
- [Balanced Parentheses](./data_structures/stacks/balanced_parentheses.py)
321-
- [Infix To Prefix Conversion](./data_structures/stacks/infix_to_prefix_conversion.py)
322-
- [Stack](./data_structures/stacks/stack.py)
323-
- [Infix To Postfix Conversion](./data_structures/stacks/infix_to_postfix_conversion.py)
324-
- [Next Greater Element](./data_structures/stacks/next_greater_element.py)
325-
- [Stock Span Problem](./data_structures/stacks/stock_span_problem.py)
326-
327-
- ## Queue
328-
329-
- [Queue On Pseudo Stack](./data_structures/queue/queue_on_pseudo_stack.py)
330-
- [Double Ended Queue](./data_structures/queue/double_ended_queue.py)
331-
- [Queue On List](./data_structures/queue/queue_on_list.py)
332-
333-
- ## Heap
334-
335-
- [Heap](./data_structures/heap/heap.py)
336-
337-
- ## Hashing
338-
339-
- [Hash Table With Linked List](./data_structures/hashing/hash_table_with_linked_list.py)
340-
- [Quadratic Probing](./data_structures/hashing/quadratic_probing.py)
341-
- [Hash Table](./data_structures/hashing/hash_table.py)
342-
- [Double Hash](./data_structures/hashing/double_hash.py)
343-
344-
345-
## Other
346-
347-
- [Detecting English Programmatically](./other/detecting_english_programmatically.py)
348-
- [Fischer Yates Shuffle](./other/fischer_yates_shuffle.py)
349-
- [Primelib](./other/primelib.py)
350-
- [Binary Exponentiation 2](./other/binary_exponentiation_2.py)
351-
- [Anagrams](./other/anagrams.py)
352-
- [Palindrome](./other/palindrome.py)
353-
- [Finding Primes](./other/finding_Primes.py)
354-
- [Two Sum](./other/two_sum.py)
355-
- [Password Generator](./other/password_generator.py)
356-
- [Linear Congruential Generator](./other/linear_congruential_generator.py)
357-
- [Frequency Finder](./other/frequency_finder.py)
358-
- [Euclidean Gcd](./other/euclidean_gcd.py)
359-
- [Word Patterns](./other/word_patterns.py)
360-
- [Nested Brackets](./other/nested_brackets.py)
361-
- [Binary Exponentiation](./other/binary_exponentiation.py)
362-
- [Sierpinski Triangle](./other/sierpinski_triangle.py)
363-
- [Game Of Life](./other/game_of_life.py)
364-
- [Tower Of Hanoi](./other/tower_of_hanoi.py)
33+
See our [directory](DIRECTORY.md).

ciphers/Atbash.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ def Atbash():
1818
output+=i
1919
print(output)
2020

21-
Atbash()
21+
22+
if __name__ == '__main__':
23+
Atbash()

ciphers/caesar_cipher.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,7 @@ def main():
5959
elif choice == '4':
6060
print ("Goodbye.")
6161
break
62-
main()
62+
63+
64+
if __name__ == '__main__':
65+
main()

other/detecting_english_programmatically.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
def loadDictionary():
77
path = os.path.split(os.path.realpath(__file__))
88
englishWords = {}
9-
with open(path[0] + '/Dictionary.txt') as dictionaryFile:
9+
with open(path[0] + '/dictionary.txt') as dictionaryFile:
1010
for word in dictionaryFile.read().split('\n'):
1111
englishWords[word] = None
1212
return englishWords

0 commit comments

Comments
 (0)