On Tue, Oct 20, 2009 at 11:22 AM, mhampton <hampto...@gmail.com> wrote:
>
> OK, I can reproduce that - I got an error after the first cell.
>
> After saving & quitting, and deleting the line:
> reset()
>
> then re-launching that worksheet everything seems to work fine.  So I
> think this is something about the reset() function.  I've never used
> it before, so I am not sure what it is doing that messes things up.
>
> Do your problem-causing worksheets always have reset() in them
> somewhere?

Reset would do things like deleting sagenb from the globals()
namespace, which would exactly cause the problem you suggest!   This
can certainly be fixed though, i.e., by making reset a little more
intelligent.

> -Marshall
>
> On Oct 20, 12:02 pm, William Stein <wst...@gmail.com> wrote:
>> On Tue, Oct 20, 2009 at 10:37 AM, lutusp <lut...@gmail.com> wrote:
>>
>> > Hello all:
>>
>> > Today I decided to try out the new VirtualBox/PuppyLinux virtual
>> > machine for Windows users. It seems much nicer than the prior version
>> > and I want to update my tutorial to make reference to it.
>>
>> > Also I wanted to see if I experienced the same issue I've been
>> > experiencing with 4.1.2 running (or not running) my existing 4.1.1
>> > worksheets, e.g. a message saying "NameError: name 'sagenb' is not
>> > defined" on execution of a rather complex cell.
>>
>> Can you enter your example athttp://demo.sagenb.orgor paste it to
>> pastebin, or paste a link to it online.  By just pasting it in an
>> email it gets word wrapped, which yields it suspect.
>>
>> William
>>
>>
>>
>>
>>
>> > Imagine my surprise when I ran the new VM using VirtualBox under
>> > Windows, uploaded my worksheets into it, and got the same result as on
>> > my usual Fedora 11 platform: "NameError: name 'sagenb' is not
>> > defined". This is true for any worksheet cell above a certain
>> > complexity level (or a series of such cells).
>>
>> > So I tried a few different ways to transfer the worksheets. I used the
>> > 4.1.2 "download all" feature to create a zip file of all my worksheets
>> > and uploaded them all into the PuppyLinux/VirtualBox Sage VM runnin
>> > gunder Windows, but with the same result.
>>
>> > Then I ran Sage 4.1.1 and created a zip archive of the old (4.1.1)
>> > versions of the worksheets and tried uploading them into the
>> > VirtualBox/PuppyLinux Sage 4.1.2 version, but that caused Sage to lock
>> > up with a message saying "Searching for Sage Server ...". Things went
>> > downhill from there and I finally had to reinstall the Sage VM under
>> > VirtualBox. Which leads me to offer this warning -- don't try to
>> > transfer pre-4.1.2 worksheets using the browser-based download/upload
>> > cycle, as this may well disable the VM under Windows and require
>> > reinstallation.
>>
>> The install of Sage in the virtual machine is read only, so it cannot
>> be "messed up".
>> I guess in theory the notebook state file in
>> /root/sage_notebook.sagenb could get
>> messed up though in some way that could make it so the server doesn't
>> startup properly (say after a reboot), though I can't imagine anyway
>> that could possibly happen through the notebook.
>>
>> How many worksheets are you uploading at once?   The code is certainly
>> there (I wrote it and many of us tested it) so one can upload <= 4.1.1
>> worksheets into 4.1.2.
>>
>>
>>
>> > Summary of the problem: basically, for any invocation of Sage 4.1.2,
>> > it seems some worksheets, above a certain complexity level, will /
>> > always/ cause the error described above.
>>
>> > Here is a simple duplication procedure for anyone running Sage 4.1.2
>> > -- it involves creating a new, empty worksheet, pasting the two cell
>> > contents below into it, and executing them.
>>
>> > 1. Create a new, empty worksheet under Sage 4.1.2.
>>
>> > 2. Copy the content shown below between the asterisk lines into two
>> > separate Sage worksheet cells.
>>
>> > 3. Execute the first cell -- sometimes this causes the error message,
>> > sometimes not.
>>
>> > 4. Execute the second cell -- this always creates the error message
>> > (in my experience).
>>
>> > ******************* BEGIN Cell 1 content
>> > ********************************
>> > %auto
>> > reset()
>> > forget()
>> > # special equation rendering
>> > def render(x,name = "temp.png",size = "normal"):
>> >    if(type(x) != type("")): x = latex(x)
>> >    latex.eval("\\" + size + " $" + x + "$",{},"",name)
>> > var('a b c d e f g h j k l x y z')
>>
>> > class Pair:
>> >    def __init__(self,d):
>> >        self.x = d[0]
>> >        self.y = d[1]
>> >    def __repr__(self):
>> >        return "%e,%e" % (self.x,self.y)
>>
>> > def show_mat(data):
>> >    yt = len(data)
>> >    xt = len(data[0])
>> >    for y in range(yt):
>> >        for x in range(xt):
>> >            sys.stdout.write("%12g " % data[y][x])
>> >        print("")
>> >    print("****")
>>
>> > def show_mat_latex(data,fn):
>> >    yt = len(data)
>> >    xt = len(data[0])
>> >    ya = []
>> >    for y in range(yt):
>> >        xa = []
>> >        for x in range(xt):
>> >            xa.append("%12g " % data[y][x])
>> >        ya.append(join(xa," & "))
>> >    ys = join(ya,"\\\\")
>> >    # specify right justification
>> >    cstr = "r" * xt
>> >    mat = "$\\left( \\begin{array}{%s}" % cstr
>> >    mat += ys
>> >    mat += "\\end{array}\\right)$"
>> >    render(mat,fn)
>> >    print ""
>>
>> > # example data
>> > data1 = [
>> >    [-1,-1],
>> >    [0,3],
>> >    [1,2.5],
>> >    [2,5],
>> >    [3,4],
>> >    [5,2],
>> >    [7,5],
>> >    [9,4]
>> > ]
>>
>> > def set_data(x):
>> >    return [Pair(n) for n in x]
>>
>> > # polynomial regression of order "p"
>> > def polyregress(data,p,debug = False):
>> >    # matrix rows and columns = p+1
>> >    p += 1
>> >    n = len(data)
>> >    # precalculate matrix cell data array
>> >    mda = [n] + [sum(data[a].x^b for a in range(n)) for b in range
>> > (1,2*p-1)]
>> >    # create/populate square matrix with appended column
>> >    m = [[mda[r+c] for c in range(p)] + [0.0] for r in range(p)]
>> >    if debug: show_mat_latex(m,"nmat2.png")
>> >    # populate RH appended column
>> >    for v in data: m[0][p] += v.y
>> >    for r in range(1,p):
>> >        m[r][p] = sum(v.x^r*v.y for v in data)
>> >    if debug: show_mat_latex(m,"nmat3.png")
>> >    # reduce matrix
>> >    mm=Matrix(RR,m)
>> >    mm.echelonize()
>> >    if debug: show_mat_latex(mm.rows(),"nmat4.png")
>> >    # extract result column
>> >    a = mm.column(p).list()
>> >    # build term list
>> >    y = 0
>> >    for j in range(p):
>> >        y += a[j]*x^j
>> >    return y
>>
>> > # correlation coefficient (r^2)
>> > def corr_coeff(data,fy):
>> >    r = 0
>> >    sx = sx2 = sy = sy2 = sxy = 0
>> >    n = len(data)
>> >    for v in data:
>> >        x = fy(x=v.x)
>> >        y = v.y
>> >        sx += x
>> >        sy += y
>> >        sxy += x * y
>> >        sx2 += x * x
>> >        sy2 += y * y
>> >    divisor = sqrt((sx2 - (sx*sx)/n) * (sy2 - (sy*sy)/n))
>> >    if(divisor != 0):
>> >        r = ((sxy-(sx*sy)/n)/divisor)^2
>> >    return r
>>
>> > # standard error
>> > def std_error(data,fy):
>> >    r = 0
>> >    n = len(data);
>> >    if(n > 2):
>> >        a = 0
>> >        for v in data:
>> >            a += (fy(x=v.x) - v.y)^2
>> >        r = sqrt(a/(n-2))
>> >    return r
>>
>> > # data range
>> > def list_minmax(data):
>> >    max = -1e6
>> >    min = 1e6
>> >    for v in data:
>> >        if(max < v.x): max = v.x
>> >        if(min > v.x): min = v.x
>> >    return(min,max)
>> > ******************* END Cell 1 content
>> > **********************************
>>
>> > ******************* BEGIN Cell 2 content
>> > ********************************
>> > # interactive version
>> > data = set_data(data1)
>> > mp = len(data)-1
>> > @interact
>> > def _(p = (0..mp)):
>> >    y = polyregress(data,p)
>> >    dp = list_plot([[data[n].x,data[n].y] for n in range(len
>> > (data))],rgbcolor='red')
>> >    lp = plot(y,x,list_minmax(data))
>> >    cc = corr_coeff(data,y)
>> >    se = std_error(data,y)
>> >    lbl = text("correlation coefficient (r^2): %f\nStandard error: %f"
>> >    % (cc,se),(5,-2),rgbcolor='black',fontsize=10)
>> >    show(dp+lp+lbl,ymin=-5,ymax=7)
>> > ******************* END Cell 2 content
>> > **********************************
>>
>> > After copying, pasting and running the two cells, you should see the
>> > error message "NameError: name 'sagenb' is not defined" after either
>> > running the first or second cell. And once the message has appeared,
>> > it will appear on an attempt to run any subsequent cell, like this
>> > one:
>>
>> > 2^32
>>
>> > I think this is an actual bug, not a transient artifact of a
>> > particular installation.
>>
>> > Other notes:
>>
>> > 1. The file README.txt bundled with the new Sage/Puppy Linux/
>> > VirtualBox virtual machine has Linux line endings, needs to be
>> > converted using "unix2dos" for Windows users. The file is an important
>> > rundown on how to install the VM, and the default Windows text editor
>> > is too dumb to sort out line endings.
>>
>> > 2. Under Windows and while using MSIE 8, on creating a new worksheet,
>> > the popup dialog to enter a name is suppressed by default and this
>> > cannot be overridden for some reason. But the worksheet can be renamed
>> > later using the File menu.
>>
>> > 3. Moving to Puppy Linux and VirtualBox was a smart move. They are
>> > both better choices that the previous arrangement.
>>
>> > Thanks for reading!
>>
>> --
>> William Stein
>> Associate Professor of Mathematics
>> University of Washingtonhttp://wstein.org
> >
>



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

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to