ConditionSet
mkoeppe opened this issue · 65 comments
(from #24176).
We define a class ConditionSet for subsets of elements given by a logical "and" of finitely many predicates.
If the given predicates (condition) are symbolic, a ConditionSet can be converted to a SymPy ConditionSet; the _sympy_ method falls back to creating a SageSet wrapper otherwise.
As an application, we provide Chart and RealChart with a method codomain.
Depends on #32013
Depends on #32015
CC: @tscrim @egourgoulhon
Component: symbolics
Author: Matthias Koeppe
Branch/Commit: f135a05
Reviewer: Travis Scrimshaw
Issue created by migration from https://trac.sagemath.org/ticket/32089
Description changed:
---
+++
@@ -1,4 +1,6 @@
(from #24176).
-We define a constructor `ConditionSet`. If the given predicate (condition) is a `CallableSymbolicExpression`, we create an instance of class `ConditionSet_callable_symbolic_expression`.
+We define a constructor `ConditionSet`.
+If the given predicate (condition) is a `CallableSymbolicExpression`, we create an instance of class `ConditionSet_callable_symbolic_expression`, which provides a `_sympy_` method.
+Author: Matthias Koeppe
Last 10 new commits:
dbdfc06 | InternalRealInterval, RealSet: Remove extra whitespace in latex, add documentation |
7f56338 | PiecewiseFunction: Adjust doctests for changed RealSet repr |
8abdc8b | src/sage/functions/piecewise.py: Add coding header |
5b0f85d | Merge #31880 |
e768463 | Merge #31877 |
cb93c99 | RealSet: Inherit from Set_base, Set_boolean_operators, Set_add_sub_operators |
3a6f9bd | RealSet.symmetric_difference: New |
08c52c2 | Set_base._test_as_set_object: Skip _test_pickling |
4f4a964 | Merge #32013 |
2d5d4b9 | sage.sets.condition_set: New |
Branch pushed to git repo; I updated commit sha1. New commits:
8c2cce8 | ConditionSet: Complete basic implementation |
Branch pushed to git repo; I updated commit sha1. New commits:
1267737 | ConditionSet: Add example |
I'm going to extend it to lists of several conditions
Branch pushed to git repo; I updated commit sha1. Last 10 new commits:
6e5cac6 | sage.interfaces.sympy_wrapper, Sets.ParentMethods._sympy_: New |
3cac256 | sage.interfaces.sympy_wrapper: Add doctests |
eef604e | SageSet: Finish docstrings; handle symbolic _contains |
2baae58 | Sets.ParentMethods._sympy_: Call sympy_init |
153b3e5 | Merge #31938 |
c06c965 | sage.interfaces.sympy_wrapper.SageSet: Add another doctest |
f535127 | Merge #31938 |
32cdd5c | Merge #31877 |
36e742d | Merge #31931 |
44f7293 | ConditionSet: Accept several predicates |
Description changed:
---
+++
@@ -4,3 +4,5 @@
If the given predicate (condition) is a `CallableSymbolicExpression`, we create an instance of class `ConditionSet_callable_symbolic_expression`, which provides a `_sympy_` method.
+As an application, we provide `Chart` and `RealChart` with a method `codomain`.
+Branch pushed to git repo; I updated commit sha1. New commits:
b31b2c7 | ConditionSet: Support generator notation, add examples |
Branch pushed to git repo; I updated commit sha1. New commits:
eb975f3 | ConditionSet: Remove unnecessary subclass, add examples |
Description changed:
---
+++
@@ -1,8 +1,8 @@
(from #24176).
-We define a constructor `ConditionSet`.
+We define a class `ConditionSet` for subsets of elements given by a logical "and" of finitely many predicates.
-If the given predicate (condition) is a `CallableSymbolicExpression`, we create an instance of class `ConditionSet_callable_symbolic_expression`, which provides a `_sympy_` method.
+If the given predicates (condition) are symbolic, a `ConditionSet` can be converted to a SymPy `ConditionSet`; the `_sympy_` method falls back to creating a `SageSet` wrapper otherwise.
As an application, we provide `Chart` and `RealChart` with a method `codomain`.
Branch pushed to git repo; I updated commit sha1. New commits:
a745649 | Chart.codomain, _restrict_set: Handle set/frozenset as ANDs in anticipation of #32102 |
Note that this is duplicating some of the framework in sage/combinat/combinat.py with FilteredCombinatorialClass.
What do we want the intersection of two condition sets to be? Mainly, do we want the generic intersection? It could be another condition set object naturally, which would be more direct for operations such as containment check or iteration.
Replying to @tscrim:
Note that this is duplicating some of the framework in
sage/combinat/combinat.pywithFilteredCombinatorialClass.
Thanks for the pointer! I was not aware of this. But it looks to me like this whole *CombinatorialClass business is deprecated?
Replying to @tscrim:
What do we want the intersection of two condition sets to be? Mainly, do we want the generic intersection? It could be another condition set object naturally, which would be more direct for operations such as containment check or iteration.
A specialized intersection method is of course a natural candidate to be added in a follow-up ticket. If for nothing else, certainly for more succinct printing.
Replying to @mkoeppe:
Replying to @tscrim:
Note that this is duplicating some of the framework in
sage/combinat/combinat.pywithFilteredCombinatorialClass.Thanks for the pointer! I was not aware of this. But it looks to me like this whole
*CombinatorialClassbusiness is deprecated?
Indeed, but some of it is still used without a true replacement ready IIRC.
Replying to @mkoeppe:
Replying to @tscrim:
What do we want the intersection of two condition sets to be? Mainly, do we want the generic intersection? It could be another condition set object naturally, which would be more direct for operations such as containment check or iteration.
A specialized
intersectionmethod is of course a natural candidate to be added in a follow-up ticket. If for nothing else, certainly for more succinct printing.
Why can't we do it on this ticket? It seems simple enough to check if other is a ConditionSet, and then just create a new such instance with the concatenation of the conditions.
OK, here we go. Caught and fixed a bug along the way.
Branch pushed to git repo; I updated commit sha1. New commits:
ac561ae | Chart._restrict_set: Update doctest output |
Thank you. LGTM (modulo the doctest failure for the dependency).
Reviewer: Travis Scrimshaw
Thank you!
Branch pushed to git repo; I updated commit sha1 and set ticket back to needs_review. Last 10 new commits:
2a23cb5 | Unicode symbol 2202 (partial) for the text display of coordinate frames |
5d096f1 | f-string for unicode_symbol in TensorProductFunctor and SignedTensorProductFunctor |
76c2fd5 | Use Unicode symbol for the Riemann sphere example |
5167e6c | Use Unicode symbol for default text display of RealLine |
332410b | Use unicode_otimes in TensorProductFunctor and SignedTensorProductFunctor |
f5d15d2 | Merge branch 'public/manifolds/unicode_art' of git://trac.sagemath.org/sage into Sage 9.4.beta4. |
d87d09b | #30473: fix doctest error in DiffMap.pullback |
f2ae50e | #30473: fix doctests outside sage/manifolds and sage/tensor/modules |
55240bb | Merge #30473 |
82f12e2 | Merge #32013 |
Unfortunately the sort order of the symbolic conditions is not stable. I'll have to fix this
Also the doctests that tried to use (ZZ<sup>2).rename("ZZ</sup>2") for cosmetic reasons were not stable. I have removed this complication.
For future reference, you can simply call X.rename() to revert back to the default name. This can be used to make the doctest stable.
Thanks!
[docpdf] Underfull \hbox (badness 10000) in paragraph at lines 5889--5891
[docpdf] \T1/txtt/m/sl/10 set.Set_boolean_operators\T1/qtm/m/n/10 , \T1/txtt/m/sl/10 sag
[docpdf] e.sets.set.Set_add_sub_operators\T1/qtm/m/n/10 , [][]\T1/txtt/m/n/10 sage.struc
[docpdf] ture.
[docpdf] ! Missing $ inserted.
[docpdf] <inserted text>
[docpdf] $
[docpdf] l.5923 ...us{}even at 0x...\PYGZgt{}(x) \PYGZcb{}}
[docpdf]
[docpdf] ?
[docpdf] ! Emergency stop.
LGTM.
Thanks.
Branch pushed to git repo; I updated commit sha1 and set ticket back to needs_review. New commits:
2682469 | src/sage/interfaces/sympy_wrapper.py: Use Family, not Set, in doctests to make sure that the SageSet wrapper is actually used |
753babb | Set_object_enumerated._sympy_: Translate empty sets to EmptySet |
141ecde | Merge #32015 |
Branch pushed to git repo; I updated commit sha1 and set ticket back to needs_review. Last 10 new commits:
f85e710 | Chart: in the description of the argument coord_restrictions, replace all instances of 'restrictions' by 'coord_restrictions' |
80f6195 | Chart, RealChart: In class docstring, order arguments as they appear in __classcall__/__init__ |
a39e6fc | DiffChart, RealDiffChart: In class docstring, order arguments as they appear in __classcall__/__init__; add description of argument coord_restrictions |
cdf20b0 | TopologicalManifold.chart: Add description of argument coord_restrictions |
741fd2e | TopologicalManifold.chart: Add an example of using coord_restrictions |
bf62543 | Merge branch 't/32089/conditionset__conditionset_callable_symbolic_expression' into t/32009/eliminate_direct_use_of_the_chart__domain_attribute |
141ccb5 | Merge #32009 |
c89c697 | Merge #32102 |
451f5cf | Sets.ParentMethods: Update doctest |
f135a05 | Merge #32015 |
Changed branch from u/mkoeppe/conditionset__conditionset_callable_symbolic_expression to f135a05