Skip to content

fix: correct argument order in fuzzy set union - #15273

Merged
cclauss merged 1 commit into
TheAlgorithms:masterfrom
Ant19801108:fix/fuzzy-union-arg-order
Sep 11, 2026
Merged

fix: correct argument order in fuzzy set union#15273
cclauss merged 1 commit into
TheAlgorithms:masterfrom
Ant19801108:fix/fuzzy-union-arg-order

Conversation

@Ant19801108

Copy link
Copy Markdown
Contributor

Description

Fixes #11871 — the fuzzy union method passed constructor arguments in the wrong order.

FuzzySet is declared as (name, left_boundary, peak, right_boundary), but union called FuzzySet(name, min_left, max_right, avg_peak), so peak and right_boundary were swapped. This swaps the last two arguments and corrects both doctests.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • python -m doctest fuzzy_logic/fuzzy_operations.py passes (22 doctests, 0 failures).

FuzzySet is declared as (name, left_boundary, peak, right_boundary), but union passed (name, min_left, max_right, avg_peak), so peak and right_boundary were swapped. Swap the last two arguments and update both doctests.

Fixes TheAlgorithms#11871

Signed-off-by: Ant19801108 <Ant19801108@users.noreply.github.com>
@cclauss

cclauss commented Sep 11, 2026

Copy link
Copy Markdown
Member

@priya-sundaram-dev please evaluate this as a fix for #11871.

If it is not the right fix then please create a pull request that closes this pull request and 11871.

@priya-sundaram-dev

Copy link
Copy Markdown
Contributor

Confirmed — this is the right fix for #11871. ✅

The dataclass is declared FuzzySet(name, left_boundary, peak, right_boundary), but the old union passed max(self.right_boundary, other.right_boundary) in the peak slot and (self.peak + other.peak) / 2 in the right_boundary slot. Swapping those two lines puts each value in its correct field; the semantics (min of lefts, avg of peaks, max of rights) are unchanged.

Verified on the PR head:

  • python3 -m doctest fuzzy_logic/fuzzy_operations.py -v22 tests in 11 items, 22 passed, 0 failed.
  • Spot-checked the doctest: FuzzySet("a",0.1,0.2,0.3).union(FuzzySet("b",0.4,0.5,0.6))left=min(0.1,0.4)=0.1, peak=(0.2+0.5)/2=0.35, right=max(0.3,0.6)=0.6, matching the corrected expected output.

Diff is minimal and scoped to the bug. LGTM — this closes #11871.

@cclauss cclauss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work. Thanks to both of you.

@cclauss
cclauss merged commit d031e8f into TheAlgorithms:master Sep 11, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

incorrect union method implementation in fuzzy operations

3 participants