Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
WIP Set_parent
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoeppe committed Aug 18, 2022
1 parent 402af5d commit 45245b1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
5 changes: 2 additions & 3 deletions src/sage/sets/condition_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
from sage.misc.cachefunc import cached_method
from sage.misc.misc import _stable_uniq
from sage.structure.element import Expression
from .set import Set, Set_base, Set_boolean_operators, Set_add_sub_operators
from .set import Set, Set_parent


class ConditionSet(Set_generic, Set_base, Set_boolean_operators, Set_add_sub_operators,
UniqueRepresentation):
class ConditionSet(Set_parent, UniqueRepresentation):
r"""
Set of elements of a universe that satisfy given predicates
Expand Down
22 changes: 15 additions & 7 deletions src/sage/sets/set.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ def Set(X=None, category=None):
If you need the functionality of mutable sets, use Python's
builtin set type.
OUTPUT:
- a :class:`~sage.sets.set.Set_parent`
EXAMPLES::
sage: X = Set(GF(9,'a'))
Expand Down Expand Up @@ -185,19 +189,17 @@ def Set(X=None, category=None):
sage: Set()
{}
"""
if isinstance(X, Set_parent) and category is None:
return X

if X is None:
X = []
elif isinstance(X, CategoryObject):
if isinstance(X, Set_generic) and category is None:
return X
elif X in Sets().Finite():
if X in Sets().Finite():
return Set_object_enumerated(X, category=category)
else:
return Set_object(X, category=category)

if isinstance(X, Element) and not isinstance(X, Set_base):
raise TypeError("Element has no defined underlying set")

try:
X = frozenset(X)
except TypeError:
Expand Down Expand Up @@ -434,8 +436,14 @@ def __sub__(self, X):
return self.difference(X)


class Set_parent(Set_generic, Set_base, Set_boolean_operators, Set_add_sub_operators):
r"""
Base class for sets that are parents and offer the full Set API
"""


@richcmp_method
class Set_object(Set_generic, Set_base, Set_boolean_operators, Set_add_sub_operators):
class Set_object(Set_parent):
r"""
A set attached to an almost arbitrary object.
Expand Down

0 comments on commit 45245b1

Please sign in to comment.