[sage-support] Re: Installing optional R package on sagenb.org

2009-01-09 Thread ztnews

I had a similar failure today, trying to:

r.install_packages("adapt")

after some fussing, runing ./sage as root, and using the notebook
interface I could get through the download phase, but same sorts of
failures in just as the gcc kicks in.  Seems several of the key R
scripts have "/home/wstein/..."  hard wired in to R_HOME_XXX, which
obviously will fail.  I tried editing the R startup scripts (among
others) but couldn't get it to work.

BTW, I installed from the latest Debian tarball into a Debian/VMWARE
machine just today.  So installing R packages is still an issue.

  -  Cronin


William Stein wrote:
> On Fri, Jan 2, 2009 at 6:57 PM, kcrisman  wrote:
> >
> > Dear support,
> > Because I only have OSX and there is this scary warning about it in
> > the documentation for r.install_packages (which incidentally the test
> > for it has no "s", but I don't know if that matters), I was trying to
> > load one on the sagenb site.  Probably this is a gross violation of
> > bandwidth or something,
>
> It will surely fail with a permission denied error at some point.  What
> package would you like to install?
>
> > but anyway the surprise result under the R
> > interface was
> >
> > install_packages(MASS)
> > Error: could not find function "install_packages"
>
> Try typing
>
> r.install_packages("MASS")
>
> in a normal Sage input cell.  You probably forgot the quotes.
>
> Trying this on OS X it definitely fails for me.  There is this message:
>
> "sage: r.install_packages("MASS")
> ** You are using OS X.  Unfortunately, the R optional package system
> currently doesn't support OS X very well.  We are working on this. **"
>
> I wonder who the "We" refers to?  :-)
>
> I tried the above on sagenb.org (I'm the admin, so I have permissions).
> It seems to fail as well:
>
> s...@sagenb:~$ sage
> --
> | Sage Version 3.2.2, Release Date: 2008-12-18   |
> | Type notebook() for the GUI, and license() for information.|
> --
> sage: r.install_packages("MASS")
> 0.00user 0.02system 0:00.03elapsed 82%CPU (0avgtext+0avgdata 0maxresident)k
> 64inputs+0outputs (1major+209minor)pagefaults 0swaps
>
> R version 2.6.1 (2007-11-26)
> Copyright (C) 2007 The R Foundation for Statistical Computing
> ISBN 3-900051-07-0
>
> R is free software and comes with ABSOLUTELY NO WARRANTY.
> You are welcome to redistribute it under certain conditions.
> Type 'license()' or 'licence()' for distribution details.
>
>   Natural language support but running in an English locale
>
> R is a collaborative project with many contributors.
> Type 'contributors()' for more information and
> 'citation()' on how to cite R or R packages in publications.
>
> Type 'demo()' for some demos, 'help()' for on-line help, or
> 'help.start()' for an HTML browser interface to help.
> Type 'q()' to quit R.
>
> > options(repos="http://cran.r-project.org/";); install.packages("MASS")
> trying URL 'http://cran.r-project.org/src/contrib/VR_7.2-45.tar.gz'
> Content type 'application/x-gzip' length 465054 bytes (454 Kb)
> opened URL
> ==
> downloaded 454 Kb
>
> WARNING: ignoring environment value of R_HOME
> /home/sage/sage/local/lib/R/library
> WARNING: ignoring environment value of R_HOME
> * Installing *source* package 'MASS' ...
> ** libs
> gcc -std=gnu99 -I/home/sage/sage/local/lib/R/include
> -I/home/sage/sage/local/lib/R/include  -I/home/sage/sage/local/inlcude
> WARNING: ignoring environment value of R_HOME   -fpic
> -I/home/sage/sage/local/include -L/home/sage/sage/local/lib/  -c lqs.c
> -o lqs.o
> gcc: WARNING:: No such file or directory
> gcc: ignoring: No such file or directory
> gcc: environment: No such file or directory
> gcc: value: No such file or directory
> gcc: of: No such file or directory
> gcc: R_HOME: No such file or directory
> make: *** [lqs.o] Error 1
> ERROR: compilation failed for package 'MASS'
> ** Removing '/home/sage/sage/local/lib/R/library/MASS'
> ** Removing '/home/sage/sage/local/lib/R/library/class'
> ** Removing '/home/sage/sage/local/lib/R/library/nnet'
> ** Removing '/home/sage/sage/local/lib/R/library/spatial'
>
> The downloaded packages are in
>   /tmp/RtmpoUnbs5/downloaded_packages
> Updating HTML index of packages in '.Library'
> Warning message:
> In install.packages("MASS") :
>   installation of package 'VR' had non-zero exit status
> >
>
>
>
> >
> > which was surprising since tab-completion was how I found this
> > function in the first place.  I also got this in the Sage interface
> > with r.install_packages.
> >
> > If anyone knows how I might do this, or if it's not good to do, or
> > whether my Mac will actually allow me to install the optional package
> > after all, OR whether Sage actually includes these by default (which
> > doesn't seem to be the case, but I might have typed something wrong),
> > I would greatly

[sage-support] Re: "Drop-in" Python scripts?

2009-01-09 Thread ztnews

Thanks, guys, for the tips.  Yes, that harrison.py script I grabbed is
dated 1999(!), so no wonder it had some deprecated dependencies
(Numeric & LinearAlgebra).  Curious, tho, that two Python installs of
mine (one in Debian and another in Vista) handled the originals just
fine.

I also figured out the gnuplot issue.  I was running SAGE on the
VMWARE virtual machine, so my browser was on a different machine.  The
script generated gnuplot would show up in the VMWARE machine, and
never on my browser.

So, I've installed SAGE in a full Debian install I have (also VMWARE),
and the gnuplot stuff works as expected: pops up a plot on the machine
running SAGE.

On the whole, I'd have to say the compatibility with native Python
scripts is not bad.

Thanks again for the tips.

  -  Cronin

On Jan 8, 2:40 pm, mabshoff  wrote:
> On Jan 8, 12:03 pm, ztnews  wrote:
>
> Hi,
>
> > Forgive me if this is too obvious.  I'm still evaluating/learning the
> > basics of SAGE
>
> No problem, this is what a support group is for :)
>
> > Just how compatible is SAGE with Python?  By which I mean, should I be
> > able to just "drop-in" an existing/working python script and have it
> > run, or should I expect some modifications will be required?  And if
> > so, what's the major things I need to keep an eye out for?
>
> One thing is that you need to deal with some numerical types, i.e.
>
> sage: j=numpy.complex(0,1)
> sage: RealNumber=float
> sage: Integer=int
>
> Seehttp://www.math.washington.edu/~jkantor/Numerical_Sage/node3.html
> for more info on that.
>
>
>
> > I've looked in the documents, particularly "Coding in Python for Sage"
>
> >http://www.sagemath.org/doc/prog/node15.html
>
> > I'll illustrate by example.  I found a Python script that does a
> > physics calculation (band structure of silicon)
>
> >http://www.wag.caltech.edu/home/rpm/projects/tight-binding/harrison.py
>
> > or see here for a discussion of the script:
>
> >http://www.wag.caltech.edu/home/rpm/projects/tight-binding/
>
> > I've successfully run harrison.py (without modification) using both
> > linux and windows-based python installations.  But under SAGE (I've
> > installed the latest vmware version) required a little diddling to get
> > it (mostly) running.
>
> > Two points. 1) This script calls for modules "Numeric" and
> > "LinearAlgebra"
>
> > from Numeric import *        # Make sure that NumPy is in your
> > from LinearAlgebra import eigenvalues
>
> Numeric is the predecessor to NumPy which is in Sage. Nunmeric used to
> be at least an optional spkg for Sage, but I am not sure if it still
> works. Installing Numeric should be possible, but AFAIK this is
> seriously outdated code.
>
> > both of which failed in SAGE.  A couple minor modifications and I got
> > past those points.  I suspect these are deprecated, but still the
> > Python installations handled the script without mods.
>
> You probably have either Numeric or an older numpy installed, but I am
> not an expert about the finer details of what numeric code works with
> that numpy release (if at all)
>
> > 2) The other thing that failed was the system call to gnuplot at the
> > end of the script.  I can imagine that would be hard make work in a
> > SAGE-notebook environment, and I haven't managed that.
>
> Do you have gnuplot installed? If so what are the failures? Did the
> gnuplot part of script work with the pure Python env?
>
> > Now, my point here is not that I need that script to run,
> > particularly.  My question is about compatibility.  Have I missed
> > something about how to execute a Python script with the minimum of
> > modifications?
>
> Without going into specifics Sage ships a subset of what the usual
> distributions ship for python modules, but adds some unusual ones that
> aren't in every distribution. You can install pretty much any Python
> module by running
>
>  ./sage -sh
>  cd into unpacked python module directory
>  python setup.py install
>
> There might be problems with dependencies and so on, but for most pure
> Python code this should work really well.
>
> > Thanks for your time.  BTW, SAGE is really impressive.
>
> :)
>
> Cheers,
>
> Michael
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] question about solve() function

