Ah, now I see it is actually mentioned in the documentation, because I was reading part for SetPartition, not for SetPartitionS...
Dne úterý 15. února 2022 v 10:38:46 UTC+1 uživatel mitchondra napsal: > To be honest, I really did not find the error message helpfull and I > identified the problem mostly just by "common programmer sense". But, of > course, I am not that familiar with Sage. > > I basically just used the examples of SetPartitions constructor, since I > found no general explanation what are possible arguments of this > constructor and what the arguments are supposed to fullfil. > I guess it makes sense to allow only sorted list of sizes (as per > definition of integer partition), but it should be mentioned somewhere in > documentation then. > > Best, > Ondra > > Dne úterý 15. února 2022 v 0:34:35 UTC+1 uživatel Travis Scrimshaw napsal: > >> As Martin said, this is not a bug. However, the error message itself is >> slightly vague because it only states partition. We could simply run >> sorted(part, reverse=True) before passing it off to create the Partition in >> the SetPartitions __classcall__. This would make the behavior less >> surprising, and our output does not match the input sizes (since it is lex >> based). I think we probably just didn't think about normalizing input here. >> >> Also, I found this bug: >> >> sage: SP = SetPartitions(10, [4,3,2,1]) >> sage: SP.random_element() >> {{1, 2, 4, 5, 7, 8}, {3, 6}, {9}, {10}} >> >> Best, >> Travis >> >> >> On Tuesday, February 15, 2022 at 1:51:32 AM UTC+9 axio...@yahoo.de wrote: >> >>> 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/645e474a-e78c-4bde-8008-9bce13578614n%40googlegroups.com.