id summary reporter owner description type status priority milestone component resolution keywords cc merged author reviewer upstream work_issues branch commit dependencies stopgaps
17548 Partitions() is buggy ferriszorro ferriszorro "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]]
}}}
{{{
sage: C = Partitions(6, min_slope=-1, max_slope=-1)
sage: [3,2,1] in C
True
sage: C.list()
[[6]]
}}}
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]]
}}}
{{{
sage: C = Compositions(10, outer=[4], inner=[1,1])
sage: [4,6] in C
False
sage: C.list()
[[4, 6], [3, 7], [2, 8], [1, 9]]
}}}
`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]]
}}}
The following command hangs:
{{{
sage: Compositions(4, inner=[2], outer=[2,2], min_slope=0).list()
...
}}}
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
}}}
One possible fix is given by #17920." defect closed major sage-duplicate/invalid/wontfix combinatorics duplicate Partitions jakobkroeker aschilling Jeroen Demeyer N/A public/combinat/equal_min_max_slope_fix 44d1cfb45c137d7d8ac6eb481bf6145ec57c12e4 #17637, #17956