2009-01-09 Thread Sand Wraith

Hi!

Is it possible to get order of root of equation? For example equation:

f(x)=(x+1)^2
and it's solution "solve(f,x)" will be "[x == -1]", but this is not
perfect clear, because x==-1 have second order. This equation actually
must have two same roots: [x == -1,x == -1].

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



[sage-support] why doesn`t solve() give a proper answer

2009-01-09 Thread Slava

Hello.
I`m trying to solve such simple system of equations: [sqrt(x) == 1, x
== y],
so I type:

x,y = var('x,y');
solve([sqrt(x) == 1, x == y], x, y);

the answer is: []
(just two brackets)

How to make it work?

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



[sage-support] Re: question about solve() function

2009-01-09 Thread William Stein

On Fri, Jan 9, 2009 at 3:49 AM, Sand Wraith  wrote:
>
> Hi!
>
> Is it possible to get order of root of equation? For example equation:
>
> f(x)=(x+1)^2
> and it's solution "solve(f,x)" will be "[x == -1]", but this is not
> perfect clear, because x==-1 have second order. This equation actually
> must have two same roots: [x == -1,x == -1].

Use the roots command:

sage: f = (x + 1)^2
sage: f.roots()
[(-1, 2)]

The 2 is the multiplicity.

William

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



