diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 62b62d0f6481..2bb8e1d69217 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/.github/workflows/devcontainer_ci.yml b/.github/workflows/devcontainer_ci.yml index e8cd040c1323..d1b81593866f 100644 --- a/.github/workflows/devcontainer_ci.yml +++ b/.github/workflows/devcontainer_ci.yml @@ -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 diff --git a/.github/workflows/directory_writer.yml b/.github/workflows/directory_writer.yml index 598cdfa5a371..deffbe9e364f 100644 --- a/.github/workflows/directory_writer.yml +++ b/.github/workflows/directory_writer.yml @@ -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 diff --git a/.github/workflows/project_euler.yml b/.github/workflows/project_euler.yml index ff61367974f3..591b2163cc1a 100644 --- a/.github/workflows/project_euler.yml +++ b/.github/workflows/project_euler.yml @@ -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: @@ -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: diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index d665d0fb9266..13df19c8d743 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -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 . diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index 7a8fc9460446..3f00094e0264 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -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: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b865f88350ea..39daf3dd7f88 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index aa6bff3ad1da..176dfaa76723 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 @@ -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. diff --git a/DIRECTORY.md b/DIRECTORY.md index daf71bab8162..ca454bd5fd82 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -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) @@ -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) @@ -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) diff --git a/digital_image_processing/convert_to_negative.py b/digital_image_processing/convert_to_negative.py index 9bf2d8f2c075..227aab51bc54 100644 --- a/digital_image_processing/convert_to_negative.py +++ b/digital_image_processing/convert_to_negative.py @@ -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() diff --git a/physics/newtons_second_law_of_motion.py b/physics/newtons_second_law_of_motion.py index 4149e2494f31..58336acb5c76 100644 --- a/physics/newtons_second_law_of_motion.py +++ b/physics/newtons_second_law_of_motion.py @@ -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__": diff --git a/pyproject.toml b/pyproject.toml index 0b0c3f5cfda4..34e099a46435 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 = [ diff --git a/sorts/tim_sort.py b/sorts/tim_sort.py index 2eeed88b7399..41ab4a10a87b 100644 --- a/sorts/tim_sort.py +++ b/sorts/tim_sort.py @@ -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: @@ -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): @@ -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 @@ -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'] @@ -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]: