The argument providing the block sizes is required to be an integer 
partition (or something that sage can make into an integer partition), as 
the error message indicates.

One might argue that Partition (and hence SetPartition) should take lists 
in any order, but this would also increase the likelihood of typos going 
undetected, I guess.

Martin

On Monday, 14 February 2022 at 13:02:39 UTC+1 mitch...@gmail.com wrote:

> Hello,
>
> I am currently working with set partitions and I encountered possible bug 
> when creating SetPartitions instance with specified partition sizes:
>
> ```
> sage: SetPartitions(10, [4,3,2,1])                                         
>                                                                   
> Set partitions of {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} with sizes in [4, 3, 2, 
> 1]
> ```
>
> The above works, but changing the order of sizes gives error:
> ```
> sage: SetPartitions(10, [1,2,3,4])                                         
>                                                                             
>                                                             
> ---------------------------------------------------------------------------
> ValueError                                Traceback (most recent call last)
> <ipython-input-4-90164a225d10> in <module>
> ----> 1 SetPartitions(Integer(10), 
> [Integer(1),Integer(2),Integer(3),Integer(4)])
>
> /usr/lib/python3/dist-packages/sage/misc/classcall_metaclass.pyx in 
> sage.misc.classcall_metaclass.ClasscallMetaclass.__call__ 
> (build/cythonized/sage/misc/classcall_metaclass.c:1714)()
>     332         """
>     333         if cls.classcall is not None:
> --> 334             return cls.classcall(cls, *args, **kwds)
>     335         else:
>     336             # Fast version of type.__call__(cls, *args, **kwds)
>
> /usr/lib/python3/dist-packages/sage/combinat/set_partition.py in 
> __classcall_private__(cls, s, part)
>    2025             else:
>    2026                 if part not in Partitions(len(s)):
> -> 2027                     raise ValueError("part must be a partition of 
> %s"%len(s))
>    2028                 else:
>    2029                     return SetPartitions_setparts(s, 
> Partition(part))
>
> ValueError: part must be a partition of 10
> ```
>
> Other orders od partition sizes (other than descending) also gives the 
> same error:
> ```
> sage: SetPartitions(10, [4,2,3,1])
> <the same error as above> 
> ```
>
> Diferent sets also show this behavior:
> ```
> sage: SetPartitions(8, [4,3,1])
> <OK>                                                                       
>                                                                             
>      
> ```
>
> ```
> sage: SetPartitions(8, [4,3,1])                                           
>                                                                   
> <Error>
> ```
>
> The same happens when using sage as a module within Python
>
> I am using Sage version 9.0, using Python 3.8.10.
> Operating system is Ubuntu 20.04.3 (64bit)
>
> Best regards,
> Ondra
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/58346f8e-de84-44d3-9d52-8b4d09b85867n%40googlegroups.com.

Reply via email to