sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.46k stars 485 forks source link

get rid of CartesianProduct #18411

Closed videlec closed 9 years ago

videlec commented 9 years ago

The features of sage.combinat.cartesian_product.CartesianProduct are now completely integrated into the category framework (see #18290). We remove all occurrences of CartesianProduct to either cartesian_product or itertools.product. We deprecate the CartesianProduct from sage.combinat.cartesian_product.

In order to support all features of the old class we also:

see also : #15425, #19195 one that can be closed as duplicate: #14224, #19192

Depends on #17411

CC: @nthiery @nathanncohen

Component: combinatorics

Author: Vincent Delecroix

Branch/Commit: 6e27dde

Reviewer: Nicolas M. Thiéry

Issue created by migration from https://trac.sagemath.org/ticket/18411

videlec commented 9 years ago

Description changed:

--- 
+++ 
@@ -1,3 +1,3 @@
-The features of `sage.combinat.cartesian_product.CartesianProduct` are now completely integrated into the category framework. We just make `CartesianProduct` an alias for `sage.sets.cartesian_product.CartesianProduct` (with some tweak to support the behavior).
+The features of `sage.combinat.cartesian_product.CartesianProduct` are now completely integrated into the category framework (see #18290). We just make `CartesianProduct` an alias for `sage.sets.cartesian_product.CartesianProduct` (with some tweak to support the previous behavior which considered the cartesian product as a set of lists).

 `sage.combinat.cartesian_product.CartesianProduct` is deprecated.
videlec commented 9 years ago

Dependencies: #18290, #12955

videlec commented 9 years ago

Branch: public/18411

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Commit: e703eb4

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

e703eb4Trac 18411: remove occurrences of CartesianProduct
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Changed commit from e703eb4 to 10df218

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

635279fTrac 18411: a bounded_number_of_tuples function
1b60903Trac 18411: remove occurrences of CartesianProduct
bec57aeTrac 18411: cartesian_product works with tuple/list/set/frozenset
7dbb663Trac 18411: move iteration of cartesian products to Sets
4fbb4aeTrac 18411: refine category of Set(...)
10df218Trac 18411: fix combinat tutorial
videlec commented 9 years ago

Author: Vincent Delecroix

videlec commented 9 years ago

Description changed:

--- 
+++ 
@@ -1,3 +1,5 @@
-The features of `sage.combinat.cartesian_product.CartesianProduct` are now completely integrated into the category framework (see #18290). We just make `CartesianProduct` an alias for `sage.sets.cartesian_product.CartesianProduct` (with some tweak to support the previous behavior which considered the cartesian product as a set of lists).
+The features of `sage.combinat.cartesian_product.CartesianProduct` are now completely integrated into the category framework (see #18290). We remove most occurrences of `CartesianProduct` to either `cartesian_product` or `itertools.product`.

-`sage.combinat.cartesian_product.CartesianProduct` is deprecated.
+follow up: #19192
+
+
videlec commented 9 years ago

Changed dependencies from #18290, #12955 to none

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

57b82e3trax #18411 fixing a typo and doctest continuation
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Changed commit from 10df218 to 57b82e3

videlec commented 9 years ago
comment:7

Thanks Frédéric for fixing a doctest. Though, I do not see the point of modifying src/sage/rings/quotient_ring.py. This file is completely unrelated to this ticket.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Changed commit from 57b82e3 to a640c24

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

a640c24trac #18411 fixing some doctests
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

b650e69trac #18411 fixing some doctests
0dcfed9Trac 18411: fix combinat/partition_tuple
613cef5Trac 18411: fix testing issues
3cc8070Trac 18411: fix composition signed
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Changed commit from a640c24 to 3cc8070

videlec commented 9 years ago
comment:10

Hi Frédéric,

This was clearly not the way to fix composition_signed.py. I removed this change from your commit. The rest of my commits should fix all issues with timed out testing (ie root system and padic) as well as the issue with tableau tuples.

Vincent

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

70949c7Trac 18411: fix two doctests
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Changed commit from 3cc8070 to 70949c7

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

9beb023Trac 18411: bound number of tests for Domains
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Changed commit from 70949c7 to 9beb023

videlec commented 9 years ago

Description changed:

--- 
+++ 
@@ -1,5 +1,10 @@
 The features of `sage.combinat.cartesian_product.CartesianProduct` are now completely integrated into the category framework (see #18290). We remove most occurrences of `CartesianProduct` to either `cartesian_product` or `itertools.product`.

+We also:
+- move the `__iter__` from `EnumeratedSets.CartesianProducts.ParentMethods` category to `Sets`
+- allows `cartesian_product` to be called with `list`, `tuple`, `set`, `frozenset`
+- introduce a function `bounded_number_of_tuples` in `sage.misc.misc` that is intensively used in the testing framework
+- refine the category of `Set([1,2,3])` to be finite
+- implement a (very naive) `random_element` for `Set([1,2,3])`
+
 follow up: #19192
-
-
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

6580825Trac 18411: fix is_empty
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Changed commit from 9beb023 to 6580825

videlec commented 9 years ago
comment:15

The only failing doctest is fine when run independently... I am not sure what may have happend.

Vincent

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Changed commit from 6580825 to 8a5ca01

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

af2c289Trac 18411: use cartesian_product in CombinatorialFreeModule
8a5ca01Trac 18411: remove two final occurrences
videlec commented 9 years ago

New commits:

af2c289Trac 18411: use cartesian_product in CombinatorialFreeModule
8a5ca01Trac 18411: remove two final occurrences
videlec commented 9 years ago

Description changed:

--- 
+++ 
@@ -1,6 +1,6 @@
-The features of `sage.combinat.cartesian_product.CartesianProduct` are now completely integrated into the category framework (see #18290). We remove most occurrences of `CartesianProduct` to either `cartesian_product` or `itertools.product`.
+The features of `sage.combinat.cartesian_product.CartesianProduct` are now completely integrated into the category framework (see #18290). We remove all occurrences of `CartesianProduct` to either `cartesian_product` or `itertools.product`. We also deprecate the `CartesianProduct` from `sage.combinat.cartesian_product`.

-We also:
+In order to support all features of the old class we also:
 - move the `__iter__` from `EnumeratedSets.CartesianProducts.ParentMethods` category to `Sets`
 - allows `cartesian_product` to be called with `list`, `tuple`, `set`, `frozenset`
 - introduce a function `bounded_number_of_tuples` in `sage.misc.misc` that is intensively used in the testing framework
videlec commented 9 years ago
comment:18

I was worried with CombinatorialFreeModule but it went smoothly. I just need to add a commit for the deprecation!

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Changed commit from 8a5ca01 to 4eacb22

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

cc3c250Trac 18411: hash for EnumeratedSetFromIterator
4eacb22Trac 18411: deprecate CartesianProduct
videlec commented 9 years ago

Description changed:

--- 
+++ 
@@ -6,5 +6,6 @@
 - introduce a function `bounded_number_of_tuples` in `sage.misc.misc` that is intensively used in the testing framework
 - refine the category of `Set([1,2,3])` to be finite
 - implement a (very naive) `random_element` for `Set([1,2,3])`
+- implement a (naive) hash for `EnumeratedSetFromIterator`

 follow up: #19192
videlec commented 9 years ago

Description changed:

--- 
+++ 
@@ -1,4 +1,4 @@
-The features of `sage.combinat.cartesian_product.CartesianProduct` are now completely integrated into the category framework (see #18290). We remove all occurrences of `CartesianProduct` to either `cartesian_product` or `itertools.product`. We also deprecate the `CartesianProduct` from `sage.combinat.cartesian_product`.
+The features of `sage.combinat.cartesian_product.CartesianProduct` are now completely integrated into the category framework (see #18290). We remove all occurrences of `CartesianProduct` to either `cartesian_product` or `itertools.product`. We deprecate the `CartesianProduct` from `sage.combinat.cartesian_product`.

 In order to support all features of the old class we also:
 - move the `__iter__` from `EnumeratedSets.CartesianProducts.ParentMethods` category to `Sets`
@@ -8,4 +8,5 @@
 - implement a (very naive) `random_element` for `Set([1,2,3])`
 - implement a (naive) hash for `EnumeratedSetFromIterator`

-follow up: #19192
+see also : #15425
+one that can be closed as duplicate: #14224, #19192
videlec commented 9 years ago
comment:22

Annoying bug:

sage: F = FiniteEnumeratedSet([int(1), int(2)])
sage: F(1)
Traceback (most recent call last):
...
TypeError: Cannot convert int to sage.structure.element.Element

And the following is also a bug IMHO

sage: FiniteEnumeratedSet([1,2]) is FiniteEnumeratedSet([int(1),int(2)])
True
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Changed commit from 4eacb22 to 9f29074

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

f0dbc10Trac 18411: deprecate CartesianProduct
596ad95Trac 18411: a comment in combinat/free_module.py
9f29074Trac 18411: a simplification in schur algebra
videlec commented 9 years ago
comment:24

I got into troubles. Combinatorial free modules are too laxist and you discover mistakes only very lately... in the following an element g is built

sage: M = SchurTensorModule(QQ, 2, 2)
sage: A = M._schur
sage: f = M.basis()[(1,1)]
sage: e = A.basis().values()[0]
sage: g = e*f

but it is not valid in the sense that the keys do not correspond to the basis

sage: map(type, g.monomial_coefficients().keys())
[<type 'tuple'>]
sage: g.parent().basis().keys()
The cartesian product of ({1, 2}, {1, 2})

And hence you silently got

sage: g.to_vector()
(0, 0, 0, 0)
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

d0f900aTrac 18411: remove two final occurrences
8819c3eTrac 18411: hash for EnumeratedSetFromIterator
4c50a1cTrac 18411: more explicit call in CombinatorialFreeModule
321067fTrac 18411: deprecate CartesianProduct
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Changed commit from 9f29074 to 321067f

videlec commented 9 years ago
comment:26

All right, my solution is to not use cartesian_product in combinatorial free module and postponed this step to #19195. Needs review again.

Vincent

videlec commented 9 years ago

Description changed:

--- 
+++ 
@@ -8,5 +8,5 @@
 - implement a (very naive) `random_element` for `Set([1,2,3])`
 - implement a (naive) hash for `EnumeratedSetFromIterator`

-see also : #15425
+see also : #15425, #19195
 one that can be closed as duplicate: #14224, #19192
videlec commented 9 years ago
comment:27

Patchbot's green light ;-)

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

c2eeac8Trac 18411: removed unused import
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Changed commit from 321067f to c2eeac8

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Changed commit from c2eeac8 to e7a2ff2

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

d269e6fTrac 18411: use Sets.__call__ to make parents
e7a2ff2Trac 18411: bounded_number_of_tuples -> some_tuples
videlec commented 9 years ago
comment:30

I just implemented the changes requested By Nicolas Thiéry while we discussed on phone.

videlec commented 9 years ago

Reviewer: Nicolas Thiéry