Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FuzzySet Class for Triangular Fuzzy Sets #11036

Merged
merged 49 commits into from
Oct 28, 2023
Merged

Add FuzzySet Class for Triangular Fuzzy Sets #11036

merged 49 commits into from
Oct 28, 2023

Conversation

Shreya123714
Copy link
Contributor

@Shreya123714 Shreya123714 commented Oct 27, 2023

###hacktoberfest

Description:

This pull request introduces the FuzzySet class, designed to represent and manipulate triangular fuzzy sets widely used in fuzzy logic and control systems. The creation of this class was motivated by the need for a versatile tool for fuzzy logic operations.

Features:

  • FuzzySet Class: The FuzzySet class is defined with attributes such as name, a (left boundary), b (peak), and c (right boundary) to describe the fuzzy set. It also provides methods for membership calculation, union, intersection, and complement operations.

Functionality:

  • Membership Calculation: The membership method calculates the membership value of an input x in the fuzzy set, handling cases where x is outside the fuzzy set boundaries.

  • Union and Intersection: The union and intersection methods allow users to calculate the union and intersection of fuzzy sets, respectively. These operations create new fuzzy sets based on the input fuzzy sets.

  • Complement (Negation): The complement method computes the complement (negation) of the fuzzy set, making it a valuable addition for fuzzy logic operations.

  • Plotting: The plot method generates a visual representation of the membership function for effective visualization and analysis.

Testing:

I have added a comprehensive test suite for the FuzzySet class to ensure its correctness and robustness. The tests cover various scenarios, including both valid and erroneous input values.

Example Usage:

The example usage section demonstrates how to create FuzzySet instances, perform operations, and visualize the membership functions of fuzzy sets. It provides practical insights into the class's capabilities.

I welcome your review and feedback, and I'm open to further improvements. Transparency is important, and I have designed this class based on existing knowledge and references from reputable sources.

@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Oct 27, 2023
@Shreya123714
Copy link
Contributor Author

wait I will fix this..

@algorithms-keeper algorithms-keeper bot added require descriptive names This PR needs descriptive function and/or variable names require tests Tests [doctest/unittest/pytest] are required require type hints https://docs.python.org/3/library/typing.html labels Oct 28, 2023
Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

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 review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to 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.

elif self.b < x < self.c:
return (self.c - x) / (self.c - self.b)

def union(self, other):

Choose a reason for hiding this comment

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

As there is no test file in this pull request nor any test function or class in the file fuzzy_logic/fuzzy_operations.py, please provide doctest for the function union

Please provide return type hint for the function: union. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: other


plt.plot(x, y, label=self.name)

def __str__(self):

Choose a reason for hiding this comment

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

As there is no test file in this pull request nor any test function or class in the file fuzzy_logic/fuzzy_operations.py, please provide doctest for the function __str__

Please provide return type hint for the function: __str__. If the function does not return a value, please provide the type hint as: def function() -> None:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Oct 28, 2023
@algorithms-keeper algorithms-keeper bot removed the tests are failing Do not merge until tests pass label Oct 28, 2023
@Shreya123714
Copy link
Contributor Author

Hey can you put a Hacktoberfest label into this pull request??

Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

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 review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to 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.

self.right_boundary = right_boundary # Right boundary


def membership(self, x):

Choose a reason for hiding this comment

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

As there is no test file in this pull request nor any test function or class in the file fuzzy_logic/fuzzy_operations.py, please provide doctest for the function membership

Please provide return type hint for the function: membership. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide descriptive name for the parameter: x

Please provide type hint for the parameter: x

elif self.b < x < self.c:
return (self.c - x) / (self.c - self.b)

def union(self, other):

Choose a reason for hiding this comment

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

As there is no test file in this pull request nor any test function or class in the file fuzzy_logic/fuzzy_operations.py, please provide doctest for the function union

Please provide return type hint for the function: union. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: other

