mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-27 15:01:08 +00:00
Upgrade to Python 3.12 (#9576)
* DRAFT: GitHub Actions: Test on Python 3.12 Repeats #8777 * #8777 Some of our dependencies will not be ready yet. * Python 3.12: Disable qiskit and tensorflow algorithms * updating DIRECTORY.md --------- Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
parent
f964dcbf2f
commit
0f4e51245f
5
.github/workflows/build.yml
vendored
5
.github/workflows/build.yml
vendored
|
@ -9,10 +9,11 @@ jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-python@v4
|
- uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: 3.11
|
python-version: 3.12
|
||||||
|
allow-prereleases: true
|
||||||
- uses: actions/cache@v3
|
- uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ~/.cache/pip
|
path: ~/.cache/pip
|
||||||
|
|
2
.github/workflows/ruff.yml
vendored
2
.github/workflows/ruff.yml
vendored
|
@ -11,6 +11,6 @@ jobs:
|
||||||
ruff:
|
ruff:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- run: pip install --user ruff
|
- run: pip install --user ruff
|
||||||
- run: ruff --output-format=github .
|
- run: ruff --output-format=github .
|
||||||
|
|
|
@ -73,7 +73,7 @@ pre-commit run --all-files --show-diff-on-failure
|
||||||
|
|
||||||
We want your work to be readable by others; therefore, we encourage you to note the following:
|
We want your work to be readable by others; therefore, we encourage you to note the following:
|
||||||
|
|
||||||
- Please write in Python 3.11+. For instance: `print()` is a function in Python 3 so `print "Hello"` will *not* work but `print("Hello")` will.
|
- Please write in Python 3.12+. For instance: `print()` is a function in Python 3 so `print "Hello"` will *not* work but `print("Hello")` will.
|
||||||
- Please focus hard on the naming of functions, classes, and variables. Help your reader by using __descriptive names__ that can help you to remove redundant comments.
|
- Please focus hard on the naming of functions, classes, and variables. Help your reader by using __descriptive names__ that can help you to remove redundant comments.
|
||||||
- Single letter variable names are *old school* so please avoid them unless their life only spans a few lines.
|
- Single letter variable names are *old school* so please avoid them unless their life only spans a few lines.
|
||||||
- Expand acronyms because `gcd()` is hard to understand but `greatest_common_divisor()` is not.
|
- Expand acronyms because `gcd()` is hard to understand but `greatest_common_divisor()` is not.
|
||||||
|
|
19
DIRECTORY.md
19
DIRECTORY.md
|
@ -26,7 +26,6 @@
|
||||||
* [Hamiltonian Cycle](backtracking/hamiltonian_cycle.py)
|
* [Hamiltonian Cycle](backtracking/hamiltonian_cycle.py)
|
||||||
* [Knight Tour](backtracking/knight_tour.py)
|
* [Knight Tour](backtracking/knight_tour.py)
|
||||||
* [Minimax](backtracking/minimax.py)
|
* [Minimax](backtracking/minimax.py)
|
||||||
* [Minmax](backtracking/minmax.py)
|
|
||||||
* [N Queens](backtracking/n_queens.py)
|
* [N Queens](backtracking/n_queens.py)
|
||||||
* [N Queens Math](backtracking/n_queens_math.py)
|
* [N Queens Math](backtracking/n_queens_math.py)
|
||||||
* [Power Sum](backtracking/power_sum.py)
|
* [Power Sum](backtracking/power_sum.py)
|
||||||
|
@ -133,7 +132,6 @@
|
||||||
* [Run Length Encoding](compression/run_length_encoding.py)
|
* [Run Length Encoding](compression/run_length_encoding.py)
|
||||||
|
|
||||||
## Computer Vision
|
## Computer Vision
|
||||||
* [Cnn Classification](computer_vision/cnn_classification.py)
|
|
||||||
* [Flip Augmentation](computer_vision/flip_augmentation.py)
|
* [Flip Augmentation](computer_vision/flip_augmentation.py)
|
||||||
* [Haralick Descriptors](computer_vision/haralick_descriptors.py)
|
* [Haralick Descriptors](computer_vision/haralick_descriptors.py)
|
||||||
* [Harris Corner](computer_vision/harris_corner.py)
|
* [Harris Corner](computer_vision/harris_corner.py)
|
||||||
|
@ -321,7 +319,6 @@
|
||||||
* [Floyd Warshall](dynamic_programming/floyd_warshall.py)
|
* [Floyd Warshall](dynamic_programming/floyd_warshall.py)
|
||||||
* [Integer Partition](dynamic_programming/integer_partition.py)
|
* [Integer Partition](dynamic_programming/integer_partition.py)
|
||||||
* [Iterating Through Submasks](dynamic_programming/iterating_through_submasks.py)
|
* [Iterating Through Submasks](dynamic_programming/iterating_through_submasks.py)
|
||||||
* [K Means Clustering Tensorflow](dynamic_programming/k_means_clustering_tensorflow.py)
|
|
||||||
* [Knapsack](dynamic_programming/knapsack.py)
|
* [Knapsack](dynamic_programming/knapsack.py)
|
||||||
* [Longest Common Subsequence](dynamic_programming/longest_common_subsequence.py)
|
* [Longest Common Subsequence](dynamic_programming/longest_common_subsequence.py)
|
||||||
* [Longest Common Substring](dynamic_programming/longest_common_substring.py)
|
* [Longest Common Substring](dynamic_programming/longest_common_substring.py)
|
||||||
|
@ -384,9 +381,6 @@
|
||||||
* [Mandelbrot](fractals/mandelbrot.py)
|
* [Mandelbrot](fractals/mandelbrot.py)
|
||||||
* [Sierpinski Triangle](fractals/sierpinski_triangle.py)
|
* [Sierpinski Triangle](fractals/sierpinski_triangle.py)
|
||||||
|
|
||||||
## Fuzzy Logic
|
|
||||||
* [Fuzzy Operations](fuzzy_logic/fuzzy_operations.py)
|
|
||||||
|
|
||||||
## Genetic Algorithm
|
## Genetic Algorithm
|
||||||
* [Basic String](genetic_algorithm/basic_string.py)
|
* [Basic String](genetic_algorithm/basic_string.py)
|
||||||
|
|
||||||
|
@ -517,8 +511,6 @@
|
||||||
* Local Weighted Learning
|
* Local Weighted Learning
|
||||||
* [Local Weighted Learning](machine_learning/local_weighted_learning/local_weighted_learning.py)
|
* [Local Weighted Learning](machine_learning/local_weighted_learning/local_weighted_learning.py)
|
||||||
* [Logistic Regression](machine_learning/logistic_regression.py)
|
* [Logistic Regression](machine_learning/logistic_regression.py)
|
||||||
* Lstm
|
|
||||||
* [Lstm Prediction](machine_learning/lstm/lstm_prediction.py)
|
|
||||||
* [Mfcc](machine_learning/mfcc.py)
|
* [Mfcc](machine_learning/mfcc.py)
|
||||||
* [Multilayer Perceptron Classifier](machine_learning/multilayer_perceptron_classifier.py)
|
* [Multilayer Perceptron Classifier](machine_learning/multilayer_perceptron_classifier.py)
|
||||||
* [Polynomial Regression](machine_learning/polynomial_regression.py)
|
* [Polynomial Regression](machine_learning/polynomial_regression.py)
|
||||||
|
@ -613,7 +605,6 @@
|
||||||
* [Matrix Exponentiation](maths/matrix_exponentiation.py)
|
* [Matrix Exponentiation](maths/matrix_exponentiation.py)
|
||||||
* [Max Sum Sliding Window](maths/max_sum_sliding_window.py)
|
* [Max Sum Sliding Window](maths/max_sum_sliding_window.py)
|
||||||
* [Median Of Two Arrays](maths/median_of_two_arrays.py)
|
* [Median Of Two Arrays](maths/median_of_two_arrays.py)
|
||||||
* [Miller Rabin](maths/miller_rabin.py)
|
|
||||||
* [Mobius Function](maths/mobius_function.py)
|
* [Mobius Function](maths/mobius_function.py)
|
||||||
* [Modular Exponential](maths/modular_exponential.py)
|
* [Modular Exponential](maths/modular_exponential.py)
|
||||||
* [Monte Carlo](maths/monte_carlo.py)
|
* [Monte Carlo](maths/monte_carlo.py)
|
||||||
|
@ -1071,17 +1062,7 @@
|
||||||
* [Sol1](project_euler/problem_800/sol1.py)
|
* [Sol1](project_euler/problem_800/sol1.py)
|
||||||
|
|
||||||
## Quantum
|
## Quantum
|
||||||
* [Bb84](quantum/bb84.py)
|
|
||||||
* [Deutsch Jozsa](quantum/deutsch_jozsa.py)
|
|
||||||
* [Half Adder](quantum/half_adder.py)
|
|
||||||
* [Not Gate](quantum/not_gate.py)
|
|
||||||
* [Q Fourier Transform](quantum/q_fourier_transform.py)
|
* [Q Fourier Transform](quantum/q_fourier_transform.py)
|
||||||
* [Q Full Adder](quantum/q_full_adder.py)
|
|
||||||
* [Quantum Entanglement](quantum/quantum_entanglement.py)
|
|
||||||
* [Quantum Teleportation](quantum/quantum_teleportation.py)
|
|
||||||
* [Ripple Adder Classic](quantum/ripple_adder_classic.py)
|
|
||||||
* [Single Qubit Measure](quantum/single_qubit_measure.py)
|
|
||||||
* [Superdense Coding](quantum/superdense_coding.py)
|
|
||||||
|
|
||||||
## Scheduling
|
## Scheduling
|
||||||
* [First Come First Served](scheduling/first_come_first_served.py)
|
* [First Come First Served](scheduling/first_come_first_served.py)
|
||||||
|
|
|
@ -47,7 +47,7 @@ def combination_sum(candidates: list, target: int) -> list:
|
||||||
>>> combination_sum([-8, 2.3, 0], 1)
|
>>> combination_sum([-8, 2.3, 0], 1)
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
RecursionError: maximum recursion depth exceeded in comparison
|
RecursionError: maximum recursion depth exceeded
|
||||||
"""
|
"""
|
||||||
path = [] # type: list[int]
|
path = [] # type: list[int]
|
||||||
answer = [] # type: list[int]
|
answer = [] # type: list[int]
|
||||||
|
|
|
@ -17,9 +17,9 @@ def maclaurin_sin(theta: float, accuracy: int = 30) -> float:
|
||||||
>>> all(isclose(maclaurin_sin(x, 50), sin(x)) for x in range(-25, 25))
|
>>> all(isclose(maclaurin_sin(x, 50), sin(x)) for x in range(-25, 25))
|
||||||
True
|
True
|
||||||
>>> maclaurin_sin(10)
|
>>> maclaurin_sin(10)
|
||||||
-0.544021110889369
|
-0.5440211108893691
|
||||||
>>> maclaurin_sin(-10)
|
>>> maclaurin_sin(-10)
|
||||||
0.5440211108893703
|
0.5440211108893704
|
||||||
>>> maclaurin_sin(10, 15)
|
>>> maclaurin_sin(10, 15)
|
||||||
-0.5440211108893689
|
-0.5440211108893689
|
||||||
>>> maclaurin_sin(-10, 15)
|
>>> maclaurin_sin(-10, 15)
|
||||||
|
@ -69,9 +69,9 @@ def maclaurin_cos(theta: float, accuracy: int = 30) -> float:
|
||||||
>>> all(isclose(maclaurin_cos(x, 50), cos(x)) for x in range(-25, 25))
|
>>> all(isclose(maclaurin_cos(x, 50), cos(x)) for x in range(-25, 25))
|
||||||
True
|
True
|
||||||
>>> maclaurin_cos(5)
|
>>> maclaurin_cos(5)
|
||||||
0.28366218546322675
|
0.2836621854632268
|
||||||
>>> maclaurin_cos(-5)
|
>>> maclaurin_cos(-5)
|
||||||
0.2836621854632266
|
0.2836621854632265
|
||||||
>>> maclaurin_cos(10, 15)
|
>>> maclaurin_cos(10, 15)
|
||||||
-0.8390715290764525
|
-0.8390715290764525
|
||||||
>>> maclaurin_cos(-10, 15)
|
>>> maclaurin_cos(-10, 15)
|
||||||
|
|
1
quantum/deutsch_jozsa.py → quantum/deutsch_jozsa.py.DISABLED.txt
Executable file → Normal file
1
quantum/deutsch_jozsa.py → quantum/deutsch_jozsa.py.DISABLED.txt
Executable file → Normal file
|
@ -1,3 +1,4 @@
|
||||||
|
# DISABLED!!
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
"""
|
"""
|
||||||
Deutsch-Jozsa Algorithm is one of the first examples of a quantum
|
Deutsch-Jozsa Algorithm is one of the first examples of a quantum
|
1
quantum/half_adder.py → quantum/half_adder.py.DISABLED.txt
Executable file → Normal file
1
quantum/half_adder.py → quantum/half_adder.py.DISABLED.txt
Executable file → Normal file
|
@ -1,3 +1,4 @@
|
||||||
|
# DISABLED!!
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
"""
|
"""
|
||||||
Build a half-adder quantum circuit that takes two bits as input,
|
Build a half-adder quantum circuit that takes two bits as input,
|
|
@ -9,15 +9,15 @@ opencv-python
|
||||||
pandas
|
pandas
|
||||||
pillow
|
pillow
|
||||||
projectq
|
projectq
|
||||||
qiskit
|
qiskit ; python_version < '3.12'
|
||||||
qiskit-aer
|
qiskit-aer ; python_version < '3.12'
|
||||||
requests
|
requests
|
||||||
rich
|
rich
|
||||||
scikit-fuzzy
|
scikit-fuzzy
|
||||||
scikit-learn
|
scikit-learn
|
||||||
statsmodels
|
statsmodels
|
||||||
sympy
|
sympy
|
||||||
tensorflow
|
tensorflow ; python_version < '3.12'
|
||||||
texttable
|
texttable
|
||||||
tweepy
|
tweepy
|
||||||
xgboost
|
xgboost
|
||||||
|
|
Loading…
Reference in New Issue
Block a user