Changes between Version 3 and Version 4 of Ticket #15425


Ignore:
Timestamp:
05/05/14 06:08:54 (6 years ago)
Author:
vdelecroix
Comment:

Hello,

+1 on that ticket!

I cleaned a bit the description.

I think it is bad to hide cartesian_product_iterator as the object is very nice. We should advertise the product from itertools somewhere.

Vincent

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #15425 – Description

    v3 v4  
    1717To be done:
    1818
    19 #.  Make {{{CartesianProduct}}} an alias for {{{cartesian_product}}},
    20     and possibly deprecated it.
     191.  Make {{{CartesianProduct}}} an alias for {{{cartesian_product}}}, and possibly deprecated it. The missing features at this point are:
     20    - Accepting any iterable as input. This probably requires turning
     21      them into parents (e.g. with {{{FiniteEnumeratedSet}}}). The overhead
     22      is probably negligible in most cases, but one would need to double
     23      check that we don't have spots where {{{CartesianProduct}}} is used
     24      intensively for very small calculations. #14224 can be closed once this is fixed.
     25    - Some features of {{{CartesianProduct}}} still need to be lifted to {{{Sets.Finite.CartesianProducts}}} or {{{EnumeratedSets.CartesianProducts}}}. For example, cardinality is currently calculated from the iterator (gasp):
     26      {{{
     27          sage: F = Permutations(10)
     28          sage: C = cartesian_product([F,F])
     29          sage: C.cardinality()
     30          *hangs forever*
     31      }}}
     32      Done by #16269/#10963 for cardinality and `__iter__`. Needs double checking for the infinite and zero cases.
    2133
    22     The missing features at this point are:
     342.  Remove {{{cartesian_product_iterator}}} from the global name space, and deprecate it altogether if, after checking, it turns out to be really just a duplicated of {{{itertools.product}}}.
    2335
    24     - Accepting any iterable as input. This probably requires turning them
    25       into parents (e.g. with FiniteEnumeratedSet). The overhead is
    26       probably negligible in most cases, but one would need to double
    27       check that we don't have spots where CartesianProduct is used
    28       intensively for very small calculations.
    29 
    30       #14224 can be closed once this is fixed.
    31 
    32     - Some features of CartesianProduct still need to be lifted to
    33       Sets.Finite.CartesianProducts or EnumeratedSets.CartesianProducts.
    34       For example, cardinality is currently calculated from the iterator (gasp):
    35       {{{
    36           sage: F = Permutations(10)
    37           sage: C = cartesian_product([F,F])
    38           sage: C.cardinality()
    39           *hangs forever*
    40       }}}
    41 
    42       Done by #16269/#10963 for cardinality and `__iter__`. Needs
    43       double checking for the infinite cases.
    44 
    45 #.  Remove cartesian_product_iterator from the global name space, and
    46     deprecate it altogether if, after checking, it turns out to be
    47     really just a duplicated of itertools.product.
    48 
    49 #.  #16289: Fix bug in cartesian_product (reported by Vincent Delecroix [1]):
     363.  #16289: Fix bug in cartesian_product (reported by Vincent Delecroix in [https://groups.google.com/forum/#!topic/sage-combinat-devel/8Aw63kro_0M this thread]):
    5037    {{{
    5138    sage: C = cartesian_product([ZZ,ZZ])
     
    5542
    5643    This is a regression that is caused by a small change introduced by
    57     #12959 in Sets.ParentMethods.CartesianProduct:
     44    #12959 in {{{Sets.ParentMethods.CartesianProduct}}}:
    5845    {{{
    5946                return parents[0].__class__ -> return parents[0].__class__
     
    6552    place. So this needs to be fixed too.
    6653
    67 #.  #16269: Fix bug reported by Nathann Cohen [2]: when converting a
     544.  #16269: Fix bug reported by Nathann Cohen in [https://groups.google.com/forum/#!msg/sage-devel/tyAxhqxk3ZI/rff7pTrGIQ4J this thread]: when converting a
    6855    list to an element of a cartesian product:
    6956    {{{
     
    8067    {{{sage.sets.cartesian_product.CartesianProduct._element_constructor}}}.
    8168
    82 #.  Fix mixed cartesian products with modules and non modules:
     695.  Fix mixed cartesian products with modules and non modules:
    8370    {{{
    8471    sage: A = AlgebrasWithBasis(QQ).example(); A.rename("A")
     
    9077    just use a plain cartesian product.
    9178
    92 #.  Fix cartesian products involving NN:
     796.  Fix cartesian products involving {{{NN}}}:
    9380    {{{
    9481        sage: cartesian_product([NN,NN])
     
    9986        AssertionError:
    10087    }}}
    101     This is in fact a bug in the way NN is lazy imported in the global
     88    This is in fact a bug in the way {{{NN}}} is lazy imported in the global
    10289    name space:
    10390    {{{
     
    10794        False
    10895    }}}
    109     Things works if one forces the import of NN:
     96    Things works if one forces the import of {{{NN}}}:
    11097    {{{
    11198        sage: NN = NonNegativeIntegers()
     
    115102
    116103
    117 #.  Many features could be further added, like for example making the
    118     cartesian product of an additive magma into an additive magma, and
    119     so on. A good step was done with #16269. Another step needs to be
    120     done after #10963 to ventilate the features in the appropriate
    121     axiom categories, and add Distributive.CartesianProducts.
    122 
    123 [1] https://groups.google.com/forum/#!topic/sage-combinat-devel/8Aw63kro_0M
    124 [2] https://groups.google.com/forum/#!msg/sage-devel/tyAxhqxk3ZI/rff7pTrGIQ4J
     1047.  Many features could be further added, like for example making the cartesian product of an additive magma into an additive magma, and so on. A good step was done with #16269. Another step needs to be done after #10963 to ventilate the features in the appropriate axiom categories, and add {{{Distributive.CartesianProducts}}}.