[sage-support] Re: assume(...) is very slow

2008-11-20 Thread Stan Schymanski

I'm probably not the right one to respond to this one, but please, do!
I get reminded of this every time I run through any of my worksheets,
but then I usually get distracted by the results before I get to send
out an email about it. Thanks for picking it up again!

Stan

On Nov 20, 6:46 am, mabshoff [EMAIL PROTECTED]
dortmund.de wrote:
 On Oct 14, 6:47 am, William Stein [EMAIL PROTECTED] wrote:

  This could be greatly sped up by changing
     maxima.assume('...')
  to
    maxima.eval(assume(..))
  in the calculus code...

  sage: timeit(maxima.eval('assume(x0)'))
  5 loops, best of 3: 53.2 ms per loop
  sage: timeit(maxima.assume(x0))
  5 loops, best of 3: 122 ms per loop

  I don't have time to do this...

 This was never made into a ticket. Should it?

 Cheers,

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



[sage-support] Re: latex output for real numbers without zeros at the end

2008-11-20 Thread Stan Schymanski

Thanks a lot for that, Robert! Is the ultimate fix the one that will
use pynac instead of maxima? I can't wait for this one.

All the best,
Stan

On Nov 19, 6:46 pm, Robert Bradshaw [EMAIL PROTECTED]
wrote:
 On Nov 18, 2008, at 11:18 PM, Stan Schymanski wrote:

  Hi Robert,

  Will the fix of the interaction with Maxima allow conservation of
  precision of arguments passed through Maxima? This would satisfy my
  needs.

 Actually, the fix is avoiding Maxima for everything symbolic.

  Depending on how long this is going to take, I would like Mike's
  interim fix to be implemented. It doesn't make anything worse compared
  with the current state, as currently latexification gives a false  
  sense
  of precision, anyway. This does certainly not fit my definition of
  usefulness. We would just have to make sure that the interim fix is
  removed again when the maxima interaction is fixed.

 The problem with Mike's fix is that it affects *all* real numbers,  
 not just ones in Maxima expressions. I would be OK with a fix that  
 just impacts symbolic object's latex (and even string)  
 representation. I'll implement this and see if it gets a positive  
 review.

 - Robert



  Robert Bradshaw wrote:
  On Nov 18, 2008, at 5:57 AM, Stan Schymanski wrote:

  Ah, I see:

  dummy1 = RealField(8)(0.1);dummy1
  0.10

  dummy2 = RealField(16)(0.1);dummy2
  0.1000

  latex(x*dummy1)
  {0.1001 x}

  latex(x*dummy2)
  {0.1 x}

  This is not quite what one would expect. However, the behaviour  
  before
  the fix was not much better in my opinion, as the precision was not
  obvious from the latex output, either:

  sage: dummy1 = RealField(8)(0.1);dummy1
  0.10
  sage: dummy2 = RealField(16)(0.1);dummy2
  0.1000
  sage: latex(x*dummy1)
  {0.1001000 x}
  sage: latex(x*dummy2)
  {0.100 x}

  Obviously, the fix does not fix all the problems, but it does make
  latex output much more useful. Would you agree?

  That depends on your definition of useful. Personally, I think it's
  useful to see how many digits of precision a given number has, and
  for most things it works fine.

  The issue here is the interaction with Maxima, which is being fixed.
  Making it so any latexification of all real numbers is truncated is
  (IMHO) not the right fix because one component abuses precisions.

  - Robert


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



[sage-support] Re: How to use tar from Sage?

2008-11-20 Thread Simon King

Dear Michael,

On Nov 19, 9:34 pm, mabshoff [EMAIL PROTECTED]
dortmund.de wrote:
 I think it is much more important to understand what the intended use
 here is instead of arguing about the finer details of compression.

Good point, although I think that the speed/memory issues pointed out
by David are helpful to make a decision.

The intended use is:
- I am computing cohomology rings, and during the computation some
executables are called that produce a lot(!) of data, stored in files
F1,F2,
- When I implemented pickling/unpickling, I first tried to save the
cohomology ring (including data that are in F1,F2,...) into a single
file. However, it turned out to be too slow and to consume too much
memory, such that it became unfeasible in some examples.
- Hence, when I save a cohomology ring now, I just provide information
on how to reconstruct the ring from F1,F2,..., in particular it tells
the location of F1,F2,...
- Advantage: It is fast and works well, as long as you stay on a
single machine.
- Disadvantage: Clearly it isn't portable. Even if you move the pickle
plus all F1,F2,... manually on a different machine, you couldn't
reconstruct the ring, because the location of the F1,F2,... changed (-
 broken paths).

