GeezerVison is showing github.com — Set the Python file maximum line length to 88 characters (#2122) · jusing-es/Python@9316e7c
File treeExpand file treeCollapse file tree Open diff view settings Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .travis.yml +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -10,7 +10,7 @@ notifications: | 10 | 10 | on_success: never | 11 | 11 | before_script: | 12 | 12 | - black --check . || true | 13 | | - - flake8 --ignore=E203,W503 --max-complexity=25 --max-line-length=120 --statistics --count . | | 13 | + - flake8 --ignore=E203,W503 --max-complexity=25 --max-line-length=88 --statistics --count . | 14 | 14 | - scripts/validate_filenames.py # no uppercase, no spaces, in a directory | 15 | 15 | - pip install -r requirements.txt # fast fail on black, flake8, validate_filenames | 16 | 16 | script: | |
Collapse file Copy file name to clipboardExpand all lines: arithmetic_analysis/intersection.py +5-3Lines changed: 5 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import math | 2 | 2 |
| 3 | 3 |
| 4 | | -def intersection( | 5 | | - function, x0, x1 | 6 | | -): # function is the f we want to find its root and x0 and x1 are two random starting points | | 4 | +def intersection(function, x0, x1): | | 5 | + """ | | 6 | + function is the f we want to find its root | | 7 | + x0 and x1 are two random starting points | | 8 | + """ | 7 | 9 | x_n = x0 | 8 | 10 | x_n1 = x1 | 9 | 11 | while True: | |
Collapse file Copy file name to clipboardExpand all lines: backtracking/hamiltonian_cycle.py +6-4Lines changed: 6 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -16,8 +16,8 @@ def valid_connection( | 16 | 16 | Checks whether it is possible to add next into path by validating 2 statements | 17 | 17 | 1. There should be path between current and next vertex | 18 | 18 | 2. Next vertex should not be in path | 19 | | - If both validations succeeds we return true saying that it is possible to connect this vertices | 20 | | - either we return false | | 19 | + If both validations succeeds we return True saying that it is possible to connect | | 20 | + this vertices either we return False | 21 | 21 |
| 22 | 22 | Case 1:Use exact graph as in main function, with initialized values | 23 | 23 | >>> graph = [[0, 1, 0, 1, 0], | @@ -52,7 +52,8 @@ def util_hamilton_cycle(graph: List[List[int]], path: List[int], curr_ind: int) | 52 | 52 | Pseudo-Code | 53 | 53 | Base Case: | 54 | 54 | 1. Chceck if we visited all of vertices | 55 | | - 1.1 If last visited vertex has path to starting vertex return True either return False | | 55 | + 1.1 If last visited vertex has path to starting vertex return True either | | 56 | + return False | 56 | 57 | Recursive Step: | 57 | 58 | 2. Iterate over each vertex | 58 | 59 | Check if next vertex is valid for transiting from current vertex | @@ -74,7 +75,8 @@ def util_hamilton_cycle(graph: List[List[int]], path: List[int], curr_ind: int) | 74 | 75 | >>> print(path) | 75 | 76 | [0, 1, 2, 4, 3, 0] | 76 | 77 |
| 77 | | - Case 2: Use exact graph as in previous case, but in the properties taken from middle of calculation | | 78 | + Case 2: Use exact graph as in previous case, but in the properties taken from | | 79 | + middle of calculation | 78 | 80 | >>> graph = [[0, 1, 0, 1, 0], | 79 | 81 | ... [1, 0, 1, 1, 1], | 80 | 82 | ... [0, 1, 0, 0, 1], | |
Collapse file Copy file name to clipboardExpand all lines: backtracking/n_queens.py +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 12 | 12 |
| 13 | 13 | def isSafe(board, row, column): | 14 | 14 | """ | 15 | | - This function returns a boolean value True if it is safe to place a queen there considering | 16 | | - the current state of the board. | | 15 | + This function returns a boolean value True if it is safe to place a queen there | | 16 | + considering the current state of the board. | 17 | 17 |
| 18 | 18 | Parameters : | 19 | 19 | board(2D matrix) : board | @@ -56,8 +56,8 @@ def solve(board, row): | 56 | 56 | return | 57 | 57 | for i in range(len(board)): | 58 | 58 | """ | 59 | | - For every row it iterates through each column to check if it is feasible to place a | 60 | | - queen there. | | 59 | + For every row it iterates through each column to check if it is feasible to | | 60 | + place a queen there. | 61 | 61 | If all the combinations for that particular branch are successful the board is | 62 | 62 | reinitialized for the next possible combination. | 63 | 63 | """ | |
Collapse file Copy file name to clipboardExpand all lines: backtracking/sum_of_subsets.py +7-5Lines changed: 7 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | """ | 2 | | - The sum-of-subsetsproblem states that a set of non-negative integers, and a value M, | 3 | | - determine all possible subsets of the given set whose summation sum equal to given M. | | 2 | + The sum-of-subsetsproblem states that a set of non-negative integers, and a | | 3 | + value M, determine all possible subsets of the given set whose summation sum | | 4 | + equal to given M. | 4 | 5 |
| 5 | | - Summation of the chosen numbers must be equal to given number M and one number can | 6 | | - be used only once. | | 6 | + Summation of the chosen numbers must be equal to given number M and one number | | 7 | + can be used only once. | 7 | 8 | """ | 8 | 9 |
| 9 | 10 |
| @@ -21,7 +22,8 @@ def create_state_space_tree(nums, max_sum, num_index, path, result, remaining_nu | 21 | 22 | Creates a state space tree to iterate through each branch using DFS. | 22 | 23 | It terminates the branching of a node when any of the two conditions | 23 | 24 | given below satisfy. | 24 | | - This algorithm follows depth-fist-search and backtracks when the node is not branchable. | | 25 | + This algorithm follows depth-fist-search and backtracks when the node is not | | 26 | + branchable. | 25 | 27 |
| 26 | 28 | """ | 27 | 29 | if sum(path) > max_sum or (remaining_nums_sum + sum(path)) < max_sum: | |
Collapse file Copy file name to clipboardExpand all lines: blockchain/chinese_remainder_theorem.py +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | # Chinese Remainder Theorem: | 2 | 2 | # GCD ( Greatest Common Divisor ) or HCF ( Highest Common Factor ) | 3 | 3 |
| 4 | | -# If GCD(a,b) = 1, then for any remainder ra modulo a and any remainder rb modulo b there exists integer n, | 5 | | -# such that n = ra (mod a) and n = ra(mod b). If n1 and n2 are two such integers, then n1=n2(mod ab) | | 4 | +# If GCD(a,b) = 1, then for any remainder ra modulo a and any remainder rb modulo b | | 5 | +# there exists integer n, such that n = ra (mod a) and n = ra(mod b). If n1 and n2 are | | 6 | +# two such integers, then n1=n2(mod ab) | 6 | 7 |
| 7 | 8 | # Algorithm : | 8 | 9 |
| |
Collapse file Copy file name to clipboardExpand all lines: blockchain/diophantine_equation.py +11-7Lines changed: 11 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -# Diophantine Equation : Given integers a,b,c ( at least one of a and b != 0), the diophantine equation | 2 | | -# a*x + b*y = c has a solution (where x and y are integers) iff gcd(a,b) divides c. | | 1 | +# Diophantine Equation : Given integers a,b,c ( at least one of a and b != 0), the | | 2 | +# diophantine equation a*x + b*y = c has a solution (where x and y are integers) | | 3 | +# iff gcd(a,b) divides c. | 3 | 4 |
| 4 | 5 | # GCD ( Greatest Common Divisor ) or HCF ( Highest Common Factor ) | 5 | 6 |
| @@ -29,8 +30,9 @@ def diophantine(a, b, c): | 29 | 30 |
| 30 | 31 | # Finding All solutions of Diophantine Equations: | 31 | 32 |
| 32 | | -# Theorem : Let gcd(a,b) = d, a = d*p, b = d*q. If (x0,y0) is a solution of Diophantine Equation a*x + b*y = c. | 33 | | -# a*x0 + b*y0 = c, then all the solutions have the form a(x0 + t*q) + b(y0 - t*p) = c, where t is an arbitrary integer. | | 33 | +# Theorem : Let gcd(a,b) = d, a = d*p, b = d*q. If (x0,y0) is a solution of Diophantine | | 34 | +# Equation a*x + b*y = c. a*x0 + b*y0 = c, then all the solutions have the form | | 35 | +# a(x0 + t*q) + b(y0 - t*p) = c, where t is an arbitrary integer. | 34 | 36 |
| 35 | 37 | # n is the number of solution you want, n = 2 by default | 36 | 38 |
| @@ -75,8 +77,9 @@ def greatest_common_divisor(a, b): | 75 | 77 | >>> greatest_common_divisor(7,5) | 76 | 78 | 1 | 77 | 79 |
| 78 | | - Note : In number theory, two integers a and b are said to be relatively prime, mutually prime, or co-prime | 79 | | - if the only positive integer (factor) that divides both of them is 1 i.e., gcd(a,b) = 1. | | 80 | + Note : In number theory, two integers a and b are said to be relatively prime, | | 81 | + mutually prime, or co-prime if the only positive integer (factor) that | | 82 | + divides both of them is 1 i.e., gcd(a,b) = 1. | 80 | 83 |
| 81 | 84 | >>> greatest_common_divisor(121, 11) | 82 | 85 | 11 | @@ -91,7 +94,8 @@ def greatest_common_divisor(a, b): | 91 | 94 | return b | 92 | 95 |
| 93 | 96 |
| 94 | | -# Extended Euclid's Algorithm : If d divides a and b and d = a*x + b*y for integers x and y, then d = gcd(a,b) | | 97 | +# Extended Euclid's Algorithm : If d divides a and b and d = a*x + b*y for integers | | 98 | +# x and y, then d = gcd(a,b) | 95 | 99 |
| 96 | 100 |
| 97 | 101 | def extended_gcd(a, b): | |
Collapse file Copy file name to clipboardExpand all lines: blockchain/modular_division.py +7-5Lines changed: 7 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 |
| 4 | 4 | # GCD ( Greatest Common Divisor ) or HCF ( Highest Common Factor ) | 5 | 5 |
| 6 | | -# Given three integers a, b, and n, such that gcd(a,n)=1 and n>1, the algorithm should return an integer x such that | 7 | | -# 0≤x≤n−1, and b/a=x(modn) (that is, b=ax(modn)). | | 6 | +# Given three integers a, b, and n, such that gcd(a,n)=1 and n>1, the algorithm should | | 7 | +# return an integer x such that 0≤x≤n−1, and b/a=x(modn) (that is, b=ax(modn)). | 8 | 8 |
| 9 | 9 | # Theorem: | 10 | 10 | # a has a multiplicative inverse modulo n iff gcd(a,n) = 1 | @@ -68,7 +68,8 @@ def modular_division2(a, b, n): | 68 | 68 | return x | 69 | 69 |
| 70 | 70 |
| 71 | | -# Extended Euclid's Algorithm : If d divides a and b and d = a*x + b*y for integers x and y, then d = gcd(a,b) | | 71 | +# Extended Euclid's Algorithm : If d divides a and b and d = a*x + b*y for integers x | | 72 | +# and y, then d = gcd(a,b) | 72 | 73 |
| 73 | 74 |
| 74 | 75 | def extended_gcd(a, b): | @@ -123,8 +124,9 @@ def greatest_common_divisor(a, b): | 123 | 124 | >>> greatest_common_divisor(7,5) | 124 | 125 | 1 | 125 | 126 |
| 126 | | - Note : In number theory, two integers a and b are said to be relatively prime, mutually prime, or co-prime | 127 | | - if the only positive integer (factor) that divides both of them is 1 i.e., gcd(a,b) = 1. | | 127 | + Note : In number theory, two integers a and b are said to be relatively prime, | | 128 | + mutually prime, or co-prime if the only positive integer (factor) that divides | | 129 | + both of them is 1 i.e., gcd(a,b) = 1. | 128 | 130 |
| 129 | 131 | >>> greatest_common_divisor(121, 11) | 130 | 132 | 11 | |
Collapse file Copy file name to clipboardExpand all lines: ciphers/affine_cipher.py +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -55,7 +55,8 @@ def check_keys(keyA, keyB, mode): | 55 | 55 |
| 56 | 56 | def encrypt_message(key: int, message: str) -> str: | 57 | 57 | """ | 58 | | - >>> encrypt_message(4545, 'The affine cipher is a type of monoalphabetic substitution cipher.') | | 58 | + >>> encrypt_message(4545, 'The affine cipher is a type of monoalphabetic ' | | 59 | + ... 'substitution cipher.') | 59 | 60 | 'VL}p MM{I}p~{HL}Gp{vp pFsH}pxMpyxIx JHL O}F{~pvuOvF{FuF{xIp~{HL}Gi' | 60 | 61 | """ | 61 | 62 | keyA, keyB = divmod(key, len(SYMBOLS)) | @@ -72,7 +73,8 @@ def encrypt_message(key: int, message: str) -> str: | 72 | 73 |
| 73 | 74 | def decrypt_message(key: int, message: str) -> str: | 74 | 75 | """ | 75 | | - >>> decrypt_message(4545, 'VL}p MM{I}p~{HL}Gp{vp pFsH}pxMpyxIx JHL O}F{~pvuOvF{FuF{xIp~{HL}Gi') | | 76 | + >>> decrypt_message(4545, 'VL}p MM{I}p~{HL}Gp{vp pFsH}pxMpyxIx JHL O}F{~pvuOvF{FuF' | | 77 | + ... '{xIp~{HL}Gi') | 76 | 78 | 'The affine cipher is a type of monoalphabetic substitution cipher.' | 77 | 79 | """ | 78 | 80 | keyA, keyB = divmod(key, len(SYMBOLS)) | |
Collapse file Copy file name to clipboardExpand all lines: ciphers/base64_cipher.py +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -39,7 +39,8 @@ def decode_base64(text): | 39 | 39 | 'WELCOME to base64 encoding 😁' | 40 | 40 | >>> decode_base64('QcOF4ZCD8JCAj/CfpJM=') | 41 | 41 | 'AÅᐃ𐀏🤓' | 42 | | - >>> decode_base64("QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFB\r\nQUFB") | | 42 | + >>> decode_base64("QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUF" | | 43 | + ... "BQUFBQUFBQUFB\r\nQUFB") | 43 | 44 | 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' | 44 | 45 | """ | 45 | 46 | base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" | |
|