On Monday, 12 December 2022 at 00:22:30 UTC-8 axio...@yahoo.de wrote:

> Ah, thank you so much!
>
> Just to make sure that I understand the philosophy: if two elements are 
> supposed to compare equal, they should have parents which can be coerced to 
> a common parent, right?  For example, the following (which is current 
> behaviour) is not really what we want:
>
> sage: A = SetPartitions(3)([[1,2],[3]])
> sage: B = SetPartition([[1,2],[3]])
> sage: A == B
> True
> sage: coercion_model.common_parent(A, B)
> TypeError: no common canonical parent for objects with parents: 'Set 
> partitions of {1, 2, 3}' and 'Set partitions'
>
> I think that is a bit surprising, but if SetPartitions don't really occur 
much in binary operations I think it will be a hardly visible quirk. One 
has to be careful generalizing principles about how to implement 
coercion/equality/hashing because we a;ready know that some of the things 
we want lead to inconsistencies.

When in doubt, the safe thing is definitely to NOT install coercions (it 
can always be done later), so I'd hesitate to recommend to change the 
behaviour above. I think you'd want at least a practical use case to 
justify it.

Note that the relevant conversions: A.parent()(B) and B.parent()(A) do work.

It seems to me the converse implication, if for two elements the coercion 
framework is happy to find a common parent in which they compare equal, 
then they should be equal in the first place, sounds a little more 
probable, but I suspect one can get problematic situations from that too.

-- 
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/3ad6fd6e-25c6-4d56-9864-4cc4ea48d55fn%40googlegroups.com.

Reply via email to