Skip to content

Commit d215734

Browse files
Merge branch 'master' into ML
2 parents c315554 + 791deb4 commit d215734

File tree

24 files changed

+135
-54
lines changed

24 files changed

+135
-54
lines changed

.github/workflows/sphinx.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ jobs:
3939
python-version: 3.14
4040
allow-prereleases: true
4141
- run: uv sync --group=docs
42-
- uses: actions/configure-pages@v5
42+
- uses: actions/configure-pages@v6
4343
- run: uv run sphinx-build -c docs . docs/_build/html
44-
- uses: actions/upload-pages-artifact@v4
44+
- uses: actions/upload-pages-artifact@v5
4545
with:
4646
path: docs/_build/html
4747

@@ -53,5 +53,5 @@ jobs:
5353
needs: build_docs
5454
runs-on: ubuntu-latest
5555
steps:
56-
- uses: actions/deploy-pages@v4
56+
- uses: actions/deploy-pages@v5
5757
id: deployment

.pre-commit-config.yaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ repos:
1919
- id: auto-walrus
2020

2121
- repo: https://github.com/astral-sh/ruff-pre-commit
22-
rev: v0.14.14
22+
rev: v0.15.9
2323
hooks:
2424
- id: ruff-check
2525
- id: ruff-format
2626

2727
- repo: https://github.com/codespell-project/codespell
28-
rev: v2.4.1
28+
rev: v2.4.2
2929
hooks:
3030
- id: codespell
3131
additional_dependencies:
3232
- tomli
3333

3434
- repo: https://github.com/tox-dev/pyproject-fmt
35-
rev: v2.12.1
35+
rev: v2.21.0
3636
hooks:
3737
- id: pyproject-fmt
3838

@@ -45,19 +45,19 @@ repos:
4545
pass_filenames: false
4646

4747
- repo: https://github.com/abravalheri/validate-pyproject
48-
rev: v0.24.1
48+
rev: v0.25
4949
hooks:
5050
- id: validate-pyproject
5151

52-
- repo: https://github.com/pre-commit/mirrors-mypy
53-
rev: v1.19.1
54-
hooks:
55-
- id: mypy
56-
args:
57-
- --explicit-package-bases
58-
- --ignore-missing-imports
59-
- --install-types
60-
- --non-interactive
52+
# - repo: https://github.com/pre-commit/mirrors-mypy
53+
# rev: v1.20.0
54+
# hooks:
55+
# - id: mypy
56+
# args:
57+
# - --explicit-package-bases
58+
# - --ignore-missing-imports
59+
# - --install-types
60+
# - --non-interactive
6161

6262
- repo: https://github.com/pre-commit/mirrors-prettier
6363
rev: v4.0.0-alpha.8

DIRECTORY.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,11 @@
469469

470470
## Geometry
471471
* [Geometry](geometry/geometry.py)
472+
* [Graham Scan](geometry/graham_scan.py)
473+
* [Jarvis March](geometry/jarvis_march.py)
474+
* Tests
475+
* [Test Graham Scan](geometry/tests/test_graham_scan.py)
476+
* [Test Jarvis March](geometry/tests/test_jarvis_march.py)
472477

473478
## Graphics
474479
* [Bezier Curve](graphics/bezier_curve.py)
@@ -981,6 +986,7 @@
981986
* [Sol2](project_euler/problem_014/sol2.py)
982987
* Problem 015
983988
* [Sol1](project_euler/problem_015/sol1.py)
989+
* [Sol2](project_euler/problem_015/sol2.py)
984990
* Problem 016
985991
* [Sol1](project_euler/problem_016/sol1.py)
986992
* [Sol2](project_euler/problem_016/sol2.py)