Hence, I made an export and an import method:
- export puts all data needed to reconstruct the ring into an archive
file.
- One may transfer the archive file to a different location. The
import method unpacks it and takes care that the unpacked F1,F2,...
are put correctly relative to the new location.

So far, I could live without import/export. But my project eventually
aims at publishing the computational results in a data base.

Memory is an issue. The data base will comprise more than 2400
cohomology rings, and a GNU zipped tar file for one of the biggest
examples is 65 MB.

And currently I am trying to compute a ring that occupies a total of
74 GB (uncompressed) on the disk - it isn't finished yet...

 I would always suggest tar.gz since bz2 support for example is not build
 in for non-GNU tar.

Does the system-tar really play a role if one can use the Python
libraries for data compression? I understood that the bz2 package
would do the work, even if there is no GNU tar on the system.

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



[sage-support] Re: lists, vectors, arrays in equations?

2008-11-20 Thread Jason Grout

Stan Schymanski wrote:
 Thanks a lot for all your help! The [f(a=i,x=j,b=k) for i,j,k in zip
 (v,w,z)] way looks useful, as I can easily see what is inserted for
 what. Looking at the other examples, I realised that most of my time
 series are likely to be imported as numpy arrays, so I will have to
 look in more detail at the numpy way. Is there an easy way of
 converting a function f into a numpy function?
 
 Here is what I tried:
 
 sage: import numpy
 sage: var('a b')
 sage: f = a*x^2 + b
 sage: v = numpy.array([1,2,3])
 sage: w = numpy.array([4,5,6])
 sage: z = numpy.array([7,8,9])
 sage: f(a=v,x=w,b=z)
 Traceback (click to the left for traceback)
 ...
 TypeError: 'numpy.ndarray' object is not callable
 sage: a = v
 sage: b = w
 sage: x = z
 sage: f
 array([
b + 49 a,
 
b + 64 a,
 
b + 81 a], dtype=object)
 sage: a*x^2 + b
 array([53, 133, 249], dtype=object)
 
 The last output is what I want, but I don't want to type the whole
 equation in again. I am collecting all the methods and ideas that help
 me and I hope that I will be able to put it all into a tutorial one
 day.
 


You could use a pure python function, then.  The code below does nothing 
with Sage; it would run with just python (and numpy).


sage: import numpy
sage: v = numpy.array([1,2,3])
sage: w = numpy.array([4,5,6])
sage: z = numpy.array([7,8,9])
sage: def f(a,x,b):
: return a*x**2+b
:
sage: f(a=v,x=w,b=z)
array([23, 58, 117], dtype=object)


Jason


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



[sage-support] Re: Problem with optional trac package (sage version 3.1.4)

2008-11-20 Thread gerhard

 What operating system *exactly*?  What version of Sage? How
 did you install trac into Sage?  And anything else useful about your
 setup that you can think of...


Redhat Fedora 8 with all current patches applied.
Linux localhost.localdomain 2.6.26.6-49.fc8
SAGE Version 3.1.4, Release Date: 2008-10-20
sage -i trac-20071204

I got around the problem by simply installing
a separate version of trac and running it independently of sage.

From what I gather using Google, the problem has to do with python.

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



[sage-support] Re: bug in integral?

2008-11-20 Thread pong

Yes, integral does not handle abs correctly.

sage: integral(abs(x),x)
integrate(abs(x), x)

sage: integral(max(x,-x),x)
x^2/2

If that's for sure a bug coming from maxima, I hope someone it can be
reported to their bug list.
I can see that it has been reported by David to the maxima-user list,
but somehow it does not show up in either the user or the bug list of
maxima. Isn't that strange?


On Nov 19, 9:33 am, David Joyner [EMAIL PROTECTED] wrote:
 Thanks for reporting this. I emailed the maxima users list.

 On Wed, Nov 19, 2008 at 11:50 AM, pong [EMAIL PROTECTED] wrote:

  Maybe someone has reported this already... but looks like there is a
  bug in integral

  sage: integral(x*abs(9-x^2), x, -6, 0)
  162

  The integrand is negative on (-6,0)
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: bug in integral?

2008-11-20 Thread David Joyner

I know Stavros M saw it and Mike cc'd Robert D, so two of the
main maxima developers definitely know about it now.

Thanks again.


