TLC for fuzzy_logic/: restore disabled demo dependency-free + add README - #15166
Merged
Merged
Conversation
- Restore fuzzy_operations.py.DISABLED.txt as fuzzy_set_operations.py, rewritten to drop the scikit-fuzzy dependency (NumPy only). Implements the Zadeh operators on sampled membership vectors: union, intersection, complement, difference, algebraic sum/product, bounded sum/difference, plus a triangular_membership helper. Every function has doctests; the __main__ block reproduces the original 'young vs. middle-aged' demo and degrades gracefully when matplotlib is absent. - Add fuzzy_logic/README.md covering both modules with Wikipedia links and a runnable example. - Remove the obsolete .DISABLED.txt (its intent is now the working module). Credit to Jigyasa Gandhi (original scikit-fuzzy demo) and @Shreya123714 (FuzzySet). Passes pytest --doctest-modules, ruff check, ruff format --check.
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
Member
|
I agree with @algorithms-keeper that single-letter names for function parameters are not self-documenting for the caller. |
cclauss
reviewed
Sep 2, 2026
Address review on TheAlgorithms#15166: - rename single-letter params (x->grid, a/b->membership_a/membership_b, fuzzy_complement arg -> membership) per algorithms-keeper + cclauss - drop 'from __future__ import annotations' (repo is Python 3.14t-only)
Address review on TheAlgorithms#15166: - rename single-letter params (x->grid, a/b->membership_a/membership_b, fuzzy_complement arg -> membership) per algorithms-keeper + cclauss - drop 'from __future__ import annotations' (repo is Python 3.14t-only)
Contributor
Author
|
Done — pushed in bbef392:
|
cclauss
enabled auto-merge (squash)
September 3, 2026 04:46
cclauss
approved these changes
Sep 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your change:
TLC pass on
fuzzy_logic/— the first directory from the shortlist in #15081 (last new contribution 2024-09, 2 files, no README). Starting here since it has the same "restore a disabled file + add tests/README/URLs" shape as theaudio_filters/exercise (#15087).What this does:
fuzzy_operations.py.DISABLED.txtdependency-free. It was disabled because it imported the third-partyscikit-fuzzy(import skfuzzy). I rewrote it asfuzzy_set_operations.pyusing NumPy only (already inpyproject.toml). It implements the classic Zadeh operators on sampled membership vectors — union, intersection, complement, difference, algebraic sum/product, bounded sum/difference — plus atriangular_membershiphelper.__main__-only matplotlib demo. The__main__block still reproduces the original "young vs. middle-aged" figure and degrades gracefully (prints a summary) when matplotlib isn't installed.fuzzy_logic/README.mdcovering both modules, with Wikipedia links and a runnable example, and explaining how the two files complement each other (fuzzy_operations.pykeeps the parametric triangular representation;fuzzy_set_operations.pyworks on arbitrary sampled membership shapes)..DISABLED.txtnow that its intent lives in a working, tested module.Credit kept to Jigyasa Gandhi (original scikit-fuzzy demo) and @Shreya123714 (the
FuzzySetclass).Verified locally:
pytest --doctest-modules fuzzy_logic/(15 passed),ruff check,ruff format --checkall pass.Relates to #15081.
Checklist: