NameError: name 'Integer' is not defined

1,842 views
Skip to first unread message

Kevin Horton

unread,
May 18, 2009, 6:20:18 PM5/18/09
to spd...@googlegroups.com
Now that I have the notebook running, I am trying a few tests, to see
what works, and what doesn't. The following fails:

from math import *
from pylab import plot, savefig, grid
y=sin(x*pi/180)
plot(y,0,360)
grid(True)
savefig("a.png")

The result is:

Traceback (most recent call last): y=sin(x*pi/180)
NameError: name 'Integer' is not defined

======================
I assume I need to install another spkg. Which one? The sage package?
If so, should I expect it to build without having first installed a
whole bunch of other packages?

--
Kevin Horton
Ottawa, Canada

William Stein

unread,
May 18, 2009, 7:21:19 PM5/18/09
to spd...@googlegroups.com
On Mon, May 18, 2009 at 3:20 PM, Kevin Horton <khor...@rogers.com> wrote:
>
> Now that I have the notebook running, I am trying a few tests, to see
> what works, and what doesn't.  The following fails:
>
> from math import *
> from pylab import plot, savefig, grid
> y=sin(x*pi/180)
> plot(y,0,360)
> grid(True)
> savefig("a.png")
>
> The result is:
>
> Traceback (most recent call last):    y=sin(x*pi/180)
> NameError: name 'Integer' is not defined

Just out of curiosity, if you do

Integer =int
RealNumber = float

and try the code above again, what happens?

Also, did you set the notebook to *Python* mode instead of Sage mode?

>
> ======================
> I assume I need to install another spkg.  Which one?  The sage package?
> If so, should I expect it to build without having first installed a
> whole bunch of other packages?
>
> --
> Kevin Horton
> Ottawa, Canada
>
>
> >
>



--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

Ondrej Certik

unread,
May 18, 2009, 7:37:31 PM5/18/09
to spd...@googlegroups.com
On Mon, May 18, 2009 at 4:21 PM, William Stein <wst...@gmail.com> wrote:
>
> On Mon, May 18, 2009 at 3:20 PM, Kevin Horton <khor...@rogers.com> wrote:
>>
>> Now that I have the notebook running, I am trying a few tests, to see
>> what works, and what doesn't.  The following fails:
>>
>> from math import *
>> from pylab import plot, savefig, grid
>> y=sin(x*pi/180)
>> plot(y,0,360)
>> grid(True)
>> savefig("a.png")
>>
>> The result is:
>>
>> Traceback (most recent call last):    y=sin(x*pi/180)
>> NameError: name 'Integer' is not defined
>
> Just out of curiosity, if you do
>
> Integer =int
> RealNumber = float
>
> and try the code above again, what happens?
>
> Also, did you set the notebook to *Python* mode instead of Sage mode?

the notebook is set to Python mode by default. The above code doesn't
work for me, but it's because "x" is not defined. See the attached
screenshot.

Could you please try the sample code from the SPD front page:

http://code.google.com/p/spdproject/

? If you follow the instructions exactly, it should just work. Then
you can start to modify it for your needs.

Ondrej

spd.png

Kevin Horton

unread,
May 18, 2009, 6:53:49 PM5/18/09
to spd...@googlegroups.com
William Stein wrote:
> On Mon, May 18, 2009 at 3:20 PM, Kevin Horton <khor...@rogers.com> wrote:
>
>> Now that I have the notebook running, I am trying a few tests, to see
>> what works, and what doesn't. The following fails:
>>
>> from math import *
>> from pylab import plot, savefig, grid
>> y=sin(x*pi/180)
>> plot(y,0,360)
>> grid(True)
>> savefig("a.png")
>>
>> The result is:
>>
>> Traceback (most recent call last): y=sin(x*pi/180)
>> NameError: name 'Integer' is not defined
>>
>
> Just out of curiosity, if you do
>
> Integer =int
> RealNumber = float
>
> and try the code above again, what happens?
>
Now I get:

Traceback (most recent call last): Integer =int


NameError: name 'Integer' is not defined

> Also, did you set the notebook to *Python* mode instead of Sage mode?
>

I left it in whichever mode it starts up in by default. The sage
preprocessor isn't working, as I need to use ** for powers, if that
tells us anything useful.

Kevin Horton

unread,
May 18, 2009, 6:58:50 PM5/18/09
to spd...@googlegroups.com
Yes, that code works. I was experimenting with code that works in Sage,
to help me understand the differences in the two environments.

Ondrej Certik

unread,
May 18, 2009, 8:14:17 PM5/18/09
to spd...@googlegroups.com

Ok, excellent. SPD doesn't contain Sage, it's just a Python and then
it contains some other libraries like numpy, scipy and sympy.

If you need the Sage functionality, you have to use the full Sage.


Ondrej

Reply all
Reply to author
Forward
0 new messages