On Thu, Nov 20, 2008 at 11:00 AM, pong [EMAIL PROTECTED] wrote:

 Yes, integral does not handle abs correctly.

 sage: integral(abs(x),x)
 integrate(abs(x), x)

 sage: integral(max(x,-x),x)
 x^2/2

 If that's for sure a bug coming from maxima, I hope someone it can be
 reported to their bug list.
 I can see that it has been reported by David to the maxima-user list,
 but somehow it does not show up in either the user or the bug list of
 maxima. Isn't that strange?


 On Nov 19, 9:33 am, David Joyner [EMAIL PROTECTED] wrote:
 Thanks for reporting this. I emailed the maxima users list.

 On Wed, Nov 19, 2008 at 11:50 AM, pong [EMAIL PROTECTED] wrote:

  Maybe someone has reported this already... but looks like there is a
  bug in integral

  sage: integral(x*abs(9-x^2), x, -6, 0)
  162

  The integrand is negative on (-6,0)
 


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



[sage-support] Re: calculating and plotting polynomials with 3 variables

2008-11-20 Thread William Stein

On Thu, Nov 20, 2008 at 7:21 AM, kcrisman [EMAIL PROTECTED] wrote:




  I am really newbie to Sage, but I need to both plot and declare
  functions like:
  f(x,y,z) = x*y*z
  and other poly's containing 3 variables.
  How do I do that?


 It sounds like you are looking for a 3-D implicit plot.  Is that
 correct?  Or perhaps a contour plot in 3-D.  Unfortunately, although
 there are reasonable (though not perfect) 2-D versions of that in
 Sage, I do not believe that we have native implicit plotting or
 contour plotting available in Sage in 3-D.  That would be really nice,
 but I don't even pretend to understand how the code might be improved
 to implement that.

 However, there is the optional experimental package for Surf, which I
 believe does plot surfaces (in an algebraic geometry context - their
 home page has a nice shot of the 27 lines on a cubic) and can be used
 with Sage.  The documentation about that on the Sage site does not
 inspire confidence that this can effortlessly installed,
 unfortunately.

 Best,
 - kcrisman

This is just to confirm that indeed Sage doesn't have an implementation
of implicit 3d plots yet.

There is a very powerful/flexible list_plot3d command -- you can pass it
an arbitrary collection of points in 3d and it puts a surface through them
using various interpolation options.  Thus you could get some approximation
to an implicit plot, by finding lots of points (x,y,z) in a 3d grid
(use fast_float
to make this fast) such that f(x,y,z) is tiny.  That would be just a few lines
of code to implement, and might be a reasonable approximation to 3d
implicit plots, for some applications (??).

William

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



[sage-support] Re: calculating and plotting polynomials with 3 variables

2008-11-20 Thread Joshua Kantor

In case anyone is interested there is a relatively standard algorithm
for constructing  mesh for an isosurfaces called marching cubes. For
a while that was patented so there is a marching tetrahedrons analog
but I think the patent issue is expired. Its complicated in that there
are lots of things to keep track up but not  mathematically
sophisticated. Obviously that doesn't help immediately but it would be
good project at some point if someone wanted to add 3d implicit
plotting.
 
Josh


On Nov 20, 9:32 am, William Stein [EMAIL PROTECTED] wrote:
 On Thu, Nov 20, 2008 at 7:21 AM, kcrisman [EMAIL PROTECTED] wrote:

   I am really newbie to Sage, but I need to both plot and declare
   functions like:
   f(x,y,z) = x*y*z
   and other poly's containing 3 variables.
   How do I do that?

  It sounds like you are looking for a 3-D implicit plot.  Is that
  correct?  Or perhaps a contour plot in 3-D.  Unfortunately, although
  there are reasonable (though not perfect) 2-D versions of that in
  Sage, I do not believe that we have native implicit plotting or
  contour plotting available in Sage in 3-D.  That would be really nice,
  but I don't even pretend to understand how the code might be improved
  to implement that.

  However, there is the optional experimental package for Surf, which I
  believe does plot surfaces (in an algebraic geometry context - their
  home page has a nice shot of the 27 lines on a cubic) and can be used
  with Sage.  The documentation about that on the Sage site does not
  inspire confidence that this can effortlessly installed,
  unfortunately.

  Best,
  - kcrisman

 This is just to confirm that indeed Sage doesn't have an implementation
 of implicit 3d plots yet.

 There is a very powerful/flexible list_plot3d command -- you can pass it
 an arbitrary collection of points in 3d and it puts a surface through them
 using various interpolation options.  Thus you could get some approximation
 to an implicit plot, by finding lots of points (x,y,z) in a 3d grid
 (use fast_float
 to make this fast) such that f(x,y,z) is tiny.  That would be just a few lines
 of code to implement, and might be a reasonable approximation to 3d
 implicit plots, for some applications (??).

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



[sage-support] Re: assume(...) is very slow

