Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- run: sudo apt-get update && sudo apt-get install -y libhdf5-dev
- uses: actions/checkout@v7
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/devcontainer_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/checkout@v6
- uses: devcontainers/ci@v0.3
with:
push: never
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/directory_writer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
directory_writer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-python@v6
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/project_euler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
libxml2-dev libxslt-dev
libhdf5-dev
libopenblas-dev
- uses: actions/checkout@v7
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
- uses: actions/setup-python@v6
with:
Expand All @@ -39,7 +39,7 @@ jobs:
libxml2-dev libxslt-dev
libhdf5-dev
libopenblas-dev
- uses: actions/checkout@v7
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
- uses: actions/setup-python@v6
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
- run: uvx ruff check --output-format=github .
2 changes: 1 addition & 1 deletion .github/workflows/sphinx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
libxml2-dev libxslt-dev
libhdf5-dev
libopenblas-dev
- uses: actions/checkout@v7
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
- uses: actions/setup-python@v6
with:
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repos:
- id: auto-walrus

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.15
rev: v0.15.9
hooks:
- id: ruff-check
- id: ruff-format
Expand All @@ -32,7 +32,7 @@ repos:
- tomli

- repo: https://github.com/tox-dev/pyproject-fmt
rev: v2.23.0
rev: v2.21.0
hooks:
- id: pyproject-fmt

Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Before contributing

Welcome to [TheAlgorithms/Python](https://github.com/TheAlgorithms/Python)! Before submitting your pull requests, please ensure that you __read the whole guidelines__. If you have any doubts about the contributing guide, please feel free to [state it clearly in an issue](https://github.com/TheAlgorithms/Python/issues/new) or ask the community on [Gitter](https://gitter.im/TheAlgorithms/community).
Welcome to [TheAlgorithms/Python](https://github.com/TheAlgorithms/Python)! Before submitting your pull requests, please ensure that you __read the whole guidelines carefully__. If you have any doubts about the contributing guide, please feel free to [state it clearly in an issue](https://github.com/TheAlgorithms/Python/issues/new) or ask the community on [Gitter](https://gitter.im/TheAlgorithms/community).

## Contributing

Expand All @@ -21,7 +21,7 @@ __Improving comments__ and __writing proper tests__ are also highly welcome.

### Contribution

We appreciate any contribution, from fixing a grammar mistake in a comment to implementing complex algorithms. Please read this section if you are contributing your work.
We appreciate any contribution, from fixing a grammatical mistake in a comment to implementing complex algorithms. Please read this section if you are contributing your work.

Your contribution will be tested by our [automated testing on GitHub Actions](https://github.com/TheAlgorithms/Python/actions) to save time and mental energy. After you have submitted your pull request, you should see the GitHub Actions tests start to run at the bottom of your submission page. If those tests fail, then click on the ___details___ button to read through the GitHub Actions output to understand the failure. If you do not understand, please leave a comment on your submission page and a community member will try to help.

Expand Down
4 changes: 0 additions & 4 deletions DIRECTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,6 @@
* [Geometry](geometry/geometry.py)
* [Graham Scan](geometry/graham_scan.py)
* [Jarvis March](geometry/jarvis_march.py)
* [Ramer Douglas Peucker](geometry/ramer_douglas_peucker.py)
* [Segment Intersection](geometry/segment_intersection.py)
* Tests
* [Test Graham Scan](geometry/tests/test_graham_scan.py)
* [Test Jarvis March](geometry/tests/test_jarvis_march.py)
Expand Down Expand Up @@ -525,7 +523,6 @@
* [Graphs Floyd Warshall](graphs/graphs_floyd_warshall.py)
* [Greedy Best First](graphs/greedy_best_first.py)
* [Greedy Min Vertex Cover](graphs/greedy_min_vertex_cover.py)
* [Johnson](graphs/johnson.py)
* [Kahns Algorithm Long](graphs/kahns_algorithm_long.py)
* [Kahns Algorithm Topo](graphs/kahns_algorithm_topo.py)
* [Karger](graphs/karger.py)
Expand All @@ -546,7 +543,6 @@
* [Strongly Connected Components](graphs/strongly_connected_components.py)
* [Tarjans Scc](graphs/tarjans_scc.py)
* Tests
* [Test Johnson](graphs/tests/test_johnson.py)
* [Test Min Spanning Tree Kruskal](graphs/tests/test_min_spanning_tree_kruskal.py)
* [Test Min Spanning Tree Prim](graphs/tests/test_min_spanning_tree_prim.py)

Expand Down
2 changes: 1 addition & 1 deletion digital_image_processing/convert_to_negative.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ def convert_to_negative(img):
neg = convert_to_negative(img)

# show result image
imshow("negative of original image", img)
imshow("negative of original image", neg)
waitKey(0)
destroyAllWindows()
7 changes: 1 addition & 6 deletions physics/newtons_second_law_of_motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,7 @@ def newtons_second_law_of_motion(mass: float, acceleration: float) -> float:
>>> newtons_second_law_of_motion(2.0, 1)
2.0
"""
force = 0.0
try:
force = mass * acceleration
except Exception:
return -0.0
return force
return mass * acceleration


if __name__ == "__main__":
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,14 @@ skip = """\
python_version = "3.14"

[tool.pytest]
ini_options.markers = [
"mat_ops: mark a test as utilizing matrix operations.",
]
ini_options.addopts = [
"--durations=10",
"--doctest-modules",
"--showlocals",
]
ini_options.markers = [
"mat_ops: mark a test as utilizing matrix operations.",
]

[tool.coverage]
report.omit = [
Expand Down
13 changes: 5 additions & 8 deletions sorts/tim_sort.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
from typing import Any


def binary_search(lst: list[Any], item: Any, start: int, end: int) -> int:
def binary_search(lst, item, start, end):
if start == end:
return start if lst[start] > item else start + 1
if start > end:
Expand All @@ -16,7 +13,7 @@ def binary_search(lst: list[Any], item: Any, start: int, end: int) -> int:
return mid


def insertion_sort(lst: list[Any]) -> list[Any]:
def insertion_sort(lst):
length = len(lst)

for index in range(1, length):
Expand All @@ -27,7 +24,7 @@ def insertion_sort(lst: list[Any]) -> list[Any]:
return lst


def merge(left: list[Any], right: list[Any]) -> list[Any]:
def merge(left, right):
if not left:
return right

Expand All @@ -40,7 +37,7 @@ def merge(left: list[Any], right: list[Any]) -> list[Any]:
return [right[0], *merge(left, right[1:])]


def tim_sort(lst: list[Any] | tuple[Any, ...] | str) -> list[Any]:
def tim_sort(lst):
"""
>>> tim_sort("Python")
['P', 'h', 'n', 'o', 't', 'y']
Expand All @@ -56,7 +53,7 @@ def tim_sort(lst: list[Any] | tuple[Any, ...] | str) -> list[Any]:
length = len(lst)
runs, sorted_runs = [], []
new_run = [lst[0]]
sorted_array: list[Any] = []
sorted_array = []
i = 1
while i < length:
if lst[i] < lst[i - 1]:
Expand Down