Open maxale opened 1 week ago
Btw, it's ironic, when Set()
is happy with mutable elements, while Subsets()
is not:
sage: Set([[1],[2],[3]])
Set of elements of [[1], [2], [3]]
sage: Subsets(_)
[...]
TypeError: unhashable type: 'list'
Related #23324.
This seems to be an enhancement request, not a bug. (However, the documentation should probably specify that the elements of the set must be hashable.) As a workaround, you can use tuples, instead of lists:
sage: Permutations( [(1,), (2,), (3,)] )
Permutations of the set [(1,), (2,), (3,)]
As mentioned at #23324, I don't think that this would be a good idea. I still think that we should require immutable objects also for Set
.
As mentioned at #23324, I don't think that this would be a good idea. I still think that we should require immutable objects also for
Set
.
I support the idea of requiring immutable objects for all these classes (including Set
), since that will save them from various side effects. But it's still a bug since documentation does not mention such an important requirement.
Steps To Reproduce
Calls like
Permutations([[1],[2],[3]])
,Subsets([[1],[2],[3]])
,SetPartitions([[1],[2],[3]])
etc. all result in the error:Expected Behavior
Should work.
Actual Behavior
TypeError
Additional Information
No response
Environment
Checklist