2008-11-20 Thread William Stein

On Thu, Nov 20, 2008 at 1:51 AM, Stan Schymanski [EMAIL PROTECTED] wrote:

 I'm probably not the right one to respond to this one, but please, do!
 I get reminded of this every time I run through any of my worksheets,
 but then I usually get distracted by the results before I get to send
 out an email about it. Thanks for picking it up again!

I've made this trac #4566:

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


 Stan

 On Nov 20, 6:46 am, mabshoff [EMAIL PROTECTED]
 dortmund.de wrote:
 On Oct 14, 6:47 am, William Stein [EMAIL PROTECTED] wrote:

  This could be greatly sped up by changing
 maxima.assume('...')
  to
maxima.eval(assume(..))
  in the calculus code...

  sage: timeit(maxima.eval('assume(x0)'))
  5 loops, best of 3: 53.2 ms per loop
  sage: timeit(maxima.assume(x0))
  5 loops, best of 3: 122 ms per loop

  I don't have time to do this...

 This was never made into a ticket. Should it?

 Cheers,

 Michael
 




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

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



[sage-support] Doc tests for file-producing methods

2008-11-20 Thread Simon King

Hi folks,

assume that some function/method produces files on the disk. What
should a doc test look like for such functions/methods? Is there a
standard? My fear is to have doc tests that destroy user data. I'd
like to know your opinion on my concerns.

1. The doc test would produce a file, even though the user didn't ask
for having nonsense data written onto his/her disk.
  a) In what directory should the files be created? [Subdirectories
of] SAGE_TMP perhaps?
  b) How can one avoid name conflicts with user data? E.g., in the doc
test for save_session, this point is not taken care of.
  c) Should the doc test always end with removing the files (see doc
test for save_session)? Even if the test data are written into a
default location and are not nonsense but actually meaningful and
reasonable to keep?
  d) Would an explicit removal of the files also be needed in
SAGE_TMP?


2. In view of 1.: Should such functions/methods have no doc test,
making an exception to the 100% doc test coverage policy?
  a) There is some evidence that the answer should be yes. For
example, there is no doc-test for 'file' or for 'os.mkdir'. However
these are not Sage but Python, and 'save_session' is a counter-
example.
  b) In my case, 2.a) would mean to have *no* doc test *at all* in the
whole package. Not good.

Yours,
  Simon

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



[sage-support] Re: Doc tests for file-producing methods

2008-11-20 Thread Robert Bradshaw

On Nov 20, 2008, at 11:00 AM, Simon King wrote:


 Hi folks,

 assume that some function/method produces files on the disk. What
 should a doc test look like for such functions/methods? Is there a
 standard? My fear is to have doc tests that destroy user data. I'd
 like to know your opinion on my concerns.

 1. The doc test would produce a file, even though the user didn't ask
 for having nonsense data written onto his/her disk.
   a) In what directory should the files be created? [Subdirectories
 of] SAGE_TMP perhaps?

Yes.

   b) How can one avoid name conflicts with user data? E.g., in the doc
 test for save_session, this point is not taken care of.

See http://www.python.org/doc/2.5.2/lib/module-tempfile.html

   c) Should the doc test always end with removing the files (see doc
 test for save_session)? Even if the test data are written into a
 default location and are not nonsense but actually meaningful and
 reasonable to keep?

That depends on what exactly they are, but usually they should.

   d) Would an explicit removal of the files also be needed in
 SAGE_TMP?

I'm not sure exactly how SAGE_TMP is cleaned up (except not as well  
as I would like).

 2. In view of 1.: Should such functions/methods have no doc test,
 making an exception to the 100% doc test coverage policy?
   a) There is some evidence that the answer should be yes. For
 example, there is no doc-test for 'file' or for 'os.mkdir'. However
 these are not Sage but Python, and 'save_session' is a counter-
 example.
   b) In my case, 2.a) would mean to have *no* doc test *at all* in the
 whole package. Not good.

There should absolutely be doctests.

- Robert



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



[sage-support] Re: Doc tests for file-producing methods

2008-11-20 Thread Simon King

Dear Robert,

On Nov 20, 8:45 pm, Robert Bradshaw [EMAIL PROTECTED]
wrote:
a) In what directory should the files be created? [Subdirectories
  of] SAGE_TMP perhaps?

 Yes.

b) How can one avoid name conflicts with user data? E.g., in the doc
  test for save_session, this point is not taken care of.

 Seehttp://www.python.org/doc/2.5.2/lib/module-tempfile.html

Cool, I think I will use it!