backtracking/generate_parentheses.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ def generate_parenthesis(n: int) -> list[str]:
6464
Example 2:
6565
>>> generate_parenthesis(1)
6666
['()']
67+
68+
Example 3:
69+
>>> generate_parenthesis(0)
70+
['']
6771
"""
6872

6973
result: list[str] = []

backtracking/n_queens.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ def is_safe(board: list[list[int]], row: int, column: int) -> bool:
3333
False
3434
>>> is_safe([[0, 0, 1], [0, 0, 0], [0, 0, 0]], 1, 1)
3535
False
36+
>>> is_safe([[1, 0, 0], [0, 0, 0], [0, 0, 0]], 1, 2)
37+
True
38+
>>> is_safe([[1, 0, 0], [0, 0, 0], [0, 0, 0]], 2, 1)
39+
True
40+
>>> is_safe([[0, 0, 0], [1, 0, 0], [0, 0, 0]], 0, 2)
41+
True
42+
>>> is_safe([[0, 0, 0], [1, 0, 0], [0, 0, 0]], 2, 2)
43+
True
3644
"""
3745

3846
n = len(board) # Size of the board

backtracking/word_break.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ def word_break(input_string: str, word_dict: set[str]) -> bool:
6666
6767
>>> word_break("catsandog", {"cats", "dog", "sand", "and", "cat"})
6868
False
69+
70+
>>> word_break("applepenapple", {})
71+
False
6972
"""
7073

7174
return backtrack(input_string, word_dict, 0)

digital_image_processing/filters/local_binary_pattern.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def get_neighbors_pixel(
1919

2020
try:
2121
return int(image[x_coordinate][y_coordinate] >= center)
22-
except (IndexError, TypeError):
22+
except IndexError, TypeError:
2323
return 0
2424

2525

divide_and_conquer/convex_hull.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def _construct_points(
124124
else:
125125
try:
126126
points.append(Point(p[0], p[1]))
127-
except (IndexError, TypeError):
127+
except IndexError, TypeError:
128128
print(
129129
f"Ignoring deformed point {p}. All points"
130130
" must have at least 2 coordinates."

dynamic_programming/catalan_numbers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def catalan_numbers(upper_limit: int) -> "list[int]":
7171
print(f"The Catalan numbers from 0 through {N} are:")
7272
print(catalan_numbers(N))
7373
print("Try another upper limit for the sequence: ", end="")
74-
except (NameError, ValueError):
74+
except NameError, ValueError:
7575
print("\n********* Invalid input, goodbye! ************\n")
7676

7777
import doctest

geodesy/lamberts_ellipsoidal_distance.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,26 @@ def lamberts_ellipsoidal_distance(
3232
Returns:
3333
geographical distance between two points in metres
3434
35+
>>> lamberts_ellipsoidal_distance(100, 0, 0, 0)
36+
Traceback (most recent call last):
37+
...
38+
ValueError: Latitude must be between -90 and 90 degrees
39+
40+
>>> lamberts_ellipsoidal_distance(0, 0, -100, 0)
41+
Traceback (most recent call last):
42+
...
43+
ValueError: Latitude must be between -90 and 90 degrees
44+
45+
>>> lamberts_ellipsoidal_distance(0, 200, 0, 0)
46+
Traceback (most recent call last):
47+
...
48+
ValueError: Longitude must be between -180 and 180 degrees
49+
50+
>>> lamberts_ellipsoidal_distance(0, 0, 0, -200)
51+
Traceback (most recent call last):
52+
...
53+
ValueError: Longitude must be between -180 and 180 degrees
54+
3555
>>> from collections import namedtuple
3656
>>> point_2d = namedtuple("point_2d", "lat lon")
3757
>>> SAN_FRANCISCO = point_2d(37.774856, -122.424227)
@@ -46,6 +66,14 @@ def lamberts_ellipsoidal_distance(
4666
'9,737,326 meters'
4767
"""
4868

69+
# Validate latitude values
70+
if not -90 <= lat1 <= 90 or not -90 <= lat2 <= 90:
71+
raise ValueError("Latitude must be between -90 and 90 degrees")
72+
73+
# Validate longitude values
74+
if not -180 <= lon1 <= 180 or not -180 <= lon2 <= 180:
75+
raise ValueError("Longitude must be between -180 and 180 degrees")
76+
4977
# CONSTANTS per WGS84 https://en.wikipedia.org/wiki/World_Geodetic_System
5078
# Distance in metres(m)
5179
# Equation Parameters

0 commit comments

Comments
 (0)