Skip to content

Commit f7fa4d9

Browse files
committed
Merge branch 'master' of github.com:ZeroDayOwl/Python into CasimirEffect
2 parents cdb1fc9 + 05e1912 commit f7fa4d9

File tree

74 files changed

+280
-122
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+280
-122
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ repos:
4040
- --ignore=E203,W503
4141
- --max-complexity=25
4242
- --max-line-length=88
43-
additional_dependencies: [flake8-builtins, pep8-naming]
43+
additional_dependencies:
44+
- flake8-bugbear
45+
- flake8-builtins
46+
- pep8-naming
4447

4548
- repo: https://github.com/pre-commit/mirrors-mypy
4649
rev: v0.982

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@
3434
<h3>All algorithms implemented in Python - for education</h3>
3535
</div>
3636

37-
Implementations are for learning purposes only. As they may be less efficient than the implementations in the Python standard library, use them at your discretion.
37+
Implementations are for learning purposes only. They may be less efficient than the implementations in the Python standard library. Use them at your discretion.
3838

3939
## Getting Started
4040

4141
Read through our [Contribution Guidelines](CONTRIBUTING.md) before you contribute.
4242

4343
## Community Channels
4444

45-
We're on [Discord](https://discord.gg/c7MnfGFGa6) and [Gitter](https://gitter.im/TheAlgorithms)! Community channels are great for you to ask questions and get help. Please join us!
45+
We are on [Discord](https://discord.gg/c7MnfGFGa6) and [Gitter](https://gitter.im/TheAlgorithms)! Community channels are a great way for you to ask questions and get help. Please join us!
4646

4747
## List of Algorithms
4848

49-
See our [directory](DIRECTORY.md) for easier navigation and better overview of the project.
49+
See our [directory](DIRECTORY.md) for easier navigation and a better overview of the project.

arithmetic_analysis/jacobi_iteration_method.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def jacobi_iteration_method(
110110
strictly_diagonally_dominant(table)
111111

112112
# Iterates the whole matrix for given number of times
113-
for i in range(iterations):
113+
for _ in range(iterations):
114114
new_val = []
115115
for row in range(rows):
116116
temp = 0

arithmetic_analysis/newton_forward_interpolation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def ucal(u: float, p: int) -> float:
2323
def main() -> None:
2424
n = int(input("enter the numbers of values: "))
2525
y: list[list[float]] = []
26-
for i in range(n):
26+
for _ in range(n):
2727
y.append([])
2828
for i in range(n):
2929
for j in range(n):

arithmetic_analysis/secant_method.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def secant_method(lower_bound: float, upper_bound: float, repeats: int) -> float
2020
"""
2121
x0 = lower_bound
2222
x1 = upper_bound
23-
for i in range(0, repeats):
23+
for _ in range(0, repeats):
2424
x0, x1 = x1, x1 - (f(x1) * (x1 - x0)) / (f(x1) - f(x0))
2525
return x1
2626

audio_filters/butterworth_filter.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
def make_lowpass(
14-
frequency: int, samplerate: int, q_factor: float = 1 / sqrt(2)
14+
frequency: int, samplerate: int, q_factor: float = 1 / sqrt(2) # noqa: B008
1515
) -> IIRFilter:
1616
"""
1717
Creates a low-pass filter
@@ -39,7 +39,7 @@ def make_lowpass(
3939

4040

4141
def make_highpass(
42-
frequency: int, samplerate: int, q_factor: float = 1 / sqrt(2)
42+
frequency: int, samplerate: int, q_factor: float = 1 / sqrt(2) # noqa: B008
4343
) -> IIRFilter:
4444
"""
4545
Creates a high-pass filter
@@ -67,7 +67,7 @@ def make_highpass(
6767

6868

6969
def make_bandpass(
70-
frequency: int, samplerate: int, q_factor: float = 1 / sqrt(2)
70+
frequency: int, samplerate: int, q_factor: float = 1 / sqrt(2) # noqa: B008
7171
) -> IIRFilter:
7272
"""
7373
Creates a band-pass filter
@@ -96,7 +96,7 @@ def make_bandpass(
9696

9797

9898
def make_allpass(
99-
frequency: int, samplerate: int, q_factor: float = 1 / sqrt(2)
99+
frequency: int, samplerate: int, q_factor: float = 1 / sqrt(2) # noqa: B008
100100
) -> IIRFilter:
101101
"""
102102
Creates an all-pass filter
@@ -121,7 +121,10 @@ def make_allpass(
121121

122122

123123
def make_peak(
124-
frequency: int, samplerate: int, gain_db: float, q_factor: float = 1 / sqrt(2)
124+
frequency: int,
125+
samplerate: int,
126+
gain_db: float,
127+
q_factor: float = 1 / sqrt(2), # noqa: B008
125128
) -> IIRFilter:
126129
"""
127130
Creates a peak filter
@@ -150,7 +153,10 @@ def make_peak(
150153

151154

152155
def make_lowshelf(
153-
frequency: int, samplerate: int, gain_db: float, q_factor: float = 1 / sqrt(2)
156+
frequency: int,
157+
samplerate: int,
158+
gain_db: float,
159+
q_factor: float = 1 / sqrt(2), # noqa: B008
154160
) -> IIRFilter:
155161
"""
156162
Creates a low-shelf filter
@@ -184,7 +190,10 @@ def make_lowshelf(
184190

185191

186192
def make_highshelf(
187-
frequency: int, samplerate: int, gain_db: float, q_factor: float = 1 / sqrt(2)
193+
frequency: int,
194+
samplerate: int,
195+
gain_db: float,
196+
q_factor: float = 1 / sqrt(2), # noqa: B008
188197
) -> IIRFilter:
189198
"""
190199
Creates a high-shelf filter

backtracking/sum_of_subsets.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ def create_state_space_tree(
3939
if sum(path) == max_sum:
4040
result.append(path)
4141
return
42-
for num_index in range(num_index, len(nums)):
42+
for index in range(num_index, len(nums)):
4343
create_state_space_tree(
4444
nums,
4545
max_sum,
46-
num_index + 1,
47-
path + [nums[num_index]],
46+
index + 1,
47+
path + [nums[index]],
4848
result,
49-
remaining_nums_sum - nums[num_index],
49+
remaining_nums_sum - nums[index],
5050
)
5151

5252

boolean_algebra/norgate.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
""" A NOR Gate is a logic gate in boolean algebra which results to false(0)
2+
if any of the input is 1, and True(1) if both the inputs are 0.
3+
Following is the truth table of an NOR Gate:
4+
| Input 1 | Input 2 | Output |
5+
| 0 | 0 | 1 |
6+
| 0 | 1 | 0 |
7+
| 1 | 0 | 0 |
8+
| 1 | 1 | 0 |
9+
"""
10+
"""Following is the code implementation of the NOR Gate"""
11+
12+
13+
def nor_gate(input_1: int, input_2: int) -> int:
14+
"""
15+
>>> nor_gate(0, 0)
16+
1
17+
>>> nor_gate(0, 1)
18+
0
19+
>>> nor_gate(1, 0)
20+
0
21+
>>> nor_gate(1, 1)
22+
0
23+
>>> nor_gate(0.0, 0.0)
24+
1
25+
>>> nor_gate(0, -7)
26+
0
27+
"""
28+
return int(bool(input_1 == input_2 == 0))
29+
30+
31+
def main() -> None:
32+
print("Truth Table of NOR Gate:")
33+
print("| Input 1 |", " Input 2 |", " Output |")
34+
print("| 0 |", " 0 | ", nor_gate(0, 0), " |")
35+
print("| 0 |", " 1 | ", nor_gate(0, 1), " |")
36+
print("| 1 |", " 0 | ", nor_gate(1, 0), " |")
37+
print("| 1 |", " 1 | ", nor_gate(1, 1), " |")
38+
39+
40+
if __name__ == "__main__":
41+
import doctest
42+
43+
doctest.testmod()
44+
main()
45+
"""Code provided by Akshaj Vishwanathan"""
46+
"""Reference: https://www.geeksforgeeks.org/logic-gates-in-python/"""

boolean_algebra/quine_mc_cluskey.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def decimal_to_binary(no_of_variable: int, minterms: Sequence[float]) -> list[st
5656
temp = []
5757
for minterm in minterms:
5858
string = ""
59-
for i in range(no_of_variable):
59+
for _ in range(no_of_variable):
6060
string = str(minterm % 2) + string
6161
minterm //= 2
6262
temp.append(string)

ciphers/mixed_keyword_cypher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def mixed_keyword(key: str = "college", pt: str = "UNIVERSITY") -> str:
4040
k = 0
4141
for _ in range(r):
4242
s = []
43-
for j in range(len_temp):
43+
for _ in range(len_temp):
4444
s.append(temp[k])
4545
if not (k < 25):
4646
break

0 commit comments

Comments
 (0)