But shouldn't the doc test of save_session be changed, using tempfile?
After all, if the user has a file 'session.sobj' in the current
directory, the doc test would destroy it.

As much as I see, SAGE_TMP is removed as soon as you quit Sage.
However, if explicit deletion were necessary: How can one delete a non-
empty directory? os.rmdir(...) would complain.

Thank you!
Simon
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Doc tests for file-producing methods

2008-11-20 Thread Robert Bradshaw

On Nov 20, 2008, at 12:04 PM, Simon King wrote:


 Dear Robert,

 On Nov 20, 8:45 pm, Robert Bradshaw [EMAIL PROTECTED]
 wrote:
   a) In what directory should the files be created? [Subdirectories
 of] SAGE_TMP perhaps?

 Yes.

   b) How can one avoid name conflicts with user data? E.g., in  
 the doc
 test for save_session, this point is not taken care of.

 Seehttp://www.python.org/doc/2.5.2/lib/module-tempfile.html

 Cool, I think I will use it!

 But shouldn't the doc test of save_session be changed, using tempfile?
 After all, if the user has a file 'session.sobj' in the current
 directory, the doc test would destroy it.

Yes, this should be changed.

 As much as I see, SAGE_TMP is removed as soon as you quit Sage.
 However, if explicit deletion were necessary: How can one delete a  
 non-
 empty directory? os.rmdir(...) would complain.

See http://www.python.org/doc/2.5.2/lib/module-shutil.html

- Robert

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



[sage-support] Re: Doc tests for file-producing methods

2008-11-20 Thread Mike Hansen

Hello,

On Thu, Nov 20, 2008 at 12:10 PM, Robert Bradshaw
[EMAIL PROTECTED] wrote:

 On Nov 20, 2008, at 12:04 PM, Simon King wrote:


 Dear Robert,

 On Nov 20, 8:45 pm, Robert Bradshaw [EMAIL PROTECTED]
 wrote:
   a) In what directory should the files be created? [Subdirectories
 of] SAGE_TMP perhaps?

 Yes.

   b) How can one avoid name conflicts with user data? E.g., in
 the doc
 test for save_session, this point is not taken care of.

 Seehttp://www.python.org/doc/2.5.2/lib/module-tempfile.html

 Cool, I think I will use it!

There is also tmp_filename and tmp_dir in sage.misc.misc.

--Mike

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



[sage-support] Re: Doc tests for file-producing methods

2008-11-20 Thread Simon King

Dear Robert,

On Nov 20, 9:10 pm, Robert Bradshaw [EMAIL PROTECTED]
wrote:
 On Nov 20, 2008, at 12:04 PM, Simon King wrote:
  But shouldn't the doc test of save_session be changed, using tempfile?
  After all, if the user has a file 'session.sobj' in the current
  directory, the doc test would destroy it.

 Yes, this should be changed.

Ok, I made a ticket #4568 (almost an arithmetic progression :)

Where is save_session defined?

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



[sage-support] How add new Sage notebook accounts? AND How kill notebook background process?

2008-11-20 Thread [EMAIL PROTECTED]

How add new Sage notebook accounts so everyone doesn't have to log in
as admin?

And, how kill Sage notebook?  I run it as a background process and it
seems to start a ton of processes.  Perhaps there is a parent process
I can kill that will automatically cause rest to die?

Thanks,

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



[sage-support] Re: Doc tests for file-producing methods

2008-11-20 Thread William Stein

On Thu, Nov 20, 2008 at 11:45 AM, Robert Bradshaw
[EMAIL PROTECTED] wrote:

 On Nov 20, 2008, at 11:00 AM, Simon King wrote:


 Hi folks,

 assume that some function/method produces files on the disk. What
 should a doc test look like for such functions/methods? Is there a
 standard? My fear is to have doc tests that destroy user data. I'd
 like to know your opinion on my concerns.

 1. The doc test would produce a file, even though the user didn't ask
 for having nonsense data written onto his/her disk.
   a) In what directory should the files be created? [Subdirectories
 of] SAGE_TMP perhaps?

 Yes.

   b) How can one avoid name conflicts with user data? E.g., in the doc
 test for save_session, this point is not taken care of.

 See http://www.python.org/doc/2.5.2/lib/module-tempfile.html

It might be better I think to use the Sage-provided functions tmp_filename()
and tmp_dir():

sage: tmp_filename()
'/Users/was/.sage//temp/bsd.local/88943//tmp_0'
sage: tmp_dir()
'/Users/was/.sage/temp/bsd.local/88943/dir_0'