(self.b + other.b) / 2,
)

def intersection(self, other):

Choose a reason for hiding this comment

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

As there is no test file in this pull request nor any test function or class in the file fuzzy_logic/fuzzy_operations.py, please provide doctest for the function intersection

Please provide return type hint for the function: intersection. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: other

(self.b + other.b) / 2,
)

def complement(self):

Choose a reason for hiding this comment

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

As there is no test file in this pull request nor any test function or class in the file fuzzy_logic/fuzzy_operations.py, please provide doctest for the function complement

Please provide return type hint for the function: complement. If the function does not return a value, please provide the type hint as: def function() -> None:

complement_name = f"¬{self.name}"
return FuzzySet(complement_name, 1 - self.c, 1 - self.a, 1 - self.b)

def plot(self):

Choose a reason for hiding this comment

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

As there is no test file in this pull request nor any test function or class in the file fuzzy_logic/fuzzy_operations.py, please provide doctest for the function plot

Please provide return type hint for the function: plot. If the function does not return a value, please provide the type hint as: def function() -> None:


plt.plot(x, y, label=self.name)

def __str__(self):

Choose a reason for hiding this comment

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

As there is no test file in this pull request nor any test function or class in the file fuzzy_logic/fuzzy_operations.py, please provide doctest for the function __str__

Please provide return type hint for the function: __str__. If the function does not return a value, please provide the type hint as: def function() -> None:

@algorithms-keeper algorithms-keeper bot added tests are failing Do not merge until tests pass and removed tests are failing Do not merge until tests pass labels Oct 28, 2023
This was referenced Oct 28, 2023
@algorithms-keeper algorithms-keeper bot removed the require tests Tests [doctest/unittest/pytest] are required label Oct 28, 2023
Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

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 review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to 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.

self.peak = peak # Peak value
self.right_boundary = right_boundary # Right boundary

def membership(self, x):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: membership. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide descriptive name for the parameter: x

Please provide type hint for the parameter: x

elif self.b < x < self.c:
return (self.c - x) / (self.c - self.b)

def union(self, other):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: union. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: other

(self.b + other.b) / 2,
)

def intersection(self, other):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: intersection. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: other

(self.b + other.b) / 2,
)

def complement(self):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: complement. If the function does not return a value, please provide the type hint as: def function() -> None:

complement_name = f"¬{self.name}"
return FuzzySet(complement_name, 1 - self.c, 1 - self.a, 1 - self.b)

def plot(self):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: plot. If the function does not return a value, please provide the type hint as: def function() -> None:


plt.plot(x, y, label=self.name)

def __str__(self):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: __str__. If the function does not return a value, please provide the type hint as: def function() -> None:

@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Oct 28, 2023
Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

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 review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to 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.

# self.peak = peak # Peak value
# self.right_boundary = right_boundary # Right boundary

def membership(self, x: float) -> float:

Choose a reason for hiding this comment

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

Please provide descriptive name for the parameter: x

elif self.peak < x < self.right_boundary:
return (self.right_boundary - x) / (self.right_boundary - self.peak)

def union(self, other) -> "FuzzySet":

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: other

(self.peak + other.peak) / 2,
)

def intersection(self, other) -> "FuzzySet":

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: other

1 - self.peak,
)

def plot(self):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: plot. If the function does not return a value, please provide the type hint as: def function() -> None:


plt.plot(x, y, label=self.name)

def __str__(self):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: __str__. If the function does not return a value, please provide the type hint as: def function() -> None:

Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

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 review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to 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.

# self.peak = peak # Peak value
# self.right_boundary = right_boundary # Right boundary

def membership(self, x: float) -> float:

Choose a reason for hiding this comment

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

Please provide descriptive name for the parameter: x

elif self.peak < x < self.right_boundary:
return (self.right_boundary - x) / (self.right_boundary - self.peak)

def union(self, other) -> "FuzzySet":

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: other

(self.peak + other.peak) / 2,
)

def intersection(self, other) -> "FuzzySet":

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: other

1 - self.peak,
)

def plot(self):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: plot. If the function does not return a value, please provide the type hint as: def function() -> None:


plt.plot(x, y, label=self.name)

def __str__(self):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: __str__. If the function does not return a value, please provide the type hint as: def function() -> None:

Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

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 review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to 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.

# self.peak = peak # Peak value
# self.right_boundary = right_boundary # Right boundary

def membership(self, x: float) -> float:

Choose a reason for hiding this comment

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

Please provide descriptive name for the parameter: x

elif self.peak < x < self.right_boundary:
return (self.right_boundary - x) / (self.right_boundary - self.peak)

def union(self, other) -> "FuzzySet":

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: other

(self.peak + other.peak) / 2,
)

def intersection(self, other) -> "FuzzySet":

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: other

1 - self.peak,
)

def plot(self):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: plot. If the function does not return a value, please provide the type hint as: def function() -> None:


plt.plot(x, y, label=self.name)

def __str__(self):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: __str__. If the function does not return a value, please provide the type hint as: def function() -> None:

@Shreya123714 Shreya123714 requested a review from cclauss October 28, 2023 16:57
Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

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 review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to 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.

peak: float
right_boundary: float

def membership(self, x: float) -> float:

Choose a reason for hiding this comment

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

Please provide descriptive name for the parameter: x

elif self.peak < x < self.right_boundary:
return (self.right_boundary - x) / (self.right_boundary - self.peak)

def union(self, other) -> "FuzzySet":

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: other

(self.peak + other.peak) / 2,
)

def intersection(self, other) -> "FuzzySet":

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: other

1 - self.peak,
)

def plot(self):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: plot. If the function does not return a value, please provide the type hint as: def function() -> None:


plt.plot(x, y, label=self.name)

def __str__(self):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: __str__. If the function does not return a value, please provide the type hint as: def function() -> None:

@cclauss
Copy link
Member

cclauss commented Oct 28, 2023

Please give me time to review the code without changing it.

Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

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 review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to 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.

peak: float
right_boundary: float

def membership(self, x: float) -> float:

Choose a reason for hiding this comment

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

Please provide descriptive name for the parameter: x

elif self.peak < x < self.right_boundary:
return (self.right_boundary - x) / (self.right_boundary - self.peak)

def union(self, other) -> "FuzzySet":

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: other

(self.peak + other.peak) / 2,
)

def intersection(self, other) -> "FuzzySet":

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: other

1 - self.peak,
)

def plot(self):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: plot. If the function does not return a value, please provide the type hint as: def function() -> None:


plt.plot(x, y, label=self.name)

def __str__(self):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: __str__. If the function does not return a value, please provide the type hint as: def function() -> None:

Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

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 review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to 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.

1 - self.peak,
)

def intersection(self, other) -> FuzzySet:

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: other

(self.peak + other.peak) / 2,
)

def membership(self, x: float) -> float:

Choose a reason for hiding this comment

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

Please provide descriptive name for the parameter: x

msg = f"Invalid value {x} for fuzzy set {self}"
raise ValueError(msg)

def union(self, other) -> FuzzySet:

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: other

(self.peak + other.peak) / 2,
)

def plot(self):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: plot. If the function does not return a value, please provide the type hint as: def function() -> None:

Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

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 review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to 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.

1 - self.peak,
)

def intersection(self, other) -> FuzzySet:

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: other

(self.peak + other.peak) / 2,
)

def membership(self, x: float) -> float:

Choose a reason for hiding this comment

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

Please provide descriptive name for the parameter: x

msg = f"Invalid value {x} for fuzzy set {self}"
raise ValueError(msg)

def union(self, other) -> FuzzySet:

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: other

(self.peak + other.peak) / 2,
)

