- Add astral-sh/uv-pre-commit (uv-lock) so uv.lock stays in sync with
pyproject.toml automatically instead of relying on manual relocks.
- Replace 'python-version: 3.14' with 'python-version-file: pyproject.toml'
in every workflow that uses actions/setup-python (build, project_euler,
sphinx, directory_writer), making requires-python the single source of
truth for the interpreter version.
* Clean up the fractals directory
Add a directory README plus two new, fully doctested fractal generators.
- README.md: overview table of every fractal, how to run them, and further
reading. Distinguishes the visual (turtle/matplotlib) demos from the
pure-computation ones that run under doctest in CI.
- sierpinski_carpet.py: integer-arithmetic Sierpinski carpet. is_filled(),
generate_carpet() and count_filled_cells() are all doctested; no display
needed.
- barnsley_fern.py: the Barnsley fern iterated function system. transform(),
choose_transformation() and generate_fern() are doctested and made
deterministic via an optional seed; matplotlib plotting is optional and
guarded behind __main__.
* fractals: inline demo code under __main__ (address keeper-bot doctest note)
* Clean up the networking_flow directory
- Add networking_flow/README.md covering max-flow / min-cut, with a
file-by-file table and guidance on which algorithm to use.
- minimum_cut.py: add a module docstring with a Wikipedia URL, type
hints, and corner-case doctests; work on a copy so the input graph is
no longer mutated.
- Add dinic.py: Dinic's algorithm (BFS level graph + DFS blocking flow),
adjacency-list based so it handles parallel edges and sparse graphs.
- Add push_relabel.py: the Goldberg-Tarjan push-relabel (preflow) method
with highest-label selection.
Both new algorithms are fully type-hinted, documented with a Wikipedia
reference, and validated by doctests; their output was cross-checked
against ford_fulkerson.py on thousands of random graphs.
* Address review: drop __future__ import, use descriptive names, apply README wording
* Clean up the audio_filters directory
- Restore equal_loudness_filter.py: replace the third-party 'yulewalker'
dependency with a dependency-free 'yulewalk' implementation (numpy + scipy
only, both already project dependencies) so the filter works again.
- Fix two bugs in iir_filter.set_coefficients: the a0-omitted branch never
triggered, and the b_coeffs length error reported len(a_coeffs).
- Add doctests covering valid and erroneous inputs (coefficient-length errors,
yulewalk input validation).
- Add Wikipedia URLs to the docstrings that were missing them.
- Add two new RBJ Audio EQ Cookbook filters: make_notch and make_bandpass_peak.
- Rewrite audio_filters/README.md to document every file and filter.
* audio_filters: clarify make_notch, document biquad notation, tighten set_coefficients guard
- Add a shared notation guide to butterworth_filter so the single-letter
RBJ-cookbook names (w0/alpha/a0..a2/b0..b2) are self-explanatory across
every filter instead of diverging in one function.
- Comment make_notch's feed-forward/feed-back sections in plain English.
- set_coefficients only fills the optional a_0 when exactly one coefficient
is missing, so genuinely too-short inputs raise with their real length
(new regression doctest).
The docstring incorrectly referenced Sylvester's sequence (a copy-paste
error from maths/sylvester_sequence.py) and used param names that did
not match the actual function signature.
Fixes#15013
Co-authored-by: kumarsatyam9378-art <kumarsatyam9378@gmail.com>
* fix: sub-interval midpoint formula in ternary search
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* fix: raise ValueError in encode() for non-lowercase input
encode() previously accepted uppercase letters, digits, and other
non-lowercase characters silently, producing incorrect/out-of-range
values (e.g. negative numbers for uppercase letters) instead of
failing. Add input validation using str.islower() and str.isalpha()
to raise a ValueError when the input isn't purely lowercase a-z.
Added a doctest covering the new error case.
* resolved doctest
* Fix Ruff 0.16 lint failures
* Enhance encode function error handling examples
Update error handling in encode function to include examples for mixed case and invalid characters.
* Fix indentation in test_cancer_data function
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Fix invalid Python 2 syntax in except clause
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update ruff-pre-commit version to v0.16.1
* Fix indentation in test_cancer_data function
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* docs: expand bubble sort docstrings with algorithm explanation
Add a concise description of how bubble sort works (repeated
adjacent comparisons/swaps until a pass makes no swaps) and note
time/space complexity for both the iterative and recursive
implementations. No behavior changes; all existing doctests pass.
* Fix Ruff 0.16 lint failures
* S310
---------
Co-authored-by: Christian Clauss <cclauss@me.com>
* Fix typos in Johnson's algorithm (nd -> and) to pass codespell
* Rename type aliases and h parameter to follow snake_case and descriptive naming
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
---------
Co-authored-by: John Law <johnlaw.po@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Add type hints to tim_sort.py, relates to #14457
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix ruff PYI041 error: use float instead of int | float
* Fix mypy error: support str and tuple inputs as defined in doctests
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix ruff E501: wrap binary_search parameters to respect 88 char limit
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Refactor generics to use Python 3.12 type parameter syntax (PEP 695)
* Use Any from typing to resolve mypy list unpacking bugs
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
* Add latitude and longitude validation with doctests
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update lamberts_ellipsoidal_distance.py
---------
Co-authored-by: Pamela Cano <pamelacano@MacBook-Pro-de-Pamela.local>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
* add some doctests to algos in backtracking
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
* Fix doctests in factorial_recursive function
The doctests in factorial_recursive were calling factorial() instead of factorial_recursive(). This fix ensures that the tests correctly validate the factorial_recursive function itself.
* Update factorial.py
---------
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
Fixed bug in bubble_sort_recursive docstring where the doctest was calling bubble_sort_iterative([]) instead of bubble_sort_recursive([]). This was a copy-paste error that would cause the doctest to pass even if bubble_sort_recursive had issues with empty lists.
Change:
- Line 71: Changed '>>> bubble_sort_iterative([])' to '>>> bubble_sort_recursive([])'
This ensures the doctest properly validates the recursive implementation.
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
* Fix return type description in bubble_sort.py
Better (clearer, standard phrasing):
:return: the same collection ordered in ascending order
* Update bubble_sort.py
---------
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
* Use TypeError for non-string input in count_vowels
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix docstring and improve input validation in kth_lexicographic_permutation
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update kth_lexicographic_permutation.py
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
* Fix incorrect doctest references in fibonacci functions
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
* Improve documentation for linear search algorithm
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Replace asserts with explicit validation in modular_division
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update linear_search.py
---------
Co-authored-by: Anusha-DeviE <itzanushadevi@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
* docs: refine docstring and simplify reverse_letters implementation
Updated the docstring for clarity and improved the logic for reversing words.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update reverse_letters.py
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
* Use TypeError for non-string input in count_vowels
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix docstring and improve input validation in kth_lexicographic_permutation
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Handle gcd(0, 0) edge case
* Update kth_lexicographic_permutation.py
* Update count_vowels.py
* Update greatest_common_divisor.py
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
* Add type hints and improve code quality for generate_parentheses_iterative
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix line length issue
* Update generate_parentheses_iterative.py
* Update generate_parentheses_iterative.py
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>