Re: [sage-devel] Re: DeprecationWarning on sagecell in Graph([(0,1)]).vertices()

2023-06-27 Thread Georgi Guninski
On Tue, Jun 27, 2023 at 8:48 AM John H Palmieri  wrote:
>
> Just do a global search-and-replace: change ".vertices()" to 
> ".vertices(sort=True, key=id)" or ".vertices(sort=True, key=str)".
>

Thanks for this.

You are right that I knew about the problems with sort(),
and sage 9.6 is OK for me currently.

I noticed the warning when I shared permanent link to
sagecell and it gave several warnings to the audience.

-- 
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/CAGUWgD_6avqD4idK6Hn48R_y%2BTNo6fTC%3Dk2j5O%3DwLv4NcqYEzg%40mail.gmail.com.


Re: [sage-devel] Re: DeprecationWarning on sagecell in Graph([(0,1)]).vertices()

2023-06-26 Thread John H Palmieri
Just do a global search-and-replace: change ".vertices()" to 
".vertices(sort=True, key=id)" or ".vertices(sort=True, key=str)".

This is not a new change; the deprecation warning has been in place almost 
a year, and there was discussion leading up to it. See 
https://github.com/sagemath/sage/issues/22349, in particular. I don't think 
that Sage developers are going to revert back to sorting by default, 
especially since sorting arbitrary objects can be problematic. 

(Actually, looking back on old sage-devel posts, you asked about 
essentially this issue (incomparable objects in Python 3 and using them to 
label vertices in graphs) back in July '22: 
https://groups.google.com/g/sage-devel/c/zc1UlSJse34/m/aHsfFnCKAAAJ. So not 
only is it not new in general, it's not new to you, either.)

On Monday, June 26, 2023 at 10:00:25 PM UTC-7 Georgi Guninski wrote:

> Thanks.
>
> In my code, this backwards incompatibility breaks over
> 150 calls to Graph.vertices() and I suspect
> I am not the only one.
>
> I think the root of the problem is the change from python2
> to python3. In python2 |["A",1].sort()| works fine, while
> it doesn't work in python3.
>
> My recommendation is to reverse engineer python2.sort() and
> use it as a custom function for sorting heterogeneous vertices.
> In this scenario, the code won't be more broken than it was
> in python2.
>

-- 
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/90a764a4-1002-4128-b79a-4cf960d3d0cen%40googlegroups.com.


Re: [sage-devel] Re: DeprecationWarning on sagecell in Graph([(0,1)]).vertices()

2023-06-26 Thread Georgi Guninski
Thanks.

In my code, this backwards incompatibility breaks over
150 calls to Graph.vertices() and I suspect
I am not the only one.

I think the root of the problem is the change from python2
to python3. In python2 |["A",1].sort()| works fine, while
it doesn't work in python3.

My recommendation is to reverse engineer python2.sort() and
use it as a custom function for sorting heterogeneous vertices.
In this scenario, the code won't be more broken than it was
in python2.

-- 
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/CAGUWgD-gDCQtwXywyx1C011Ak1zcBtJ4t7RV6JwqhFnKh%3D6p_g%40mail.gmail.com.


Re: [sage-devel] Re: DeprecationWarning on sagecell in Graph([(0,1)]).vertices()

2023-06-26 Thread Nils Bruin
On Monday, 26 June 2023 at 16:30:20 UTC+2 Georgi Guninski wrote:

> As of https://github.com/sagemath/sage/issues/22349, this argument must 
be explicitly specified (unless a "key" is given); otherwise a warning is 
printed and "sort=True" is used. The default will eventually be changed to 
"False". 

I think this sucks.

 
Pay attention to the instructions: by explicitly specifying "sort = ..." 
you can avoid the warning. Doing so protects your code against the eventual 
change from default "True" to "False". It's correcting an earlier design 
error (vertices may not even be sortable, so defaulting to doing that can 
really be a problem).

-- 
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/a1710359-d2ce-4a9f-87f3-4be4a1c6b296n%40googlegroups.com.


Re: [sage-devel] Re: DeprecationWarning on sagecell in Graph([(0,1)]).vertices()

2023-06-26 Thread Georgi Guninski
On Mon, Jun 26, 2023 at 4:40 PM kcrisman  wrote:

> As of https://github.com/sagemath/sage/issues/22349, this argument must be 
> explicitly specified (unless a "key" is given); otherwise a warning is 
> printed and "sort=True" is used. The default will eventually be changed to 
> "False".
>

I think this sucks.
Don't see any warning on version 9.6.

-- 
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/CAGUWgD9SNgTKkTh4fwekkJnuhFG92Qg0uppfkHEGkarBuN1zJg%40mail.gmail.com.


[sage-devel] Re: DeprecationWarning on sagecell in Graph([(0,1)]).vertices()

2023-06-26 Thread kcrisman

On Saturday, June 24, 2023 at 9:20:39 AM UTC-4 Georgi Guninski wrote:

https://sagecell.sagemath.org/ 

Graph([(0,1)]).vertices() 

/tmp/ipykernel_1853928/1298164553.py:1: DeprecationWarning: parameter 
'sort' will be set to False by default in the future 
See https://github.com/sagemath/sage/issues/22349 for details. 
Graph([(Integer(0),Integer(1))]).vertices() 

[0, 1] 


The docstring clarifies:

https://sagecell.sagemath.org/?z=eJxzV7BVcC9KLMjQiNYw0DHUjNXk5XLXK0stKslMTi22BwCCfwjO=sage=eJyLjgUAARUAuQ==

G = Graph([(0,1)])
G.vertices?

As of https://github.com/sagemath/sage/issues/22349, this argument must be 
explicitly specified (unless a "key" is given); otherwise a warning is 
printed and "sort=True" is used. The default will eventually be changed to 
"False". 

Interestingly, the example Harald cross-referenced 
at https://github.com/sagemathinc/cocalc/issues/6750 does not give this 
warning in the cell server.

-- 
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/be567bed-6911-42f7-a4cc-e075ba7ba2cdn%40googlegroups.com.