These create either a valid tempory filename or temporary directory in
the appropriate subdirectory of DOT_SAGE.  This will definitely eventually
be cleaned up by the sage-cleaner script, even if you kill -9 the sage
process.


   c) Should the doc test always end with removing the files (see doc
 test for save_session)? Even if the test data are written into a
 default location and are not nonsense but actually meaningful and
 reasonable to keep?

 That depends on what exactly they are, but usually they should.

   d) Would an explicit removal of the files also be needed in
 SAGE_TMP?

 I'm not sure exactly how SAGE_TMP is cleaned up (except not as well
 as I would like).

 2. In view of 1.: Should such functions/methods have no doc test,
 making an exception to the 100% doc test coverage policy?
   a) There is some evidence that the answer should be yes. For
 example, there is no doc-test for 'file' or for 'os.mkdir'. However
 these are not Sage but Python, and 'save_session' is a counter-
 example.
   b) In my case, 2.a) would mean to have *no* doc test *at all* in the
 whole package. Not good.

 There should absolutely be doctests.

 - Robert



 




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

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



[sage-support] Re: How add new Sage notebook accounts? AND How kill notebook background process?

2008-11-20 Thread William Stein

On Thu, Nov 20, 2008 at 12:27 PM, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:

 How add new Sage notebook accounts so everyone doesn't have to log in
 as admin?

Type notebook? and read the docs.  If that isn't enough please please
do ask here again.


 And, how kill Sage notebook?  I run it as a background process and it
 seems to start a ton of processes.  Perhaps there is a parent process
 I can kill that will automatically cause rest to die?

Do you know about the screen program?  Try typing man screen to
see if you have it.  It is an *awesome* way to run programs like the notebook,
detach  them, come back to them later ,etc., and be able to control-c
to quit them properly.  If it isn't installed on your server, let me know and
I'll point you to a page where you can download and install it.

William

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



[sage-support] Re: latex output for real numbers without zeros at the end

2008-11-20 Thread Robert Bradshaw

On Nov 20, 2008, at 1:54 AM, Stan Schymanski wrote:

 Thanks a lot for that, Robert!

See http://trac.sagemath.org/sage_trac/ticket/4572 Do you want to  
review it?

 Is the ultimate fix the one that will
 use pynac instead of maxima? I can't wait for this one.

Yep, though we won't be replacing all of maxima's functionality any  
time soon.


 All the best,
 Stan

 On Nov 19, 6:46 pm, Robert Bradshaw [EMAIL PROTECTED]
 wrote:
 On Nov 18, 2008, at 11:18 PM, Stan Schymanski wrote:

 Hi Robert,

 Will the fix of the interaction with Maxima allow conservation of
 precision of arguments passed through Maxima? This would satisfy my
 needs.

 Actually, the fix is avoiding Maxima for everything symbolic.

 Depending on how long this is going to take, I would like Mike's
 interim fix to be implemented. It doesn't make anything worse  
 compared
 with the current state, as currently latexification gives a false
 sense
 of precision, anyway. This does certainly not fit my definition of
 usefulness. We would just have to make sure that the interim fix is
 removed again when the maxima interaction is fixed.

 The problem with Mike's fix is that it affects *all* real numbers,
 not just ones in Maxima expressions. I would be OK with a fix that
 just impacts symbolic object's latex (and even string)
 representation. I'll implement this and see if it gets a positive
 review.

 - Robert



 Robert Bradshaw wrote:
 On Nov 18, 2008, at 5:57 AM, Stan Schymanski wrote:

 Ah, I see:

 dummy1 = RealField(8)(0.1);dummy1
 0.10

 dummy2 = RealField(16)(0.1);dummy2
 0.1000

 latex(x*dummy1)
 {0.1001 x}

 latex(x*dummy2)
 {0.1 x}

 This is not quite what one would expect. However, the behaviour
 before
 the fix was not much better in my opinion, as the precision was  
 not
 obvious from the latex output, either:

 sage: dummy1 = RealField(8)(0.1);dummy1
 0.10
 sage: dummy2 = RealField(16)(0.1);dummy2
 0.1000
 sage: latex(x*dummy1)
 {0.1001000 x}
 sage: latex(x*dummy2)
 {0.100 x}

 Obviously, the fix does not fix all the problems, but it does make
 latex output much more useful. Would you agree?

 That depends on your definition of useful. Personally, I think it's
 useful to see how many digits of precision a given number has, and
 for most things it works fine.

 The issue here is the interaction with Maxima, which is being  
 fixed.
 Making it so any latexification of all real numbers is truncated is
 (IMHO) not the right fix because one component abuses precisions.

 - Robert


 


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



[sage-support] How to exponentiate a matrix with mixed entries?

