Skip to content

Commit b0c2eb4

Browse files
authored
Merge branch 'master' into master
2 parents 4f5dea3 + 788d95b commit b0c2eb4

File tree

10 files changed

+127
-17
lines changed

10 files changed

+127
-17
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,21 @@ 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
1219
- uses: actions/checkout@v5
13-
- uses: astral-sh/setup-uv@v6
20+
- uses: astral-sh/setup-uv@v7
1421
with:
1522
enable-cache: true
1623
cache-dependency-glob: uv.lock
1724
- uses: actions/setup-python@v6
1825
with:
19-
python-version: 3.x
26+
python-version: 3.14
2027
allow-prereleases: true
2128
- run: uv sync --group=test
2229
- name: Run tests

.github/workflows/directory_writer.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ jobs:
1111
fetch-depth: 0
1212
- uses: actions/setup-python@v6
1313
with:
14-
python-version: 3.x
14+
python-version: 3.14
15+
allow-prereleases: true
1516
- name: Write DIRECTORY.md
1617
run: |
1718
scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md

.github/workflows/project_euler.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,37 @@ jobs:
1414
project-euler:
1515
runs-on: ubuntu-latest
1616
steps:
17+
- run:
18+
sudo apt-get update && sudo apt-get install -y libtiff5-dev libjpeg8-dev libopenjp2-7-dev
19+
zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk
20+
libharfbuzz-dev libfribidi-dev libxcb1-dev
21+
libxml2-dev libxslt-dev
22+
libhdf5-dev
23+
libopenblas-dev
1724
- uses: actions/checkout@v5
18-
- uses: astral-sh/setup-uv@v6
25+
- uses: astral-sh/setup-uv@v7
1926
- uses: actions/setup-python@v6
2027
with:
21-
python-version: 3.x
28+
python-version: 3.14
29+
allow-prereleases: true
2230
- run: uv sync --group=euler-validate --group=test
2331
- run: uv run pytest --doctest-modules --cov-report=term-missing:skip-covered --cov=project_euler/ project_euler/
2432
validate-solutions:
2533
runs-on: ubuntu-latest
2634
steps:
35+
- run:
36+
sudo apt-get update && sudo apt-get install -y libtiff5-dev libjpeg8-dev libopenjp2-7-dev
37+
zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk
38+
libharfbuzz-dev libfribidi-dev libxcb1-dev
39+
libxml2-dev libxslt-dev
40+
libhdf5-dev
41+
libopenblas-dev
2742
- uses: actions/checkout@v5
28-
- uses: astral-sh/setup-uv@v6
43+
- uses: astral-sh/setup-uv@v7
2944
- uses: actions/setup-python@v6
3045
with:
31-
python-version: 3.x
46+
python-version: 3.14
47+
allow-prereleases: true
3248
- run: uv sync --group=euler-validate --group=test
3349
- run: uv run pytest scripts/validate_solutions.py
3450
env:

.github/workflows/ruff.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v5
15-
- uses: astral-sh/setup-uv@v6
15+
- uses: astral-sh/setup-uv@v7
1616
- run: uvx ruff check --output-format=github .

.github/workflows/sphinx.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,18 @@ jobs:
2525
build_docs:
2626
runs-on: ubuntu-24.04-arm
2727
steps:
28+
- run:
29+
sudo apt-get update && sudo apt-get install -y libtiff5-dev libjpeg8-dev libopenjp2-7-dev
30+
zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk
31+
libharfbuzz-dev libfribidi-dev libxcb1-dev
32+
libxml2-dev libxslt-dev
33+
libhdf5-dev
34+
libopenblas-dev
2835
- uses: actions/checkout@v5
29-
- uses: astral-sh/setup-uv@v6
36+
- uses: astral-sh/setup-uv@v7
3037
- uses: actions/setup-python@v6
3138
with:
32-
python-version: 3.13
39+
python-version: 3.14
3340
allow-prereleases: true
3441
- run: uv sync --group=docs
3542
- uses: actions/configure-pages@v5

