Re: [sage-devel] A issue with the Set function in sage

2020-06-25 Thread 'Travis Scrimshaw' via sage-devel


>
>> - the problem is that lists are not hashable, and  considered unequal. 
>> The problem is that in general testing objects for equality is far 
>> from obvious, might be algorithmically unsolvable, etc. 
>>
>> Why is Set trying then? I can see in the documentation that "Sets with 
> unhashable objects work, but with less functionality", but as this example 
> shows, it's more "but with misleading functionality". How is this ever 
> useful?
>
> Because sometimes you need to have something that is a Sage object in a 
category. Also sometimes you want a set-like object with unhashable things. 
However, I agree that it should try a bit harder to remove redundant 
elements by a brute force check.
 

> sage: a,b=list(Set([[0],[0]])) 
> sage: a==b 
> True 
>
> I don't know if this is ever useful internally (I doubt it; I expect it 
> mainly makes bugs harder to find), but we should definitely not be exposing 
> this as user interface, Python's own "frozenset" and "set" are better 
> behaved.
>

+1 for general internal use. However, set and frozenset can behave quite 
differently than over objects in Sage, and something dealing with that 
nonuniformity leads to more cases and code.

Best,
Travis

-- 
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/9ebed824-3c12-4dc0-90e7-857d7dd29520o%40googlegroups.com.


Re: [sage-devel] A issue with the Set function in sage

2020-06-25 Thread 'Martin R' via sage-devel
See https://trac.sagemath.org/ticket/23324 for some discussion.

Am Donnerstag, 25. Juni 2020 19:19:26 UTC+2 schrieb Nils Bruin:
>
>
>
> On Thursday, June 25, 2020 at 5:00:23 AM UTC-7, Dima Pasechnik wrote:
>>
>>
>> - the problem is that lists are not hashable, and  considered unequal. 
>> The problem is that in general testing objects for equality is far 
>> from obvious, might be algorithmically unsolvable, etc. 
>>
>> Why is Set trying then? I can see in the documentation that "Sets with 
> unhashable objects work, but with less functionality", but as this example 
> shows, it's more "but with misleading functionality". How is this ever 
> useful?
>
> sage: a,b=list(Set([[0],[0]])) 
> sage: a==b 
> True 
>
> I don't know if this is ever useful internally (I doubt it; I expect it 
> mainly makes bugs harder to find), but we should definitely not be exposing 
> this as user interface, Python's own "frozenset" and "set" are better 
> behaved.
>

-- 
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/2cc7f9b1-f3e9-4e9d-8f66-8ba93f7d0c8do%40googlegroups.com.


Re: [sage-devel] A issue with the Set function in sage

2020-06-25 Thread Nils Bruin


On Thursday, June 25, 2020 at 5:00:23 AM UTC-7, Dima Pasechnik wrote:
>
>
> - the problem is that lists are not hashable, and  considered unequal. 
> The problem is that in general testing objects for equality is far 
> from obvious, might be algorithmically unsolvable, etc. 
>
> Why is Set trying then? I can see in the documentation that "Sets with 
unhashable objects work, but with less functionality", but as this example 
shows, it's more "but with misleading functionality". How is this ever 
useful?

sage: a,b=list(Set([[0],[0]])) 
sage: a==b 
True 

I don't know if this is ever useful internally (I doubt it; I expect it 
mainly makes bugs harder to find), but we should definitely not be exposing 
this as user interface, Python's own "frozenset" and "set" are better 
behaved.

-- 
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/ae7e774b-3921-4a11-9c6c-63aec90d0e05o%40googlegroups.com.


Re: [sage-devel] A issue with the Set function in sage

2020-06-25 Thread Dima Pasechnik
On Thu, Jun 25, 2020 at 12:49 PM Ars-Magna  wrote:
>
> Is the following a bug ?
>
> sage: Set([[(Integer(0), Integer(0)), (Integer(1), Integer(1))],[(Integer(0), 
> Integer(0)), (Integer(1), Integer(1))]]).cardinality()
>
> 2

hard to say. Note that

sage: Set([[(0,0), (1,1)],[(0,0), (1,1)]]).cardinality()
2
sage: Set([((0,0), (1,1)),((0,0), (1,1))]).cardinality()
1

and even
sage: Set([[0],[0]]).cardinality()
2

- the problem is that lists are not hashable, and  considered unequal.
The problem is that in general testing objects for equality is far
from obvious, might be algorithmically unsolvable, etc.

>
> --
> 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/4c7163cb-84c5-4bf0-9ef3-585e709883b7o%40googlegroups.com.

-- 
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/CAAWYfq3R8D_jyQEJCZeWtEmZGQJmTR8xu5%3DKbnUeRUhttdB%3Dmg%40mail.gmail.com.