2008-11-20 Thread Paul Leopardi

Hi all,
I'm trying to exponentiate a matrix with a complex entry. The input
and output is below. Why does Sage give me 103993*I/33102 in the upper
right hand corner, and how can I get it to give me the right answer?
Also, how do I get it to use (eg.) RealField(100)?
Best, Paul

[EMAIL PROTECTED]:~ sage
--
| SAGE Version 3.1.2, Release Date: 2008-09-19   |
| Type notebook() for the GUI, and license() for information.|
--

sage: A=Matrix([[1,0,i*float(pi)],[0,1,0],[0,0,1]])
sage: exp(A)/exp(1)

[ 1  0 103993*I/33102]
[ 0  1  0]
[ 0  0  1]
sage: B=Matrix([[1,0,i*pi],[0,1,0],[0,0,1]])
sage: exp(B)/exp(1)

[   10 I*pi]
[   010]
[   001]

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



[sage-support] Mathematica (under wine) sage interface

2008-11-20 Thread Quicksilver_Johny

I am currently running Mathematica through wine on Ubuntu.
From the command line:
[EMAIL PROTECTED]:~$ wine C:\Program Files\Wolfram Research\Mathematica
\6.0\math.exe
Mathematica 6.0 for Microsoft Windows (32-bit)
Copyright 1988-2008 Wolfram Research, Inc.

In[1]:=

And in /usr/bin/math
[EMAIL PROTECTED]:~$ cat /usr/bin/math
#/bin/bash
wine C:\Program Files\Wolfram Research\Mathematica\6.0\math.exe


However, I get this in sage:
sage: mathematica('1+1')
Timeout exceeded in read_nonblocking().
pexpect.spawn instance at 0xae5988c
version: 2.0 ($Revision: 1.151 $)
command: /usr/bin/math
args: ['/usr/bin/math']
patterns:
In[[0-9]+]:=
buffer (last 100 chars):
before (last 100 chars): mand, self.args)
425
426 # Parent

OSError: [Errno 8] Exec format error
sage:
after: class 'pexpect.TIMEOUT'
match: None
match_index: None
exitstatus: None
flag_eof: 0
pid: 3157
child_fd: 3
timeout: 30
delimiter: class 'pexpect.EOF'
logfile: None
maxread: 100
searchwindowsize: None
delaybeforesend: 0
---
TypeError Traceback (most recent call
last)

/home/qj/ipython console in module()

/home/qj/sage/local/lib/python2.5/site-packages/sage/interfaces/
expect.pyc in __call__(self, x, name)
963 return x
964 if isinstance(x, basestring):
-- 965 return cls(self, x, name=name)
966 try:
967 return self._coerce_from_special_method(x)

/home/qj/sage/local/lib/python2.5/site-packages/sage/interfaces/
expect.pyc in __init__(self, parent, value, is_name, name)
   1281 except (TypeError, KeyboardInterrupt,
RuntimeError, ValueError), x:
   1282 self._session_number = -1
- 1283 raise TypeError, x
   1284 self._session_number = parent._session_number
   1285

TypeError: Unable to start mathematica


What should I do to get the Mathematica interface to work?
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: How add new Sage notebook accounts? AND How kill notebook background process?

2008-11-20 Thread [EMAIL PROTECTED]

On Nov 20, 1:05 pm, William Stein [EMAIL PROTECTED] wrote:
 Type notebook? and read the docs.  If that isn't enough please please
 do ask here again.

The Help link inside the notebook gives a ton of great docs on how
to do great things with notebook.  I couldn't find the section on how
to add new notebook accounts in those docs.
Should I be looking somewhere else?

  And, how kill Sage notebook?  I run it as a background process and it
  seems to start a ton of processes.  Perhaps there is a parent process
  I can kill that will automatically cause rest to die?

 Do you know about the screen program?  Try typing man screen to
 see if you have it.  It is an *awesome* way to run programs like the notebook,
 detach  them, come back to them later ,etc., and be able to control-c
 to quit them properly.  If it isn't installed on your server, let me know and
 I'll point you to a page where you can download and install it.

I've used screen to run programs.  I never thought to use it to exit
programs cleanly.
I was trying to make a /etc/init.d/sage script to start and stop
Sage.  I guess my /etc/init.d/sage could start screen.  I hadn't
thought of that.  I'll look into it.

Thanks!

Chris

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



[sage-support] Possible to change base notebook URL? e.g. localhost:8000/foo/bar ?

2008-11-20 Thread [EMAIL PROTECTED]

Possible to change base notebook URL? e.g. localhost:8000/foo/bar ?

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



