#17548: Partitions() is buggy
---------------------------------+---------------------------
       Reporter:  ferriszorro    |        Owner:  ferriszorro
           Type:  defect         |       Status:  needs_work
       Priority:  major          |    Milestone:  sage-6.5
      Component:  combinatorics  |   Resolution:
       Keywords:  Partitions     |    Merged in:
        Authors:                 |    Reviewers:
Report Upstream:  N/A            |  Work issues:
         Branch:                 |       Commit:
   Dependencies:                 |     Stopgaps:  #17637
---------------------------------+---------------------------
Description changed by jdemeyer:

Old description:

> There are various bugs in `Partitions`/`Compositions`, especially when
> many constraints are combined:
>
> {{{
> sage: C = Partitions(10, min_part=2, max_slope=-1)
> sage: [5,3,2] in C
> True
> sage: C.list()
> [[10], [8, 2], [7, 3], [6, 4]]
> }}}
>
> {{{
> sage: C = Compositions(5, max_part=2, min_slope=1, inner=[2])
> sage: [2,1,2] in C
> False
> sage: C.list()
> [[2, 1, 2]]
> }}}
>
> When slopes are equal, things often go wrong:
> {{{
> sage: C = Compositions(4, min_slope=0, max_slope=0)
> sage: [1,1,1,1] in C
> True
> sage: C.list()
> [[4], [2, 2]]
> }}}
>
> Contradictory length bounds still give results:
> {{{
> sage: C = Compositions(6, min_length=3, max_length=2)
> sage: [4,1,1] in C
> False
> sage: C.list()[0]
> [4, 1, 1]
> }}}
> {{{
> sage: C = Compositions(3, max_length=2, inner=[1,1,1])
> sage: [1,1,1] in C
> False
> sage: C.list()
> [[1, 1, 1]]
> }}}
>
> `max_part` is not respected:
> {{{
> sage: C = Compositions(4, max_part=2, min_slope=1)
> sage: [1,3] in C
> False
> sage: C.list()
> [[1, 3]]
> }}}
>
> Strange exception which really shouldn't be an exception:
> {{{
> sage: Compositions(10, inner=[1,1], max_slope=-1)
> ...
> ValueError: floor does not satisfy the max slope condition
> }}}

New description:

 There are various bugs in `Partitions`/`Compositions`, especially when
 many constraints are combined:

 {{{
 sage: C = Partitions(10, min_part=2, max_slope=-1)
 sage: [5,3,2] in C
 True
 sage: C.list()
 [[10], [8, 2], [7, 3], [6, 4]]
 }}}

 {{{
 sage: C = Compositions(5, max_part=2, min_slope=1, inner=[2])
 sage: [2,1,2] in C
 False
 sage: C.list()
 [[2, 1, 2]]
 }}}

 When slopes are equal, things often go wrong:
 {{{
 sage: C = Compositions(4, min_slope=0, max_slope=0)
 sage: [1,1,1,1] in C
 True
 sage: C.list()
 [[4], [2, 2]]
 }}}

 Contradictory length bounds still give results:
 {{{
 sage: C = Compositions(6, min_length=3, max_length=2)
 sage: [4,1,1] in C
 False
 sage: C.list()[0]
 [4, 1, 1]
 }}}
 {{{
 sage: C = Compositions(3, max_length=2, inner=[1,1,1])
 sage: [1,1,1] in C
 False
 sage: C.list()
 [[1, 1, 1]]
 }}}

 `max_part` is not respected:
 {{{
 sage: C = Compositions(4, max_part=2, min_slope=1)
 sage: [1,3] in C
 False
 sage: C.list()
 [[1, 3]]
 }}}

 This is horribly wrong:
 {{{
 sage: Compositions(7, max_part=4, inner=[1], min_slope=1).list()
 [[3, 5], [1, 3, 4]]
 }}}

 Strange exception which really shouldn't be an exception:
 {{{
 sage: Compositions(10, inner=[1,1], max_slope=-1)
 ...
 ValueError: floor does not satisfy the max slope condition
 }}}

--

--
Ticket URL: <http://trac.sagemath.org/ticket/17548#comment:39>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to