Re: [sage-devel] Sorting strings and integers

2017-08-09 Thread Jeroen Demeyer
On 2017-08-08 00:43, Stefan wrote: P.S. The Graph class does way too much sorting. See e.g. sage.graphs.generic_graph.GenericGraph.vertices() I created https://trac.sagemath.org/ticket/22349 for that. -- You received this message because you are subscribed to the Google Groups "sage-devel" gr

Re: [sage-devel] Sorting strings and integers

2017-08-08 Thread Erik Bray
On Tue, Aug 8, 2017 at 7:54 AM, Daniel Krenn wrote: > On 2017-08-07 22:53, David Roe wrote: >> >>> sorted([1,2,'a']) >> Traceback (most recent call last): >> File "", line 1, in >> TypeError: '<' not supported between instances of 'str' and 'int' >> [...] >> Which still leaves t

Re: [sage-devel] Sorting strings and integers

2017-08-07 Thread Daniel Krenn
On 2017-08-07 22:53, David Roe wrote: > >>> sorted([1,2,'a']) > Traceback (most recent call last): > File "", line 1, in > TypeError: '<' not supported between instances of 'str' and 'int' > [...] > Which still leaves the second part of Stefan's question: how do we get > consiste

Re: [sage-devel] Sorting strings and integers

2017-08-07 Thread Jori Mäntysalo
On Mon, 7 Aug 2017, David Roe wrote: Yet for a user looking at the examples of using such a function, it's nicer to see sage: my_func(inputs) # unordered [A, C, B] rather than sage: set([str(c) for c in my_func(inputs)]) == set(["A","B","C"]) True Maybe just EXAMPLES:: sage: my_func(

Re: [sage-devel] Sorting strings and integers

2017-08-07 Thread Stefan
> What bad practice are you referring to? The output of some functions are > lists where the ordering is somewhat unpredictable. This different > ordering can reveal itself in testing on different platforms, or with a > changed package that Sage depends on. Yet for a user looking at the >

Re: [sage-devel] Sorting strings and integers

2017-08-07 Thread David Roe
On Mon, Aug 7, 2017 at 5:14 PM, Vincent Delecroix <20100.delecr...@gmail.com > wrote: > On 07/08/2017 23:11, David Roe wrote: > >> On Mon, Aug 7, 2017 at 5:03 PM, Vincent Delecroix < >> 20100.delecr...@gmail.com >> >>> wrote: >>> >> >> On 07/08/2017 22:53, David Roe wrote: >>> >>> On Mon, Aug 7, 2

Re: [sage-devel] Sorting strings and integers

2017-08-07 Thread Vincent Delecroix
On 07/08/2017 23:11, David Roe wrote: On Mon, Aug 7, 2017 at 5:03 PM, Vincent Delecroix <20100.delecr...@gmail.com wrote: On 07/08/2017 22:53, David Roe wrote: On Mon, Aug 7, 2017 at 4:37 PM, Vincent Delecroix < 20100.delecr...@gmail.com wrote: On 07/08/2017 19:47, David Roe wrote:> Bu

Re: [sage-devel] Sorting strings and integers

2017-08-07 Thread David Roe
On Mon, Aug 7, 2017 at 5:03 PM, Vincent Delecroix <20100.delecr...@gmail.com > wrote: > On 07/08/2017 22:53, David Roe wrote: > >> On Mon, Aug 7, 2017 at 4:37 PM, Vincent Delecroix < >> 20100.delecr...@gmail.com >> >>> wrote: >>> >> >> On 07/08/2017 19:47, David Roe wrote:> But I think that Sage >

Re: [sage-devel] Sorting strings and integers

2017-08-07 Thread Vincent Delecroix
On 07/08/2017 22:53, David Roe wrote: On Mon, Aug 7, 2017 at 4:37 PM, Vincent Delecroix <20100.delecr...@gmail.com wrote: On 07/08/2017 19:47, David Roe wrote:> But I think that Sage integers should compare the same as python ints I agree and with Python 3 you get an error $ python Pytho

Re: [sage-devel] Sorting strings and integers

2017-08-07 Thread David Roe
On Mon, Aug 7, 2017 at 4:37 PM, Vincent Delecroix <20100.delecr...@gmail.com > wrote: > On 07/08/2017 19:47, David Roe wrote:> But I think that Sage > >> integers should compare the same as python ints >> > I agree and with Python 3 you get an error > > $ python > Python 3.6.2 (default, Jul 20 201

Re: [sage-devel] Sorting strings and integers

2017-08-07 Thread Vincent Delecroix
On 07/08/2017 19:47, David Roe wrote:> But I think that Sage integers should compare the same as python ints I agree and with Python 3 you get an error $ python Python 3.6.2 (default, Jul 20 2017, 03:52:27) [GCC 7.1.1 20170630] on linux Type "help", "copyright", "credits" or "license" for more

Re: [sage-devel] Sorting strings and integers

2017-08-07 Thread David Roe
This does seem to be new. In Sage 7.2 (just one that I had handy), sage: sorted([1,2,'a']) [1, 2, 'a'] sage: sorted([1r,2r,'a']) [1, 2, 'a'] This isn't that surprising, since the semantics of comparison have been changing because of the upcoming switch to python 3. But I think that Sage integers

[sage-devel] Sorting strings and integers

2017-08-07 Thread Stefan
Is this behavior new? I got it on my MacBook running the latest development version. And, more importantly, what is the recommended way of writing doctests for functions that return frozen sets with strings and integers? In particular in light of Python 3 coming up... sage: sorted([1,2,'a'])