Repository: sympy/sympy

Issue:
Combinatorics Subset is a subclass of Basic but arguments are not stored in the args attribute
The `Subset` class in `sympy/combinatorics/subsets` is a subclass of `Basic` but its arguments are not stored in the `args` attribute. This means that it does not behave as a `Basic` since `subset=subset.func(*subset.args) ` is not satisfied (see also https://github.com/sympy/sympy/issues/22310). 

This class should then instead subclass from `Atom` if it wishes to store its arguments elsewhere than `.args`. I assume there is a good reason the arguments are stored differently in the first place. 

PR coming as soon as tests pass locally.

Discussion:

Patch:
diff --git a/sympy/combinatorics/subsets.py b/sympy/combinatorics/subsets.py
index 57bec6a326..5600a3ec6d 100644
--- a/sympy/combinatorics/subsets.py
+++ b/sympy/combinatorics/subsets.py
@@ -1,10 +1,9 @@
 from itertools import combinations
 
 from sympy.combinatorics.graycode import GrayCode
-from sympy.core import Basic
 
 
-class Subset(Basic):
+class Subset():
     """
     Represents a basic subset object.
 
@@ -59,11 +58,20 @@ def __new__(cls, subset, superset):
             if elem not in superset:
                 raise ValueError('The superset provided is invalid as it does '
                                  'not contain the element {}'.format(elem))
-        obj = Basic.__new__(cls)
+        obj = object.__new__(cls)
         obj._subset = subset
         obj._superset = superset
         return obj
 
+    def __eq__(self, other):
+        """Return a boolean indicating whether a == b on the basis of
+        whether both objects are of the class Subset and if the values
+        of the subset and superset attributes are the same.
+        """
+        if not isinstance(other, Subset):
+            return NotImplemented
+        return self.subset == other.subset and self.superset == other.superset
+
     def iterate_binary(self, k):
         """
         This is a helper function. It iterates over the


Test patch:
diff --git a/sympy/combinatorics/tests/test_subsets.py b/sympy/combinatorics/tests/test_subsets.py
index a2cff52a89..1d50076da1 100644
--- a/sympy/combinatorics/tests/test_subsets.py
+++ b/sympy/combinatorics/tests/test_subsets.py
@@ -54,6 +54,8 @@ def test_subset():
     raises(ValueError, lambda: Subset(['a'], ['b', 'c']))
     raises(ValueError, lambda: Subset.subset_from_bitlist(['a', 'b'], '010'))
 
+    assert Subset(['a'], ['a', 'b']) != Subset(['b'], ['a', 'b'])
+    assert Subset(['a'], ['a', 'b']) != Subset(['a'], ['a', 'c'])
 
 def test_ksubsets():
     assert list(ksubsets([1, 2, 3], 2)) == [(1, 2), (1, 3), (2, 3)]
diff --git a/sympy/core/tests/test_args.py b/sympy/core/tests/test_args.py
index f2188b02bf..a090adef68 100644
--- a/sympy/core/tests/test_args.py
+++ b/sympy/core/tests/test_args.py
@@ -500,12 +500,6 @@ def test_sympy__combinatorics__graycode__GrayCode():
     assert _test_args(GrayCode(3, rank=1))
 
 
-def test_sympy__combinatorics__subsets__Subset():
-    from sympy.combinatorics.subsets import Subset
-    assert _test_args(Subset([0, 1], [0, 1, 2, 3]))
-    assert _test_args(Subset(['c', 'd'], ['a', 'b', 'c', 'd']))
-
-
 def test_sympy__combinatorics__permutations__Permutation():
     from sympy.combinatorics.permutations import Permutation
     assert _test_args(Permutation([0, 1, 2, 3]))