def plot(self):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: plot. If the function does not return a value, please provide the type hint as: def function() -> None:

@Shreya123714
Copy link
Contributor Author

Please give me time to review the code without changing it.

Hey, while you do that , can I fix few typo error , and make the code more descriptive,
I am new to open source , now after reading the bot's suggestion i found few loop holes like " function hint "problem,

@algorithms-keeper algorithms-keeper bot removed the tests are failing Do not merge until tests pass label Oct 28, 2023
Copy link
Member

@cclauss cclauss left a comment

Choose a reason for hiding this comment

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

Looks cool but I do not get all the details...

I moved some tests from fuzzy_logic/test_fuzzy_logic.py into doctests and removed that file. I did several updates to the main file to make it pass our tests. If it does so then I will approve and merge it. If you see missing tests or other errors, please open a new pull request with changes and @mention me on it.

@algorithms-keeper algorithms-keeper bot removed the awaiting reviews This PR is ready to be reviewed label Oct 28, 2023
Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

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 review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to 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.

@cclauss cclauss merged commit f243631 into TheAlgorithms:master Oct 28, 2023
@Shreya123714
Copy link
Contributor Author

Looks cool but I do not get all the details...

I moved some tests from fuzzy_logic/test_fuzzy_logic.py into doctests and removed that file. I did several updates to the main file to make it pass our tests. If it does so then I will approve and merge it. If you see missing tests or other errors, please open a new pull request with changes and @mention me on it.

same , my PR started failing, once I added that test_fuzzy_logic.py , i did so to remove the " required test " label,
But sure , I shall work on it 😄😄😄(●'◡'●) Thank you for merging the PR , Thank you Thank you Thank You so MUCH!!!!!!!!!!!!

@cclauss
Copy link
Member

cclauss commented Oct 28, 2023

pytest not finding tests is often about not having an empty __init__.py file in the same directory. In this repo, we tend to use doctest because the tests live with the code and it is often easier for new contributions to understand doctests.

Please feel free to create pull requests to make this code what you want it to be.

@cclauss
Copy link
Member

cclauss commented Oct 28, 2023

Also, Python set()

Enable the following notation:
x in set # membership but must return a bool --> contains(self, item)
set & other # intersection --> and(self, other)
set | other # union --> or(self, other)
~set # complement --> invert(self)

If you implemented FuzzySet.__contains__() you could enable x in fuzzy_set for membership.
If you implemented FuzzySet.__and__() you could enable fuzzy_set_a & fuzzy_set_b for intersection.
If you implemented FuzzySet.__or__() you could enable fuzzy_set_a | fuzzy_set_b for union.
If you implemented FuzzySet.__contains__() you could enable ~fuzzy_set for complement.

https://rszalski.github.io/magicmethods/#appendix1

sedatguzelsemme pushed a commit to sedatguzelsemme/Python that referenced this pull request Sep 15, 2024
* Added Opertation for triangular fuzzy sets

* Added Sources

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix the bug , for which test were failing

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add type hints and improve parameter names

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add Test For fuzzy_operations.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix the bug in fuzzy_operations.py

* Add test_fuzzy_logic.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix the bug in fuzzy_operations.py & deleted test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fixed the typo error

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Again done

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* corrected wrong intendation due to which test fail

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* bug fixed

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add test_fuzzy_logic

* Modified fuzzy_operations.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fixed the bug, made a FuzzySet dataclass

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Replaced assertEqual of unittest to assert python

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* lets see

* Changed test

* orderd the import statements

* Add docstring and dataclass the FuzzySet

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update fuzzy_operations.py

* Delete fuzzy_logic/test_fuzzy_logic.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* https://en.wikipedia.org/wiki/Fuzzy_set

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
@isidroas isidroas mentioned this pull request Jan 25, 2025
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
require descriptive names This PR needs descriptive function and/or variable names require type hints https://docs.python.org/3/library/typing.html
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants