Skip to content

Commit 6c73e42

Browse files
Merge branch 'TheAlgorithms:master' into ML
2 parents 6dd9cc9 + c79034c commit 6c73e42

File tree

12 files changed

+18
-42
lines changed

12 files changed

+18
-42
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@ jobs:
99
build:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- run:
13-
sudo apt-get update && sudo apt-get install -y libtiff5-dev libjpeg8-dev libopenjp2-7-dev
14-
zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk
15-
libharfbuzz-dev libfribidi-dev libxcb1-dev
16-
libxml2-dev libxslt-dev
17-
libhdf5-dev
18-
libopenblas-dev
12+
- run: sudo apt-get update && sudo apt-get install -y libhdf5-dev
1913
- uses: actions/checkout@v5
2014
- uses: astral-sh/setup-uv@v7
2115
with:
@@ -32,6 +26,7 @@ jobs:
3226
--ignore=computer_vision/cnn_classification.py
3327
--ignore=docs/conf.py
3428
--ignore=dynamic_programming/k_means_clustering_tensorflow.py
29+
--ignore=machine_learning/local_weighted_learning/local_weighted_learning.py
3530
--ignore=machine_learning/lstm/lstm_prediction.py
3631
--ignore=neural_network/input_data.py
3732
--ignore=project_euler/

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ We want your work to be readable by others; therefore, we encourage you to note
9999
ruff check
100100
```
101101

102-
- Original code submission require docstrings or comments to describe your work.
102+
- Original code submissions require docstrings or comments to describe your work.
103103

104104
- More on docstrings and comments:
105105

DIRECTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@
624624
* [Sequential Minimum Optimization](machine_learning/sequential_minimum_optimization.py)
625625
* [Similarity Search](machine_learning/similarity_search.py)
626626
* [Support Vector Machines](machine_learning/support_vector_machines.py)
627+
* [T Stochastic Neighbour Embedding](machine_learning/t_stochastic_neighbour_embedding.py)
627628
* [Word Frequency Functions](machine_learning/word_frequency_functions.py)
628629
* [Xgboost Classifier](machine_learning/xgboost_classifier.py)
629630
* [Xgboost Regressor](machine_learning/xgboost_regressor.py)

machine_learning/decision_tree.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,13 @@ def predict(self, x):
146146
"""
147147
if self.prediction is not None:
148148
return self.prediction
149-
elif self.left or self.right is not None:
149+
elif self.left is not None and self.right is not None:
150150
if x >= self.decision_boundary:
151151
return self.right.predict(x)
152152
else:
153153
return self.left.predict(x)
154154
else:
155-
print("Error: Decision tree not yet trained")
156-
return None
155+
raise ValueError("Decision tree not yet trained")
157156

158157

159158
class TestDecisionTree:
@@ -201,4 +200,4 @@ def main():
201200
main()
202201
import doctest
203202

204-
doctest.testmod(name="mean_squarred_error", verbose=True)
203+
doctest.testmod(name="mean_squared_error", verbose=True)

maths/factorial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def factorial_recursive(n: int) -> int:
5656
raise ValueError("factorial() only accepts integral values")
5757
if n < 0:
5858
raise ValueError("factorial() not defined for negative values")
59-
return 1 if n in {0, 1} else n * factorial(n - 1)
59+
return 1 if n in {0, 1} else n * factorial_recursive(n - 1)
6060

6161

6262
if __name__ == "__main__":

maths/fibonacci.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def fib_memoization(n: int) -> list[int]:
183183
"""
184184
if n < 0:
185185
raise ValueError("n is negative")
186-
# Cache must be outside recursuive function
186+
# Cache must be outside recursive function
187187
# other it will reset every time it calls itself.
188188
cache: dict[int, int] = {0: 0, 1: 1, 2: 1} # Prefilled cache
189189

maths/monte_carlo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from statistics import mean
99

1010

11-
def pi_estimator(iterations: int):
11+
def pi_estimator(iterations: int) -> None:
1212
"""
1313
An implementation of the Monte Carlo method used to find pi.
1414
1. Draw a 2x2 square centred at (0,0).

maths/volume.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ def main():
555555
print(f"Torus: {vol_torus(2, 2) = }") # ~= 157.9
556556
print(f"Conical Frustum: {vol_conical_frustum(2, 2, 4) = }") # ~= 58.6
557557
print(f"Spherical cap: {vol_spherical_cap(1, 2) = }") # ~= 5.24
558-
print(f"Spheres intersetion: {vol_spheres_intersect(2, 2, 1) = }") # ~= 21.21
558+
print(f"Spheres intersection: {vol_spheres_intersect(2, 2, 1) = }") # ~= 21.21
559559
print(f"Spheres union: {vol_spheres_union(2, 2, 1) = }") # ~= 45.81
560560
print(
561561
f"Hollow Circular Cylinder: {vol_hollow_circular_cylinder(1, 2, 3) = }"

pyproject.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ name = "thealgorithms-python"
33
version = "0.0.1"
44
description = "TheAlgorithms in Python"
55
authors = [ { name = "TheAlgorithms Contributors" } ]
6-
requires-python = ">=3.13"
6+
requires-python = ">=3.14"
77
classifiers = [
88
"Programming Language :: Python :: 3 :: Only",
9-
"Programming Language :: Python :: 3.13",
109
]
1110
dependencies = [
1211
"beautifulsoup4>=4.12.3",
@@ -23,6 +22,7 @@ dependencies = [
2322
"pillow>=11.3",
2423
"rich>=13.9.4",
2524
"scikit-learn>=1.5.2",
25+
"scipy>=1.16.2",
2626
"sphinx-pyproject>=0.3",
2727
"statsmodels>=0.14.4",
2828
"sympy>=1.13.3",
@@ -48,7 +48,7 @@ euler-validate = [
4848
]
4949

5050
[tool.ruff]
51-
target-version = "py313"
51+
target-version = "py314"
5252

5353
output-format = "full"
5454
lint.select = [
@@ -109,7 +109,7 @@ lint.ignore = [
109109
# `ruff rule S101` for a description of that rule
110110
"B904", # Within an `except` clause, raise exceptions with `raise ... from err` -- FIX ME
111111
"B905", # `zip()` without an explicit `strict=` parameter -- FIX ME
112-
"EM101", # Exception must not use a string literal, assign to variable first
112+
"EM101", # Exception must not use a string literal, assign to a variable first
113113
"EXE001", # Shebang is present but file is not executable -- DO NOT FIX
114114
"G004", # Logging statement uses f-string
115115
"ISC001", # Conflicts with ruff format -- DO NOT FIX
@@ -125,6 +125,7 @@ lint.ignore = [
125125
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes -- FIX ME
126126
"SIM905", # Consider using a list literal instead of `str.split` -- DO NOT FIX
127127
"SLF001", # Private member accessed: `_Iterator` -- FIX ME
128+
"UP037", # FIX ME
128129
]
129130

130131
lint.per-file-ignores."data_structures/hashing/tests/test_hash_map.py" = [

requirements.txt

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)