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

Commit

Permalink
ConditionSet: In doctests, do not rename ZZ^2 etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Jul 8, 2021
1 parent 0f60232 commit 69d045a
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/sage/sets/condition_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ def _repr_(self):
t
sage: ZeroDimButNotNullary = ConditionSet(ZZ^0, t > 0, vars=("q"))
sage: ZeroDimButNotNullary._repr_()
'{ q ∈ Ambient free module of rank 0 over the principal ideal domain Integer Ring : t > 0 }'
'{ q ∈ Ambient free module of rank 0
over the principal ideal domain Integer Ring : t > 0 }'
"""
s = "{ "
names = self.variable_names()
Expand Down Expand Up @@ -323,9 +324,9 @@ def _call_predicate(self, predicate, element):
sage: TripleDigits = ZZ^3
sage: predicate(x, y, z) = sqrt(x^2 + y^2 + z^2) < 12; predicate
(x, y, z) |--> sqrt(x^2 + y^2 + z^2) < 12
sage: TripleDigits.rename('ZZ^3')
sage: SmallTriples = ConditionSet(ZZ^3, predicate); SmallTriples
{ (x, y, z) ∈ ZZ^3 : sqrt(x^2 + y^2 + z^2) < 12 }
{ (x, y, z) ∈ Ambient free module of rank 3 over the principal
ideal domain Integer Ring : sqrt(x^2 + y^2 + z^2) < 12 }
sage: predicate = SmallTriples._predicates[0]
sage: element = TripleDigits((1, 2, 3))
sage: SmallTriples._call_predicate(predicate, element)
Expand Down Expand Up @@ -356,9 +357,9 @@ def _an_element_(self):
sage: TripleDigits = ZZ^3
sage: predicate(x, y, z) = sqrt(x^2 + y^2 + z^2) < 12; predicate
(x, y, z) |--> sqrt(x^2 + y^2 + z^2) < 12
sage: TripleDigits.rename('ZZ^3')
sage: SmallTriples = ConditionSet(ZZ^3, predicate); SmallTriples
{ (x, y, z) ∈ ZZ^3 : sqrt(x^2 + y^2 + z^2) < 12 }
{ (x, y, z) ∈ Ambient free module of rank 3 over the principal
ideal domain Integer Ring : sqrt(x^2 + y^2 + z^2) < 12 }
sage: SmallTriples.an_element() # indirect doctest
(1, 0, 0)
"""
Expand Down Expand Up @@ -389,9 +390,9 @@ def _sympy_(self):
sage: predicate(x, y, z) = sqrt(x^2 + y^2 + z^2) < 12; predicate
(x, y, z) |--> sqrt(x^2 + y^2 + z^2) < 12
sage: (ZZ^3).rename('ZZ^3')
sage: SmallTriples = ConditionSet(ZZ^3, predicate); SmallTriples
{ (x, y, z) ∈ ZZ^3 : sqrt(x^2 + y^2 + z^2) < 12 }
{ (x, y, z) ∈ Ambient free module of rank 3 over the principal
ideal domain Integer Ring : sqrt(x^2 + y^2 + z^2) < 12 }
sage: ST = SmallTriples._sympy_(); ST
ConditionSet((x, y, z), sqrt(x**2 + y**2 + z**2) < 12,
ProductSet(Integers, Integers, Integers))
Expand Down Expand Up @@ -444,14 +445,14 @@ def intersection(self, X):
EXAMPLES::
sage: (ZZ^2).rename("ZZ^2"); (QQ^2).rename("QQ^2")
sage: in_small_oblong(x, y) = x^2 + 3 * y^2 <= 42
sage: SmallOblongUniverse = ConditionSet(QQ^2, in_small_oblong)
sage: SmallOblongUniverse
{ (x, y) ∈ QQ^2 : x^2 + 3*y^2 <= 42 }
{ (x, y) ∈ Vector space of dimension 2 over Rational Field : x^2 + 3*y^2 <= 42 }
sage: parity_check(x, y) = abs(sin(pi/2*(x + y))) < 1/1000
sage: EvenUniverse = ConditionSet(ZZ^2, parity_check); EvenUniverse
{ (x, y) ∈ ZZ^2 : abs(sin(1/2*pi*x + 1/2*pi*y)) < (1/1000) }
{ (x, y) ∈ Ambient free module of rank 2 over the principal ideal
domain Integer Ring : abs(sin(1/2*pi*x + 1/2*pi*y)) < (1/1000) }
sage: SmallOblongUniverse & EvenUniverse
{ (x, y) ∈ Free module of degree 2 and rank 2 over Integer Ring
Echelon basis matrix:
Expand All @@ -463,11 +464,11 @@ def intersection(self, X):
sage: SmallMirrorUniverse = ConditionSet(QQ^2, in_small_oblong, vars=(y, x))
sage: SmallMirrorUniverse
{ (y, x) ∈ QQ^2 : 3*x^2 + y^2 <= 42 }
{ (y, x) ∈ Vector space of dimension 2 over Rational Field : 3*x^2 + y^2 <= 42 }
sage: SmallOblongUniverse & SmallMirrorUniverse
{ (x, y) ∈ QQ^2 : x^2 + 3*y^2 <= 42 }
{ (x, y) ∈ Vector space of dimension 2 over Rational Field : x^2 + 3*y^2 <= 42 }
sage: SmallMirrorUniverse & SmallOblongUniverse
{ (y, x) ∈ QQ^2 : 3*x^2 + y^2 <= 42 }
{ (y, x) ∈ Vector space of dimension 2 over Rational Field : 3*x^2 + y^2 <= 42 }
"""
if isinstance(X, ConditionSet):
return ConditionSet(self.ambient().intersection(X.ambient()),
Expand Down

0 comments on commit 69d045a

Please sign in to comment.