ciphers/gronsfeld_cipher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def gronsfeld(text: str, key: str) -> str:
2020
>>> gronsfeld('yes, ¥€$ - _!@#%?', '')
2121
Traceback (most recent call last):
2222
...
23-
ZeroDivisionError: integer modulo by zero
23+
ZeroDivisionError: division by zero
2424
"""
2525
ascii_len = len(ascii_uppercase)
2626
key_len = len(key)
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
def rotate_array(arr: list[int], steps: int) -> list[int]:
2+
"""
3+
Rotates a list to the right by steps positions.
4+
5+
Parameters:
6+
arr (List[int]): The list of integers to rotate.
7+
steps (int): Number of positions to rotate. Can be negative for left rotation.
8+
9+
Returns:
10+
List[int]: Rotated list.
11+
12+
Examples:
13+
>>> rotate_array([1, 2, 3, 4, 5], 2)
14+
[4, 5, 1, 2, 3]
15+
>>> rotate_array([1, 2, 3, 4, 5], -2)
16+
[3, 4, 5, 1, 2]
17+
>>> rotate_array([1, 2, 3, 4, 5], 7)
18+
[4, 5, 1, 2, 3]
19+
>>> rotate_array([], 3)
20+
[]
21+
"""
22+
23+
n = len(arr)
24+
if n == 0:
25+
return arr
26+
27+
steps = steps % n
28+
29+
if steps < 0:
30+
steps += n
31+
32+
def reverse(start: int, end: int) -> None:
33+
"""
34+
Reverses a portion of the list in place from index start to end.
35+
36+
Parameters:
37+
start (int): Starting index of the portion to reverse.
38+
end (int): Ending index of the portion to reverse.
39+
40+
Returns:
41+
None
42+
43+
Examples:
44+
>>> example = [1, 2, 3, 4, 5]
45+
>>> def reverse_test(arr, start, end):
46+
... while start < end:
47+
... arr[start], arr[end] = arr[end], arr[start]
48+
... start += 1
49+
... end -= 1
50+
>>> reverse_test(example, 0, 2)
51+
>>> example
52+
[3, 2, 1, 4, 5]
53+
>>> reverse_test(example, 2, 4)
54+
>>> example
55+
[3, 2, 5, 4, 1]
56+
"""
57+
58+
while start < end:
59+
arr[start], arr[end] = arr[end], arr[start]
60+
start += 1
61+
end -= 1
62+
63+
reverse(0, n - 1)
64+
reverse(0, steps - 1)
65+
reverse(steps, n - 1)
66+
67+
return arr
68+
69+
70+
if __name__ == "__main__":
71+
examples = [
72+
([1, 2, 3, 4, 5], 2),
73+
([1, 2, 3, 4, 5], -2),
74+
([1, 2, 3, 4, 5], 7),
75+
([], 3),
76+
]
77+
78+
for arr, steps in examples:
79+
rotated = rotate_array(arr.copy(), steps)
80+
print(f"Rotate {arr} by {steps}: {rotated}")

machine_learning/xgboost_classifier.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ def xgboost(features: np.ndarray, target: np.ndarray) -> XGBClassifier:
4242

4343
def main() -> None:
4444
"""
45-
>>> main()
46-
4745
Url for the algorithm:
4846
https://xgboost.readthedocs.io/en/stable/
4947
Iris type dataset is used to demonstrate algorithm.

maths/largest_of_very_large_numbers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def res(x, y):
1515
>>> res(-1, 5)
1616
Traceback (most recent call last):
1717
...
18-
ValueError: math domain error
18+
ValueError: expected a positive input
1919
"""
2020
if 0 not in (x, y):
2121
# We use the relation x^y = y*log10(x), where 10 is the base.

pyproject.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@ classifiers = [
1010
]
1111
dependencies = [
1212
"beautifulsoup4>=4.12.3",
13+
"cython>=3.1.2",
1314
"fake-useragent>=1.5.1",
1415
"httpx>=0.28.1",
1516
"imageio>=2.36.1",
1617
"keras>=3.7",
17-
"lxml>=5.3",
18+
"lxml>=6",
1819
"matplotlib>=3.9.3",
1920
"numpy>=2.1.3",
2021
"opencv-python>=4.10.0.84",
2122
"pandas>=2.2.3",
22-
"pillow>=11",
23+
"pillow>=11.3",
2324
"rich>=13.9.4",
2425
"scikit-learn>=1.5.2",
2526
"sphinx-pyproject>=0.3",
@@ -32,7 +33,7 @@ dependencies = [
3233

3334
[dependency-groups]
3435
test = [
35-
"pytest>=8.3.4",
36+
"pytest>=8.4.1",
3637
"pytest-cov>=6",
3738
]
3839

0 commit comments

Comments
 (0)