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

Set() comparison for (non)equality broken #35178

Closed
2 tasks done
dimpase opened this issue Feb 23, 2023 · 1 comment
Closed
2 tasks done

Set() comparison for (non)equality broken #35178

dimpase opened this issue Feb 23, 2023 · 1 comment

Comments

@dimpase
Copy link
Member

dimpase commented Feb 23, 2023

Is there an existing issue for this?

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.

Did you read the documentation and troubleshoot guide?

  • I have read the documentation and troubleshoot guide

Environment

** Sage 10.0.betas ** and earlier

Steps To Reproduce

sage: L = {0}
sage: L == Set(L)
True
sage: L != Set(L)
True

Expected Behavior

!= should be the negation of ==

Actual Behavior

both == and != comparisons being True is pretty bad

Additional Information

No response

@jhpalmieri
Copy link
Member

This might fix it:

diff --git a/src/sage/sets/set.py b/src/sage/sets/set.py
index b988525a880..5b7ab78be2e 100644
--- a/src/sage/sets/set.py
+++ b/src/sage/sets/set.py
@@ -1064,7 +1064,8 @@ class Set_object_enumerated(Set_object):
         """
         if not isinstance(other, Set_object_enumerated):
             if isinstance(other, (set, frozenset)):
-                return self.set() == other
+                if self.set() == other:
+                    return rich_to_bool(op, 0)
             return NotImplemented
         if self.set() == other.set():
             return rich_to_bool(op, 0)

vbraun pushed a commit that referenced this issue Mar 26, 2023
    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes #1234" use "Introduce new method to
calculate 1+1"
-->
### Description
Fixes Set inequality (issue #35178)

<!-- Describe your changes here in detail -->
<!-- Why is this change required? What problem does it solve? -->
<!-- If it resolves an open issue, please link to the issue here. For
example "Closes #1337" -->

### Changes

Details at #35178

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->

- [x] I have made sure that the title is self-explanatory and the
description concisely explains the PR.
- [x] I have linked an issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation accordingly.

### ⌛ Dependencies

(none)
    
URL: #35197
Reported by: John H. Palmieri
Reviewer(s): Matthias Köppe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants