[sage-devel] Re: Dig through stack for printing an object?

2013-05-14 Thread Nils Bruin
On May 14, 10:01 pm, Simon King wrote: > Indeed, when I created the AttributeErrorMessage, it was suggested on > trac to use LazyString instead. It turns out that a special purpose > cythoned AttributeErrorMessage is faster, but I agree that in the > general case (when it makes no sense to have a

[sage-devel] Re: Dig through stack for printing an object?

2013-05-14 Thread Simon King
Hi Nils, On 2013-05-15, Nils Bruin wrote: > We already have a tool for delaying string assembly and it indeed > makes a difference in creating Exception objects: > > sage: from sage.misc.lazy_string import lazy_string > sage: f=lambda op,A,B:"unsupported operand parent(s) for '%s': '%s' > and '%s

[sage-devel] Re: QQ random_matrix()

2013-05-14 Thread Rob Beezer
The zeros problem is known: http://trac.sagemath.org/sage_trac/ticket/11968 I could be responsible for some of this - but not all, as the documentation was in even worse shape before I attacked it. I might be able to revist some of this soon, but not immediately. Rob On Thursday, May 9, 2013

[sage-devel] Re: QQ random_matrix()

2013-05-14 Thread Kenneth Lin
Has anyone taken a look at this or know what's wrong? Just wanted to bump this once if anyone missed it -- 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

[sage-devel] Re: Dig through stack for printing an object?

2013-05-14 Thread Nils Bruin
On May 14, 2:52 pm, Nils Bruin wrote: > On May 14, 2:13 pm, Simon King wrote: > > > There is a lazy object specially designed for attribute errors. See > > sage.structure.misc.AttributeErrorMessage. We already have a tool for delaying string assembly and it indeed makes a difference in creating

[sage-devel] Re: F(0)^0

2013-05-14 Thread Nils Bruin
On May 14, 3:34 pm, Mike OS wrote: > F. := GF(5) > F(0)^0 ... >   File "integer_mod.pyx", line 2381, in > sage.rings.finite_rings.integer_mod.IntegerMod_int.__pow__ > (sage/rings/finite_rings/integer_mod.c:20136) > ArithmeticError: 0^0 is undefined. I'm pretty sure that's not the error you got

[sage-devel] Re: Does anyone use SAGE_LOAD_ATTACH_PATH?

2013-05-14 Thread Ben Hutz
I have used it in the past, but not for anything essential. As long as there was support for a search path, that would be fine for me. On Tuesday, May 14, 2013 4:49:06 AM UTC-5, Volker Braun wrote: > > The plan would still be to support a search path, just not look at > (undocumented) shell envi

[sage-devel] F(0)^0

2013-05-14 Thread Mike OS
Hi All, A bug I think: 0^0 should be 1, right! QQ(0)^0 1 F. := GF(5) F(0)^0 Traceback (most recent call last): File "", line 1, in File "_sage_input_16.py", line 10, in exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(b

[sage-devel] Re: Dig through stack for printing an object?

2013-05-14 Thread Nils Bruin
On May 14, 2:13 pm, Simon King wrote: > There is a lazy object specially designed for attribute errors. See > sage.structure.misc.AttributeErrorMessage. Cool. Doesn't the coercion framework end up trying all kinds of things that may generate errors which get caught? Aren't those also different er

[sage-devel] Re: Dig through stack for printing an object?

2013-05-14 Thread Simon King
Hi Nils, On 2013-05-14, Nils Bruin wrote: > I think someone was considering using a "lazy" object as "message" > that would only materialize to a full string if it's really asked for. > Did we ever get to that? There is a lazy object specially designed for attribute errors. See sage.structure.mi

[sage-devel] Re: Dig through stack for printing an object?

2013-05-14 Thread Nils Bruin
On May 14, 11:35 am, Volker Braun wrote: > Don't do that. Exceptions should be short and to the point. And not do any > string processing. Don't convert passed values to strings unless you don't > care about performance. I agree, but it does happen. And as you see, matrix.__repr__ takes the whole

[sage-devel] Re: Integer vs. int in python

2013-05-14 Thread Eviatar
When you index an iterable the __index__ method is used, so Sage integers will work in many contexts. On Tuesday, 14 May 2013 12:06:35 UTC-7, John H Palmieri wrote: > > Why does Python handle Sage Integers well in some cases but not in others? > For example: > > $ sage --python > Python

[sage-devel] Re: Integer vs. int in python

2013-05-14 Thread Volker Braun
Anything that does isinstance(i,int) in the Python standard library is broken. Usually thats when multiple input types are allowed. In this case the argument to match.group() could be a string if you use the ?P syntax to name the match group. On Tuesday, May 14, 2013 8:06:35 PM UTC+1, John H

[sage-devel] Integer vs. int in python

2013-05-14 Thread John H Palmieri
Why does Python handle Sage Integers well in some cases but not in others? For example: $ sage --python Python 2.7.4 (default, May 8 2013, 16:25:06) [GCC 4.7.3] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from sage.all import Integer

[sage-devel] Re: Dig through stack for printing an object?

2013-05-14 Thread Volker Braun
On Tuesday, May 14, 2013 6:54:38 PM UTC+1, Nils Bruin wrote: > Not all "repr"s end up on a terminal, though. They can end up in > exception messages that get caught, processed, and never printed. Don't do that. Exceptions should be short and to the point. And not do any string processing. Don'

[sage-devel] Re: Dig through stack for printing an object?

2013-05-14 Thread Nils Bruin
On May 14, 10:02 am, Volker Braun wrote: > I have no opinion on whether or not to do that on each _repr_ call. It > doesn't do anything for me, but I don't see what the point of flooding the > terminal even faster is. Not all "repr"s end up on a terminal, though. They can end up in exception mess

[sage-devel] Re: Dig through stack for printing an object?

2013-05-14 Thread John H Palmieri
On Tuesday, May 14, 2013 9:39:22 AM UTC-7, Nils Bruin wrote: > How about just changing this to "(use str(...) to see all entries)", > where we rely on the intelligence of the user to interpret "..." to > mean 'whatever access you have to the matrix'. > > In principle a change like that sounds

[sage-devel] Re: Dig through stack for printing an object?

2013-05-14 Thread Volker Braun
I have no opinion on whether or not to do that on each _repr_ call. It doesn't do anything for me, but I don't see what the point of flooding the terminal even faster is. But I do think the functionality to dig for a variable name from an object is useful, and should be kept. On Tuesday, Ma

[sage-devel] Re: Dig through stack for printing an object?

2013-05-14 Thread Nils Bruin
Oh, and sage_getvariablename doesn't quite live up to its advertised API either: sage: L=["hi"] sage: _T=L[0] sage: sage.misc.sageinspect.sage_getvariablename(L[0],omit_underscore_names=True) '_T' -- You received this message because you are subscribed to the Google Groups "sage-devel" group. T

[sage-devel] Dig through stack for printing an object?

2013-05-14 Thread Nils Bruin
On http://trac.sagemath.org/sage_trac/ticket/14579 I noticed that sage is doing something very fancy to produce a short "repr" of a large matrix: It doesn't print the entries (I knew that), but it even goes delving in the stack to see if it can find a name to which the matrix might possibly be boun

[sage-devel] mathfest 2013

2013-05-14 Thread John Travis
I'll be there. John T -- 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 post to this group, send email to sage-devel@goo

[sage-devel] Re: Orderings and dictionaries

2013-05-14 Thread Nils Bruin
On May 14, 3:42 am, Jernej Azarija wrote: > This is what the guys on #python (IRC) told me to consider > > >>> d1 = {-1: 0, -2: 0}>>> d2 = {-2: 0, -1: 0}>>> d1{-2: 0, -1: 0}>>> d2{-1: > >>> 0, -2: 0}>>> d1 == d2True>>> d1.keys()[-2, -1]>>> d2.keys()[-1, -2]>>> That is an extremely sneaky example

[sage-devel] Re: [sage-combinat-devel] use Sage!

2013-05-14 Thread David Joyner
Hi WIlliam: I'm curious, is there any further progress on this plan of a Use Sage! series at Springer? - David On Thu, May 2, 2013 at 4:27 PM, William Stein wrote: > Hi Sage-Developers, > > There is a big series of small books about R that Springer publishes: > > http://www.springer.com/series/

Re: [sage-devel] Backspace Key in Notebook

2013-05-14 Thread manday
Could anyone have a look at this? Needless to say, this is *extremely* annoying. Every few minutes the notebook gets completely messed up with this bug. I can forgo the Backspace Key, but I need to press Enter, and that just breaks in the middle of a block then and I'm left with a complete d u

[sage-devel] Re: Orderings and dictionaries

2013-05-14 Thread Nathann Cohen
d1 = {-1: 0, -2: 0} d2 = {-2: 0, -1: 0} d1 > {-2: 0, -1: 0} d2 > {-1: 0, -2: 0} d1 == d2 > True d1.keys() > [-2, -1] d2.keys() > [-1, -2] NOooo Ookokokokok. Then the code is good a

[sage-devel] Re: Orderings and dictionaries

2013-05-14 Thread Jernej Azarija
This is what the guys on #python (IRC) told me to consider >>> d1 = {-1: 0, -2: 0}>>> d2 = {-2: 0, -1: 0}>>> d1{-2: 0, -1: 0}>>> d2{-1: 0, >>> -2: 0}>>> d1 == d2True>>> d1.keys()[-2, -1]>>> d2.keys()[-1, -2]>>> On Tue, May 14, 2013 at 12:12 PM, Nathann Cohen wrote: > Hello everybody

[sage-devel] Re: Orderings and dictionaries

2013-05-14 Thread luisfe
No, you cannot. You should always think dictionaries as unordered structures. Dictionary keys depend not only on the keys themselves but on the operations performed on the dictionary. Take a simple case with hash collision: {{{ sage: A={} sage: B={} sage: A[hash('a')]=0 sage: A['a']=1 sage: B['a']

Re: [sage-devel] Re: SQRT of negative number is negative? Or positive? Or what?

2013-05-14 Thread Ralf Hemmecke
> does Axiom have Coercion? You surely have never looked into AXIOM. http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.132.4943&rep=rep1&type=pdf > How does it handle this? > http://www.sagemath.org/doc/reference/coercion/sage/structure/coerce.html It depends on how much automatic coerci

Re: [sage-devel] Orderings and dictionaries

2013-05-14 Thread Jeroen Demeyer
On 05/14/2013 12:12 PM, Nathann Cohen wrote: Hello everybody ! I've got a small Python question whose answer you probably know. Given a dictionary my_dict, I cannot expect my_dict.values() to always return its elements in the same ordering, as I understand it depends on the ordering of

[sage-devel] Orderings and dictionaries

2013-05-14 Thread Nathann Cohen
Hello everybody ! I've got a small Python question whose answer you probably know. Given a dictionary my_dict, I cannot expect my_dict.values() to always return its elements in the same ordering, as I understand it depends on the ordering of the keys which is machine-dependent. This bein

[sage-devel] Re: Does anyone use SAGE_LOAD_ATTACH_PATH?

2013-05-14 Thread Volker Braun
The plan would still be to support a search path, just not look at (undocumented) shell environment variables for it. So you'll still be able to set a search path via a python function either from init.sage or the attached source code. On Tuesday, May 14, 2013 10:41:24 AM UTC+1, leif wrote: >

[sage-devel] Does anyone use SAGE_LOAD_ATTACH_PATH?

2013-05-14 Thread leif
For its purpose, see the docstring for /the preparser's/ 'load' (e.g. by typing 'sage.misc.preparser.load?' at the Sage prompt, or see [2]), or that of 'reset_load_attach_path' (which in contrast is directly accessible) [3]. (This environment variable isn't documented anywhere else in /Sage's

Re: [sage-devel] SQRT of negative number is negative? Or positive? Or what?

2013-05-14 Thread Marco Streng
As for the question "html( "In which kind of school do they teach $\\sqrt{-2.4995} = - i 1.58$ ???" );", I think any good school that teaches about complex numbers should teach that both - i 1.58 and i 1.58 are equally valid (approximate) square roots of -2.4995. One choice is as good as another. A

[sage-devel] Re: SQRT of negative number is negative? Or positive? Or what?

2013-05-14 Thread Harald Schilly
On Tuesday, May 14, 2013 2:22:07 AM UTC+2, rjf wrote: > > So far > as I can tell, Python offers no step forward, and maybe a step backward. > Sage != Python. Apart from that, does Axiom have Coercion? How does it handle this? http://www.sagemath.org/doc/reference/coercion/sage/structure/coerce.