[sage-support] Re: Possible to change base notebook URL? e.g. localhost:8000/foo/bar ?

2008-11-20 Thread William Stein

On Thu, Nov 20, 2008 at 7:31 PM, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:

 Possible to change base notebook URL? e.g. localhost:8000/foo/bar ?


Unfortunately, this isn't supported yet, though it's certainly been requested
before.

William

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



[sage-support] Re: How add new Sage notebook accounts? AND How kill notebook background process?

2008-11-20 Thread William Stein

On Thu, Nov 20, 2008 at 6:30 PM, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:

 On Nov 20, 1:05 pm, William Stein [EMAIL PROTECTED] wrote:
 Type notebook? and read the docs.  If that isn't enough please please
 do ask here again.

 The Help link inside the notebook gives a ton of great docs on how
 to do great things with notebook.  I couldn't find the section on how
 to add new notebook accounts in those docs.
 Should I be looking somewhere else?

It should be in chapter 3 on the notebook.  Unfortunately, I just
looked and it isn't.The problem is that the file notebook_object.py
isn't included in the reference manual.

Maybe Mike Hansen can fix this when he Sphinxifies the documentation
for Sage, which he'll do very soon.

I've created trac ticket #4574 about this:

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



  And, how kill Sage notebook?  I run it as a background process and it
  seems to start a ton of processes.  Perhaps there is a parent process
  I can kill that will automatically cause rest to die?

 Do you know about the screen program?  Try typing man screen to
 see if you have it.  It is an *awesome* way to run programs like the 
 notebook,
 detach  them, come back to them later ,etc., and be able to control-c
 to quit them properly.  If it isn't installed on your server, let me know and
 I'll point you to a page where you can download and install it.

 I've used screen to run programs.  I never thought to use it to exit
 programs cleanly.
 I was trying to make a /etc/init.d/sage script to start and stop
 Sage.  I guess my /etc/init.d/sage could start screen.  I hadn't
 thought of that.  I'll look into it.

 Thanks!


I don't know if that is possible -- let me know.  It would be interesting.

William

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



[sage-support] Re: Possible to change base notebook URL? e.g. localhost:8000/foo/bar ?

2008-11-20 Thread Jason Grout

William Stein wrote:
 On Thu, Nov 20, 2008 at 7:31 PM, [EMAIL PROTECTED]
 [EMAIL PROTECTED] wrote:
 Possible to change base notebook URL? e.g. localhost:8000/foo/bar ?

 
 Unfortunately, this isn't supported yet, though it's certainly been requested
 before.


Indeed, see 
http://groups.google.com/group/sage-devel/browse_thread/thread/feb0b87bdfb026a3/2ff47b95d10e6c7e?lnk=gstq=%3Cbase+href#2ff47b95d10e6c7e

I thought that this was going to be a part of the templating of the 
notebook.  For whoever is doing that, how is it going?  Would it be easy 
to add the base href=something tag at the top?

Jason


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



[sage-support] Re: Possible to change base notebook URL? e.g. localhost:8000/foo/bar ?

2008-11-20 Thread Timothy Clemans

 I thought that this was going to be a part of the templating of the
 notebook.  For whoever is doing that, how is it going?  Would it be easy
 to add the base href=something tag at the top?


It will be easy to do that. Mike said he would review the notebook
tickets over the weekend. With templating I'm finding that it's easy
to introduce a lot of bugs, so it is going slowly.

 Jason


 


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



[sage-support] Re: How add new Sage notebook accounts? AND How kill notebook background process?

2008-11-20 Thread [EMAIL PROTECTED]

On Nov 20, 8:23 pm, William Stein [EMAIL PROTECTED] wrote:
 I don't know if that is possible -- let me know.  It would be interesting.

Actually I found a better way to write an init.d script.  It appears
that killing twistd shuts down the whole show.

Adding here on hopes useful to someone...

Working /etc/init.d/sage script.
(Replace seb with your non-root user account and SAGE_DIR as desired.)

#!/usr/bin/env python

import sys
import os

SAGE_DIR = /usr/local/sage-3.1.2-ubuntu32bit-i686-intel-i686-Linux
TWISTD   = SAGE_DIR + /local/bin/twistd

def start():
os.system(su seb -c 'sage -notebook ')

def stop():
os.system('kill `ps -ef | grep ' + TWISTD + ' | cut -b 10-14`
\
   1 /dev/null 2 /dev/null ; sleep 4')

if sys.argv[1] == start:
start()

if sys.argv[1] == stop:
stop()

if sys.argv[1] == restart:
stop()
start()

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