[sage-support] Re: Installing optional R package on sagenb.org

2009-01-09 Thread William Stein

On Fri, Jan 9, 2009 at 1:19 AM, ztnews  wrote:
>
> I had a similar failure today, trying to:
>
> r.install_packages("adapt")
>
> after some fussing, runing ./sage as root, and using the notebook
> interface I could get through the download phase, but same sorts of
> failures in just as the gcc kicks in.  Seems several of the key R
> scripts have "/home/wstein/..."  hard wired in to R_HOME_XXX, which
> obviously will fail.  I tried editing the R startup scripts (among
> others) but couldn't get it to work.
>
> BTW, I installed from the latest Debian tarball into a Debian/VMWARE
> machine just today.  So installing R packages is still an issue.
>
>  -  Cronin

I made this trac #4959:

http://trac.sagemath.org/sage_trac/ticket/4959

Michael -- I hope there wasn't already a ticket for this in trac --
it's impossible to search for "r".
I couldn't find anything under install_packages.

>
>
> William Stein wrote:
>> On Fri, Jan 2, 2009 at 6:57 PM, kcrisman  wrote:
>> >
>> > Dear support,
>> > Because I only have OSX and there is this scary warning about it in
>> > the documentation for r.install_packages (which incidentally the test
>> > for it has no "s", but I don't know if that matters), I was trying to
>> > load one on the sagenb site.  Probably this is a gross violation of
>> > bandwidth or something,
>>
>> It will surely fail with a permission denied error at some point.  What
>> package would you like to install?
>>
>> > but anyway the surprise result under the R
>> > interface was
>> >
>> > install_packages(MASS)
>> > Error: could not find function "install_packages"
>>
>> Try typing
>>
>> r.install_packages("MASS")
>>
>> in a normal Sage input cell.  You probably forgot the quotes.
>>
>> Trying this on OS X it definitely fails for me.  There is this message:
>>
>> "sage: r.install_packages("MASS")
>> ** You are using OS X.  Unfortunately, the R optional package system
>> currently doesn't support OS X very well.  We are working on this. **"
>>
>> I wonder who the "We" refers to?  :-)
>>
>> I tried the above on sagenb.org (I'm the admin, so I have permissions).
>> It seems to fail as well:
>>
>> s...@sagenb:~$ sage
>> --
>> | Sage Version 3.2.2, Release Date: 2008-12-18   |
>> | Type notebook() for the GUI, and license() for information.|
>> --
>> sage: r.install_packages("MASS")
>> 0.00user 0.02system 0:00.03elapsed 82%CPU (0avgtext+0avgdata 0maxresident)k
>> 64inputs+0outputs (1major+209minor)pagefaults 0swaps
>>
>> R version 2.6.1 (2007-11-26)
>> Copyright (C) 2007 The R Foundation for Statistical Computing
>> ISBN 3-900051-07-0
>>
>> R is free software and comes with ABSOLUTELY NO WARRANTY.
>> You are welcome to redistribute it under certain conditions.
>> Type 'license()' or 'licence()' for distribution details.
>>
>>   Natural language support but running in an English locale
>>
>> R is a collaborative project with many contributors.
>> Type 'contributors()' for more information and
>> 'citation()' on how to cite R or R packages in publications.
>>
>> Type 'demo()' for some demos, 'help()' for on-line help, or
>> 'help.start()' for an HTML browser interface to help.
>> Type 'q()' to quit R.
>>
>> > options(repos="http://cran.r-project.org/";); install.packages("MASS")
>> trying URL 'http://cran.r-project.org/src/contrib/VR_7.2-45.tar.gz'
>> Content type 'application/x-gzip' length 465054 bytes (454 Kb)
>> opened URL
>> ==
>> downloaded 454 Kb
>>
>> WARNING: ignoring environment value of R_HOME
>> /home/sage/sage/local/lib/R/library
>> WARNING: ignoring environment value of R_HOME
>> * Installing *source* package 'MASS' ...
>> ** libs
>> gcc -std=gnu99 -I/home/sage/sage/local/lib/R/include
>> -I/home/sage/sage/local/lib/R/include  -I/home/sage/sage/local/inlcude
>> WARNING: ignoring environment value of R_HOME   -fpic
>> -I/home/sage/sage/local/include -L/home/sage/sage/local/lib/  -c lqs.c
>> -o lqs.o
>> gcc: WARNING:: No such file or directory
>> gcc: ignoring: No such file or directory
>> gcc: environment: No such file or directory
>> gcc: value: No such file or directory
>> gcc: of: No such file or directory
>> gcc: R_HOME: No such file or directory
>> make: *** [lqs.o] Error 1
>> ERROR: compilation failed for package 'MASS'
>> ** Removing '/home/sage/sage/local/lib/R/library/MASS'
>> ** Removing '/home/sage/sage/local/lib/R/library/class'
>> ** Removing '/home/sage/sage/local/lib/R/library/nnet'
>> ** Removing '/home/sage/sage/local/lib/R/library/spatial'
>>
>> The downloaded packages are in
>>   /tmp/RtmpoUnbs5/downloaded_packages
>> Updating HTML index of packages in '.Library'
>> Warning message:
>> In install.packages("MASS") :
>>   installation of package 'VR' had non-zero exit status
>> >
>>
>>
>>
>> >
>> > which was surprising since tab-completion was how I found this
>> > fu

[sage-support] Re: why doesn`t solve() give a proper answer

2009-01-09 Thread Robert Dodier

On Jan 9, 6:51 am, Slava  wrote:

> I`m trying to solve such simple system of equations: [sqrt(x) == 1, x
> == y],
> so I type:
>
> x,y = var('x,y');
> solve([sqrt(x) == 1, x == y], x, y);
>
> the answer is: []

If I understand correctly, Sage punts to Maxima to solve equations.
Maxima's built-in solver is not too strong. There is an add-on package
which can solve equations which contain radicals. Dunno how to call
it from Sage, but in Maxima itself it's like this:

load (topoly_solver);
to_poly_solve ([sqrt(x) = 1, x = y], [x, y]);
 => [[x = 1, y = 1]]

Maybe at some point in the not-too-distant future, the built-in
solver would call to_poly_solve automatically 

HTH

Robert Dodier

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



[sage-support] Re: why doesn`t solve() give a proper answer

2009-01-09 Thread William Stein

On Fri, Jan 9, 2009 at 9:01 AM, Robert Dodier  wrote:
>
> On Jan 9, 6:51 am, Slava  wrote:
>
>> I`m trying to solve such simple system of equations: [sqrt(x) == 1, x
>> == y],
>> so I type:
>>
>> x,y = var('x,y');
>> solve([sqrt(x) == 1, x == y], x, y);
>>
>> the answer is: []
>
> If I understand correctly, Sage punts to Maxima to solve equations.
> Maxima's built-in solver is not too strong. There is an add-on package
> which can solve equations which contain radicals. Dunno how to call
> it from Sage, but in Maxima itself it's like this:
>
> load (topoly_solver);
> to_poly_solve ([sqrt(x) = 1, x = y], [x, y]);
>  => [[x = 1, y = 1]]
>
> Maybe at some point in the not-too-distant future, the built-in
> solver would call to_poly_solve automatically 

That would be nice.  Here's doing the above in sage:

sage: x,y=var('x,y')
sage: v = [sqrt(x)==1, x==y]
sage: w = maxima(v)
sage: maxima.load('topoly_solver')
sage: w.to_poly_solve([x,y])
[[x=1,y=1]]

There's currently no simple code in sage to turn the output of
to_poly_solve into  native sage objects.

William

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



[sage-support] Re: why doesn`t solve() give a proper answer

2009-01-09 Thread William Stein

On Fri, Jan 9, 2009 at 9:05 AM, William Stein  wrote:
> On Fri, Jan 9, 2009 at 9:01 AM, Robert Dodier  wrote:
>>
>> On Jan 9, 6:51 am, Slava  wrote:
>>
>>> I`m trying to solve such simple system of equations: [sqrt(x) == 1, x
>>> == y],
>>> so I type:
>>>
>>> x,y = var('x,y');
>>> solve([sqrt(x) == 1, x == y], x, y);
>>>
>>> the answer is: []
>>
>> If I understand correctly, Sage punts to Maxima to solve equations.
>> Maxima's built-in solver is not too strong. There is an add-on package
>> which can solve equations which contain radicals. Dunno how to call
>> it from Sage, but in Maxima itself it's like this:
>>
>> load (topoly_solver);
>> to_poly_solve ([sqrt(x) = 1, x = y], [x, y]);
>>  => [[x = 1, y = 1]]
>>
>> Maybe at some point in the not-too-distant future, the built-in
>> solver would call to_poly_solve automatically 
>
> That would be nice.  Here's doing the above in sage:
>
> sage: x,y=var('x,y')
> sage: v = [sqrt(x)==1, x==y]
> sage: w = maxima(v)
> sage: maxima.load('topoly_solver')
> sage: w.to_poly_solve([x,y])
> [[x=1,y=1]]
>
> There's currently no simple code in sage to turn the output of
> to_poly_solve into  native sage objects.
>

I should correct myself and say it doesn't have any "trivial to use"
function to do that.  Of course we wrote code to do that when
implementing our solve command (which does work as you suggest above).

William

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



[sage-support] Problem Running with nohup on OSX.5

2009-01-09 Thread Tom


I'm having difficulty running Sage in the background on a Mac with OSX.
5 and getting the output saved in a file.  I tried a few permutations
with different results so I expect I'm making a silly error.   Here's
what I've seen.
Since the program runs fine in some of the scenarios, I don't think
the program (which I call "commands.sage") is the problem (I've made
it simpler and simpler without any change in the results).  Any help
would be appreciated.

Thanks,
Tom

0.  If I run Sage (from the command line) and type

load "commands.sage"

then the program runs fine.


1.  If I run

nohup ./sage < commands.sage > results.txt &

the file results.txt will just contain the initial startup messages
from Sage, but nothing more.


2.  If I run
./sage < commands.sage > results.txt

all the output is correctly written to results.txt.   The only problem
is that I can't close the terminal session and let Sage run in the
background.


3. If I run

./sage < commands.sage

I get the initial startup message, but nothing else written to screen
or any file.


4.  If I create a file "intro.sage" with the one line

load "commands.sage"

and then run

./sage < intro.sage

then the program runs and the output is sent to the screen.


5.  If I run

nohup ./sage < intro.sage > results.txt &

the file results.txt will just contain the initial startup messages
from Sage, but nothing more.


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



[sage-support] Re: Problem Running with nohup on OSX.5

2009-01-09 Thread Carl Witty

On Jan 9, 1:53 pm, Tom  wrote:
> I'm having difficulty running Sage in the background on a Mac with OSX.
> 5 and getting the output saved in a file.  I tried a few permutations
> with different results so I expect I'm making a silly error.   Here's
> what I've seen.
> Since the program runs fine in some of the scenarios, I don't think
> the program (which I call "commands.sage") is the problem (I've made
> it simpler and simpler without any change in the results).  Any help
> would be appreciated.
>
> Thanks,
> Tom
>
> 0.  If I run Sage (from the command line) and type
>
> load "commands.sage"
>
> then the program runs fine.
>
> 1.  If I run
>
> nohup ./sage < commands.sage > results.txt &
>
> the file results.txt will just contain the initial startup messages
> from Sage, but nothing more.
>
> 2.  If I run
> ./sage < commands.sage > results.txt
>
> all the output is correctly written to results.txt.   The only problem
> is that I can't close the terminal session and let Sage run in the
> background.
>
> 3. If I run
>
> ./sage < commands.sage
>
> I get the initial startup message, but nothing else written to screen
> or any file.
>
> 4.  If I create a file "intro.sage" with the one line
>
> load "commands.sage"
>
> and then run
>
> ./sage < intro.sage
>
> then the program runs and the output is sent to the screen.
>
> 5.  If I run
>
> nohup ./sage < intro.sage > results.txt &
>
> the file results.txt will just contain the initial startup messages
> from Sage, but nothing more.

It seems to be working for me with:

  nohup ./sage mytest.sage < /dev/null > results.txt &

So I gave the command file as a command-line argument, instead of on
standard input; and I made sure to redirect standard input from /dev/
null.  I also had to avoid the name commands.sage, because that
conflicts with a module Commands that's part of Sage (via IPython).

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



[sage-support] the set containing the empty set

2009-01-09 Thread John H Palmieri

Is this a bug?

sage: Set([])
{}
sage: Set(Set([]))
{}
sage: Set([]) == Set(Set([]))
True

In general, are Sage Sets supposed to behave like mathematical sets?

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



[sage-support] Re: the set containing the empty set

2009-01-09 Thread Mike Hansen

On Fri, Jan 9, 2009 at 3:36 PM, John H Palmieri  wrote:
>
> Is this a bug?
>
> sage: Set([])
> {}
> sage: Set(Set([]))
> {}
> sage: Set([]) == Set(Set([]))
> True

This is because Set takes a list (iterable) for all the of the
elements of the set.  So, if you want to construct the set containing
the empty set, you'd do the following:

sage: e = Set([])
sage: ee = Set([e])
sage: e
{}
sage: ee
{{}}
sage: e == ee
False

--Mike

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



[sage-support] Re: the set containing the empty set

2009-01-09 Thread William Stein

On Fri, Jan 9, 2009 at 3:38 PM, Mike Hansen  wrote:
>
> On Fri, Jan 9, 2009 at 3:36 PM, John H Palmieri  
> wrote:
>>
>> Is this a bug?
>>
>> sage: Set([])
>> {}
>> sage: Set(Set([]))
>> {}
>> sage: Set([]) == Set(Set([]))
>> True
>
> This is because Set takes a list (iterable) for all the of the
> elements of the set.  So, if you want to construct the set containing
> the empty set, you'd do the following:
>
> sage: e = Set([])
> sage: ee = Set([e])
> sage: e
> {}
> sage: ee
> {{}}
> sage: e == ee
> False

Yep.  Think "coercion" -- Set(foo) makes foo into a set.
It doesn't make the set containing foo.

William

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



[sage-support] Re: Problem Running with nohup on OSX.5

2009-01-09 Thread Tom


I think I may have found the source of the error, but not a
solution.   Does Sage (or Python or unix) only save the output to disk
in chunks of 32Kb?  By putting some simple print statements in my
program, I do see the output being recorded in the file.   I find that
the size of the results file gets incremented by approximately 32Kb
each time.   In the original program, there was not much output so one
would have to wait a long time before one would have 32Kb of output
(unless the program ends).

Carl, I also tried your solution  "nohup ./sage mytest.sage < /dev/
null > results.txt &"  and it appears to have the same property.  No
output for the original file, but output in 32Kb chunks with the new
print statements inserted.  Also, the use of the name "commands.sage"
was unfortunate.  I just chose that as it seemed like a generic name.
My original program has a different name that wouldn't be a Sage
command.

If my guess above is correct, is there anyway to force Sage to save
the output to the file more often (i.e. in smaller chunks)?

Thanks in advance,
Tom


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



[sage-support] Re: Problem Running with nohup on OSX.5

2009-01-09 Thread William Stein

On Fri, Jan 9, 2009 at 4:27 PM, Tom  wrote:
>
>
> I think I may have found the source of the error, but not a
> solution.   Does Sage (or Python or unix) only save the output to disk
> in chunks of 32Kb?  By putting some simple print statements in my
> program, I do see the output being recorded in the file.   I find that
> the size of the results file gets incremented by approximately 32Kb
> each time.   In the original program, there was not much output so one
> would have to wait a long time before one would have 32Kb of output
> (unless the program ends).
>
> Carl, I also tried your solution  "nohup ./sage mytest.sage < /dev/
> null > results.txt &"  and it appears to have the same property.  No
> output for the original file, but output in 32Kb chunks with the new
> print statements inserted.  Also, the use of the name "commands.sage"
> was unfortunate.  I just chose that as it seemed like a generic name.
> My original program has a different name that wouldn't be a Sage
> command.
>
> If my guess above is correct, is there anyway to force Sage to save
> the output to the file more often (i.e. in smaller chunks)?

Use sys.stdout.flush():

w...@bsd:~/papers/current/ggz$ sage
--
| Sage Version 3.2.1, Release Date: 2008-12-01   |
| Type notebook() for the GUI, and license() for information.|
--
sage: import sys
sage: sys.stdout.flush()

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



[sage-support] Re: Problem Running with nohup on OSX.5

2009-01-09 Thread Tom

import sys
sys.stdout.flush()

was the solution!

Thanks William!

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



[sage-support] Re: Problem Running with nohup on OSX.5

2009-01-09 Thread Justin C. Walker


On Jan 9, 2009, at 16:53 , Tom wrote:

>
> import sys
> sys.stdout.flush()
>
> was the solution!
>
> Thanks William!

If this solves the problem, it sounds like a bug to me.

Unless Sage is getting killed because of some error condition, the  
output should "drain" before the process terminates.  Adding the  
flush() might change the timing of writes to the file system, but  
shouldn't change the "correctness" of the operations.

Am I missing something about the way Python works?

Justin

--
Justin C. Walker, Curmudgeon at Large
Director
Institute for the Enhancement of the Director's Income
---
Nobody knows the trouble I've been
---




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



[sage-support] Re: the set containing the empty set

2009-01-09 Thread John H Palmieri



On Jan 9, 3:40 pm, "William Stein"  wrote:
> On Fri, Jan 9, 2009 at 3:38 PM, Mike Hansen  wrote:
>
> > On Fri, Jan 9, 2009 at 3:36 PM, John H Palmieri  
> > wrote:
>
> >> Is this a bug?
>
> >> sage: Set([])
> >> {}
> >> sage: Set(Set([]))
> >> {}
> >> sage: Set([]) == Set(Set([]))
> >> True
>
> > This is because Set takes a list (iterable) for all the of the
> > elements of the set.  So, if you want to construct the set containing
> > the empty set, you'd do the following:
>
> > sage: e = Set([])
> > sage: ee = Set([e])
> > sage: e
> > {}
> > sage: ee
> > {{}}
> > sage: e == ee
> > False
>
> Yep.  Think "coercion" -- Set(foo) makes foo into a set.
> It doesn't make the set containing foo.

Oh, I should have figured that out.

Here's another question: what is the most efficient way of testing
whether one Set is a subset of another?  I can do

S in list(T.subsets())

-- and it's a bit frustrating that I can't do S in T.subsets() -- and
I can also manipulate intersections, unions, differences, etc. I can
also convert to python sets and use <=.  Is there a preferred way?

  John


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



[sage-support] Re: the set containing the empty set

2009-01-09 Thread William Stein

On Fri, Jan 9, 2009 at 6:42 PM, John H Palmieri  wrote:
>
>
>
> On Jan 9, 3:40 pm, "William Stein"  wrote:
>> On Fri, Jan 9, 2009 at 3:38 PM, Mike Hansen  wrote:
>>
>> > On Fri, Jan 9, 2009 at 3:36 PM, John H Palmieri  
>> > wrote:
>>
>> >> Is this a bug?
>>
>> >> sage: Set([])
>> >> {}
>> >> sage: Set(Set([]))
>> >> {}
>> >> sage: Set([]) == Set(Set([]))
>> >> True
>>
>> > This is because Set takes a list (iterable) for all the of the
>> > elements of the set.  So, if you want to construct the set containing
>> > the empty set, you'd do the following:
>>
>> > sage: e = Set([])
>> > sage: ee = Set([e])
>> > sage: e
>> > {}
>> > sage: ee
>> > {{}}
>> > sage: e == ee
>> > False
>>
>> Yep.  Think "coercion" -- Set(foo) makes foo into a set.
>> It doesn't make the set containing foo.
>
> Oh, I should have figured that out.
>
> Here's another question: what is the most efficient way of testing
> whether one Set is a subset of another?  I can do
>
>S in list(T.subsets())
>
> -- and it's a bit frustrating that I can't do S in T.subsets() -- and
> I can also manipulate intersections, unions, differences, etc. I can
> also convert to python sets and use <=.  Is there a preferred way?
>

There should be an is_subset method, but mysteriously there isn't.   Implement
it and send a patch.

William

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



[sage-support] Re: the set containing the empty set

2009-01-09 Thread John H Palmieri

On Jan 9, 7:03 pm, "William Stein"  wrote:
> On Fri, Jan 9, 2009 at 6:42 PM, John H Palmieri  
> wrote:
>
> > Here's another question: what is the most efficient way of testing
> > whether one Set is a subset of another?  I can do
>
> >    S in list(T.subsets())
>
> > -- and it's a bit frustrating that I can't do S in T.subsets() -- and
> > I can also manipulate intersections, unions, differences, etc. I can
> > also convert to python sets and use <=.  Is there a preferred way?
>
> There should be an is_subset method, but mysteriously there isn't.   Implement
> it and send a patch.

Okay, then back to my question: what's the most efficient way of
implement it?

  John

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