[sage-support] Re: Handling Axiom crashes in Sage

2009-07-23 Thread Bill Page

On Thu, Jul 23, 2009 at 10:25 PM, David D.wrote:
>
> Hi, I'm trying to run a simple script that basically loops through a
> long list of polynomials, does some things with them in Axiom,
> and imports the results back to Sage.

I am very interested in your use of Axiom in Sage. I was beginning to
think I was the only one doing this sort of thing. :-(

> After running for a while (60-90 minutes) it will hang with the
> message "Axiom crashed -- automatically restarting."  At this point
> I have to Interrupt and manually restart the loop at the point where
> it failed.

I am not so sure about the origin of the "Axiom crashed ..." message
but besides an actual program crash, I think it might also simply
indicate a communication failure between Sage and FriCAS. There have
been problems with that on some platforms in the past.

I have been running a slightly modified version of your code (modified
for compatibility with an older version of Sage 3.2 and Mike Hansen's
patches for Axiom) on a fairly fast processor for more than 3 hours.
Output from a 'print a,b,c' debugging statement currently shows:

...
-8 0 3
-8 0 4
(x^4 - 8*x^3 + 4*x + 1, [2, (3*y/4 + 3*x^2/2 - 3*x/2 - 3/4)/x^2])
-8 0 5
...
-8 2 0
-8 2 1
-8 2 2
...

With no failures so far.

>
> Is there any way to catch this error automatically so I can continue
> processing without having to manually restart?   I'd like to be able
> to leave it running overnight or for days at a time, and manually
> restarting it every hour is at best annoying.
>
> I've tested and the crash doesn't happen at any specific point in the
> input or even on a specific axiom command, but it does seem to occur
> after the same amount of time roughly (1-1.5 hours) even with
> different input, so I don't believe it's a coding flaw (even though
> that would probably be the easiest thing to fix).  I'm more interested
> in finding a way to handle this error, though, than preventing it from
> happening.
>

I realize that you are more interested in a work-a-round than in
finding the cause of the problem but as both a Sage user and an Axiom
developer I am motivated to look into this problem a little further.

> Running Sage 4.0.1 and Fricas 1.0.3 on Windows Vista.
>

By running "on Windows Vista", I presume that you mean you are running
Sage (and FriCAS) on a virtual machine under Windows. Can you be more
precise about exactly what versions you are running? What Sage source
code or binary file did you download and build or install? How did you
install Fricas 1.0.3? Was it built using clisp or ecl? How much memory
is allocated for the virtual machine?

> Here's the actual code I'm running, if it helps:
> ...

Thanks. I changed only two lines in your code:

# if (gcd(D,diff(D,x)) != 1): return [0,0]
if (axiom.gcd(D,diff(D,x)) != 1): return [0,0]

# axiom.set('F', D)
axiom('F:=%s'%axiom(D).name())

The first one calls the FriCAS version of gcd since the "native" gcd
in Sage-3.2 was not able to handle some of your polynomials.

The second change is just for compatibility with the older version of
the FriCAS/Axiom interface. It works around a bug that I think is
fixed in more recent versions of Sage.

As far as I can tell these changes should not prevent the problem you
are seeing. I expect that it is a deeper problem relating to memory
and/or lisp version. If you are using FriCAS with ecl that is one of
the first things I might suspect.

In my case I am running an older version of Sage but a somewhat newer
version of FriCAS. FriCAS is compiled with clisp under 32-bit Debian
5.0 on a 3.0 GHz processor with a large cache and 4 Gbytes memory.
Sage 3.2 was built from source plus Mike Hansen's patched for axiom.py
from trac (I believe these patches must have been included in Sage
4.0.1).

I installed FriCAS 1.0.5 from

http://sage.math.washington.edu/home/page/packages/fricas-1.0.5.spkg

which I assembled from the build machinery in the spkg for
fricas-1.0.3.p0 plus the newer FriCAS sources.

---

I will let the current test run to completion (if possible) and let
you know the result. If this succeeds, I will try building a new
version of Sage and FriCAS that is closer to what you are running and
try again to see if I am able to reproduce the problem.

Regards,
Bill Page.

--~--~-~--~~~---~--~~
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: Histograms

2009-07-23 Thread Jason Grout

D White wrote:
> I'm having no luck getting the "bins" option to pylab.hist() to work.
> Here's an example:
> 
> fish_data=[random() for i in range(100)]
> import pylab
> import numpy
> 
> divats = numpy.arange(0.0,1.0,0.1)
> pylab.hist(fish_data, bins=divats)
> pylab.savefig('sage.png')
> 


You can do lots of things to solve this problem.  The easiest is to wait 
for the next Sage release, which contains a fix for this (longstanding) 
problem.

To get things to work now, the easiest thing to do is to declare divats 
to be of float type:

divats = numpy.arange(0.0, 1.0, 0.1, dtype=float)


(or use William's trick...)

Jason



--~--~-~--~~~---~--~~
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: Histograms

2009-07-23 Thread William Stein

On Thu, Jul 23, 2009 at 8:16 PM, D White wrote:
>
> I'm having no luck getting the "bins" option to pylab.hist() to work.
> Here's an example:
>
> fish_data=[random() for i in range(100)]
> import pylab
> import numpy
>
> divats = numpy.arange(0.0,1.0,0.1)
> pylab.hist(fish_data, bins=divats)
> pylab.savefig('sage.png')
>
> Without the "bins=divats" it gives the expected output.  With it, it
> says "... TypeError: function not supported for these types, and can't
> coerce safely to supported types".  I was following the example at
> http://msenux.redwoods.edu/math/python/hist.php for the use of hist().
>
> Other approaches would be welcome.

I personally like drawing histograms using finance.TimeSeries, e.g.:

fish_data=[random() for i in range(100)]
v = finance.TimeSeries(fish_data)
v.plot_histogram(bins=10)

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] Histograms

2009-07-23 Thread D White

I'm having no luck getting the "bins" option to pylab.hist() to work.
Here's an example:

fish_data=[random() for i in range(100)]
import pylab
import numpy

divats = numpy.arange(0.0,1.0,0.1)
pylab.hist(fish_data, bins=divats)
pylab.savefig('sage.png')

Without the "bins=divats" it gives the expected output.  With it, it
says "... TypeError: function not supported for these types, and can't
coerce safely to supported types".  I was following the example at
http://msenux.redwoods.edu/math/python/hist.php for the use of hist().

Other approaches would be welcome.  The goal is to compare the
distributions output by different simulations graphically, without
doing any statistical analysis.  The rpy interface complains about
lack of X11 support, at least on sagenb.org.


--~--~-~--~~~---~--~~
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: accessing sage notebook with android phone

2009-07-23 Thread Rob Beezer

On Jul 22, 10:35 pm, Rob Beezer  wrote:
> A student of mine was running a connection to a Sage notebook server
> on his Android phone last Friday.  He showed me an interesting plot,
> so I know it was working properly.  I'll point him to this discussion
> and see if I can get details.

Got back some details from my student.  This is about his experiences
with connections to sagenb.org

Hope this is helpful with the debugging.

> I have a G1 running Android 1.5 with service by T-mobile. The browser is the
> default android browser (chrome I believe). The phone sometimes has trouble
> handling POST data, which may be the source of the problem.

Rob
--~--~-~--~~~---~--~~
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: Handling Axiom crashes in Sage

2009-07-23 Thread William Stein

On Thu, Jul 23, 2009 at 7:25 PM, David D. wrote:
>
> Hi, I'm trying to run a simple script that basically loops through a
> long list of polynomials, does some things with them in Axiom, and
> imports the results back to Sage.  After running for a while (60-90
> minutes) it will hang with the message "Axiom crashed -- automatically
> restarting."  At this point I have to Interrupt and manually restart
> the loop at the point where it failed.

Do you know about Python's "try/except" construction?  Does the above
raise a RuntimeError?  Maybe you can do something sort of like:

try:
do stuff
except RuntimeError:
 restart stuff and start argain

William

> Is there any way to catch this error automatically so I can continue
> processing without having to manually restart?   I'd like to be able
> to leave it running overnight or for days at a time, and manually
> restarting it every hour is at best annoying.
>
> I've tested and the crash doesn't happen at any specific point in the
> input or even on a specific axiom command, but it does seem to occur
> after the same amount of time roughly (1-1.5 hours) even with
> different input, so I don't believe it's a coding flaw (even though
> that would probably be the easiest thing to fix).  I'm more interested
> in finding a way to handle this error, though, than preventing it from
> happening.
>
> Running Sage 4.0.1 and Fricas 1.0.3 on Windows Vista.
>
> Here's the actual code I'm running, if it helps:
>
>
> var('x,y')
>
> axiom.set('Q',   'FRAC INT')
> axiom.set('Qx',  'UnivariatePolynomial(x,Q)')
> axiom.set('Qxy', 'UnivariatePolynomial(y,FRAC Qx)')
>
> def find_generator(D) :
>
>    if (gcd(D,diff(D,x)) != 1): return [0,0]
>
>    axiom.set('F', D)
>    axiom.set('R', 'RadicalFunctionField(Q, Qx, Qxy, F :: Qx, 2)')
>    axiom.set('V', 'FiniteDivisor(Q,Qx,Qxy,R)')
>    axiom.set('S', 'PointsOfFiniteOrderRational(Qx, Qxy, R)')
>    axiom.set('G', 'torsionIfCan(divisor(0,1)$V - divisor(0,-1)$V)$S')
>
>    n = axiom('(G case "failed" => 0; G.order)').sage()
>    if (n == 0) : return [0,0]
>
>    # Needs .replace(' ','') since strings longer than 244 characters
> get extra spaces put into
>    #   them for some reason, which messes things up.
>    f = sage_eval(axiom('lift(G.function) :: EXPR FRAC
> INT').unparsed_input_form().replace(' ',''), locals={'x':x, 'y':y})
>
>    return([n,f])
>
> #--
>
> for a in range(-10,11) :
>    for b in range(-10,11) :
>        for c in range(-10,11) :
>            D = x^4+a*x^3+b*x^2+c*x+1
>            G = find_generator(D)
>            if (G != [0,0]): print(D,G)
>
> >
>



-- 
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 
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] Handling Axiom crashes in Sage

2009-07-23 Thread David D.

Hi, I'm trying to run a simple script that basically loops through a
long list of polynomials, does some things with them in Axiom, and
imports the results back to Sage.  After running for a while (60-90
minutes) it will hang with the message "Axiom crashed -- automatically
restarting."  At this point I have to Interrupt and manually restart
the loop at the point where it failed.

Is there any way to catch this error automatically so I can continue
processing without having to manually restart?   I'd like to be able
to leave it running overnight or for days at a time, and manually
restarting it every hour is at best annoying.

I've tested and the crash doesn't happen at any specific point in the
input or even on a specific axiom command, but it does seem to occur
after the same amount of time roughly (1-1.5 hours) even with
different input, so I don't believe it's a coding flaw (even though
that would probably be the easiest thing to fix).  I'm more interested
in finding a way to handle this error, though, than preventing it from
happening.

Running Sage 4.0.1 and Fricas 1.0.3 on Windows Vista.

Here's the actual code I'm running, if it helps:


var('x,y')

axiom.set('Q',   'FRAC INT')
axiom.set('Qx',  'UnivariatePolynomial(x,Q)')
axiom.set('Qxy', 'UnivariatePolynomial(y,FRAC Qx)')

def find_generator(D) :

if (gcd(D,diff(D,x)) != 1): return [0,0]

axiom.set('F', D)
axiom.set('R', 'RadicalFunctionField(Q, Qx, Qxy, F :: Qx, 2)')
axiom.set('V', 'FiniteDivisor(Q,Qx,Qxy,R)')
axiom.set('S', 'PointsOfFiniteOrderRational(Qx, Qxy, R)')
axiom.set('G', 'torsionIfCan(divisor(0,1)$V - divisor(0,-1)$V)$S')

n = axiom('(G case "failed" => 0; G.order)').sage()
if (n == 0) : return [0,0]

# Needs .replace(' ','') since strings longer than 244 characters
get extra spaces put into
#   them for some reason, which messes things up.
f = sage_eval(axiom('lift(G.function) :: EXPR FRAC
INT').unparsed_input_form().replace(' ',''), locals={'x':x, 'y':y})

return([n,f])

#--

for a in range(-10,11) :
for b in range(-10,11) :
for c in range(-10,11) :
D = x^4+a*x^3+b*x^2+c*x+1
G = find_generator(D)
if (G != [0,0]): print(D,G)

--~--~-~--~~~---~--~~
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: Symmetric Algebras

2009-07-23 Thread William Stein

On Thu, Jul 23, 2009 at 1:08 PM, VictorMiller wrote:
>
> I have a finite dimensional vector space V/k, and various
> automorphisms (i.e. members of GL(V)).  I would like to construct the
> field k(X), where the variables in X correspond to a basis of V, along
> with the operation of GL(V) on k(X).  Is there some existing way to do
> this in SAGE, or do I need to write new classes?

I think you'll need to write a new class to clearly express what
you're doing.  It should be a relatively lightweight wrapper of
Frac(k[X]) and homorphisms though.

> In addition I have a map, h, from the basis of V to another field L,
> so that h is extended in the obvious way
> k(X) --> L.
>
> Victor
> >
>



-- 
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 
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: Where does import look?

2009-07-23 Thread Marshall Hampton

Its not the same issue, but http://trac.sagemath.org/sage_trac/ticket/5206
is somewhat related.  I have taken to only using .py files, which seem
more robust in general.

-Marshall

On Jul 23, 2:14 pm, John H Palmieri  wrote:
> On Jul 23, 9:16 am, VictorMiller  wrote:
>
> > I have a sage program in a file in one of my directories called
> > calc.sage.  It uses a class that I wrote called Table, which I've put
> > in a file called Table.py in the same directory.  In the sage notebook
> > I load calc.sage (by explicitly giving the path to the directory), and
> > calc.sage has a line
>
> > from Table import Table
>
> > However, when I try to run it it can't find Table.py.  So, the
> > question is, what is the path that sage uses for import, and how do I
> > change it?  Is there a way to do this without having to include
> > explicit path qualification in the files?
>
> > Victor
>
> Here is some more data: I created three files:
>
> dga.py  -- contains the definition of a class Lambda
> new.py  -- contains the line "from dga import Lambda"
> temp.sage  -- identical to new.py
>
> From the command-line, running "load ...path.../new.py" works just
> fine.  On the other hand, running "load ...path.../temp.sage" does
> not: it complains about not being able to find the module "dga".  From
> the notebook, neither works: they both complain about not being able
> to find "dga".
>
> So there is a difference between FILE.py and FILE.sage, and there is
> also a difference between running from the command-line vs. the
> notebook.  Can anyone illuminate any of this?
>
>   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: Where does import look?

2009-07-23 Thread John H Palmieri

On Jul 23, 9:16 am, VictorMiller  wrote:
> I have a sage program in a file in one of my directories called
> calc.sage.  It uses a class that I wrote called Table, which I've put
> in a file called Table.py in the same directory.  In the sage notebook
> I load calc.sage (by explicitly giving the path to the directory), and
> calc.sage has a line
>
> from Table import Table
>
> However, when I try to run it it can't find Table.py.  So, the
> question is, what is the path that sage uses for import, and how do I
> change it?  Is there a way to do this without having to include
> explicit path qualification in the files?
>
> Victor

Here is some more data: I created three files:

dga.py  -- contains the definition of a class Lambda
new.py  -- contains the line "from dga import Lambda"
temp.sage  -- identical to new.py

>From the command-line, running "load ...path.../new.py" works just
fine.  On the other hand, running "load ...path.../temp.sage" does
not: it complains about not being able to find the module "dga".  From
the notebook, neither works: they both complain about not being able
to find "dga".

So there is a difference between FILE.py and FILE.sage, and there is
also a difference between running from the command-line vs. the
notebook.  Can anyone illuminate any of this?

  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] Symmetric Algebras

2009-07-23 Thread VictorMiller

I have a finite dimensional vector space V/k, and various
automorphisms (i.e. members of GL(V)).  I would like to construct the
field k(X), where the variables in X correspond to a basis of V, along
with the operation of GL(V) on k(X).  Is there some existing way to do
this in SAGE, or do I need to write new classes?
In addition I have a map, h, from the basis of V to another field L,
so that h is extended in the obvious way
k(X) --> L.

Victor
--~--~-~--~~~---~--~~
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: Where does import look?

2009-07-23 Thread Marshall Hampton

The very crude solution I use with pure python is to put stuff in the
site-packages directory.  In sage, this is in
$SAGE_ROOT/local/lib/python/site-packages.  It is where most python
packages install themselves.

-Marshall

On Jul 23, 12:11 pm, VictorMiller  wrote:
> I know that you can modify sys.path which is where python looks to
> find where to use import.  The question that I should have asked is
> how does one develop new sage functions.  It makes sense for each
> project to have its own directory to contain the pieces of stuff.
> What I'd like is to have some sort of function and/or command for a
> SAGE notebook which would give a list of directories to look in when I
> do attach or load, so instead of saying
>
> attach somelongpathstring/foo.sage
>
> I could just say
>
> adddirectory somelongpathstring
> attach foo.sage
>
> and foo.sage could have lines like
>
> from bar import baz
>
> where bar.py is in the directory somelongpathstring
>
> Victor
>
> On Jul 23, 1:56 pm, John Cremona  wrote:
>
> > Hi Victor.  Although I don't know the answer to your question, I'm
> > sure that it actually a python question (rather than a sage one) so I
> > expect that the answer lies somewhere in the wealth of online python
> > documentation!
>
> > Of course someone else might give a more helpful answer...
>
> > John Cremona
>
> > On Jul 23, 5:16 pm, VictorMiller  wrote:
>
> > > I have a sage program in a file in one of my directories called
> > > calc.sage.  It uses a class that I wrote called Table, which I've put
> > > in a file called Table.py in the same directory.  In the sage notebook
> > > I load calc.sage (by explicitly giving the path to the directory), and
> > > calc.sage has a line
>
> > > from Table import Table
>
> > > However, when I try to run it it can't find Table.py.  So, the
> > > question is, what is the path that sage uses for import, and how do I
> > > change it?  Is there a way to do this without having to include
> > > explicit path qualification in the files?
>
> > > Victor
--~--~-~--~~~---~--~~
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: breaking out of double for loops

2009-07-23 Thread Craig Citro

> for x in range(10):
>     for y in range(10):
>          if 2^x*3^y==12:
>                break
>
> (x,y)
>

I think the most "pythonic" solution would be to use
itertools.product, which requires python 2.6 or greater (and hence
sage 4.1 or greater):

sage: import itertools
sage: for x,y in itertools.product(range(10), range(10)):
   ...: if 2^x*3^y == 12:
   ...: break
   ...:
sage: print x,y
2 1

-cc

--~--~-~--~~~---~--~~
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: Where does import look?

2009-07-23 Thread VictorMiller

I know that you can modify sys.path which is where python looks to
find where to use import.  The question that I should have asked is
how does one develop new sage functions.  It makes sense for each
project to have its own directory to contain the pieces of stuff.
What I'd like is to have some sort of function and/or command for a
SAGE notebook which would give a list of directories to look in when I
do attach or load, so instead of saying

attach somelongpathstring/foo.sage

I could just say

adddirectory somelongpathstring
attach foo.sage

and foo.sage could have lines like

from bar import baz

where bar.py is in the directory somelongpathstring

Victor

On Jul 23, 1:56 pm, John Cremona  wrote:
> Hi Victor.  Although I don't know the answer to your question, I'm
> sure that it actually a python question (rather than a sage one) so I
> expect that the answer lies somewhere in the wealth of online python
> documentation!
>
> Of course someone else might give a more helpful answer...
>
> John Cremona
>
> On Jul 23, 5:16 pm, VictorMiller  wrote:
>
> > I have a sage program in a file in one of my directories called
> > calc.sage.  It uses a class that I wrote called Table, which I've put
> > in a file called Table.py in the same directory.  In the sage notebook
> > I load calc.sage (by explicitly giving the path to the directory), and
> > calc.sage has a line
>
> > from Table import Table
>
> > However, when I try to run it it can't find Table.py.  So, the
> > question is, what is the path that sage uses for import, and how do I
> > change it?  Is there a way to do this without having to include
> > explicit path qualification in the files?
>
> > Victor
>
>
--~--~-~--~~~---~--~~
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: Where does import look?

2009-07-23 Thread John Cremona

Hi Victor.  Although I don't know the answer to your question, I'm
sure that it actually a python question (rather than a sage one) so I
expect that the answer lies somewhere in the wealth of online python
documentation!

Of course someone else might give a more helpful answer...

John Cremona

On Jul 23, 5:16 pm, VictorMiller  wrote:
> I have a sage program in a file in one of my directories called
> calc.sage.  It uses a class that I wrote called Table, which I've put
> in a file called Table.py in the same directory.  In the sage notebook
> I load calc.sage (by explicitly giving the path to the directory), and
> calc.sage has a line
>
> from Table import Table
>
> However, when I try to run it it can't find Table.py.  So, the
> question is, what is the path that sage uses for import, and how do I
> change it?  Is there a way to do this without having to include
> explicit path qualification in the files?
>
> Victor
--~--~-~--~~~---~--~~
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: units and absolute fields

2009-07-23 Thread John Cremona



On Jul 22, 12:21 pm, davidloeffler  wrote:
> On Jul 21, 6:01 pm, mac8090  wrote:
>
>
>
> > For a field extension over Q of 2 values, for example M=QQ(i, sqrt
> > (2)), it is possible to find an absolute field X by the following
>
> > L.=NumberField(x^2-2)
> > R.=L[]
> > M.=L.extension(t^2+1)
>
> > (this gets M)
>
> > X.=M.absolute_field()
>
> > so far so good. A field in terms of b and c has now become a field in
> > terms of just one value, d. Also, the absolute_field command also
> > gives functions between M and X, namely definable as:
>
> > from_X, to_X = X.structure()
>
> > The units of M, X respectively can be found by
>
> > X.units()
> > M.units()
>
> > However, would it now make sense if the units of M corresponded to the
> > units of X? Or is that wrong?
>
> > If so, the following statement
>
> > [to_X(g) for g in M.units()]==X.units()
>
> > would return True. But it does not. Nor are the values of X.units() a
> > rearrangement of the values in the set on the left hand side. Why
> > doesn't this work?
>
> I find it curious that the example doesn't work for you, because for
> me it does work; in fact, if you look at the code of the units()
> command, you'll see that for a relative field like M, it's internally
> calculating the units in the corresponding absolute field (using Pari)
> and mapping them over to the relative field, exactly as you're doing
> "by hand" in your example.
>
> Which version of Sage are you using? Some of this code has been
> changed relatively recently -- Francis Clarke fixed a number of bugs
> in the relative number fields code in patch #5842, which was included
> in Sage 4.0.2 (released about a month back).
>
> David

Good point.  Remember Rule 1:  always say exactly which version of
Sage you are using (and preferably which platform, etc), and give the
exact input which causes the problem!

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] Where does import look?

2009-07-23 Thread VictorMiller

I have a sage program in a file in one of my directories called
calc.sage.  It uses a class that I wrote called Table, which I've put
in a file called Table.py in the same directory.  In the sage notebook
I load calc.sage (by explicitly giving the path to the directory), and
calc.sage has a line

from Table import Table

However, when I try to run it it can't find Table.py.  So, the
question is, what is the path that sage uses for import, and how do I
change it?  Is there a way to do this without having to include
explicit path qualification in the files?

Victor
--~--~-~--~~~---~--~~
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: breaking out of double for loops

2009-07-23 Thread Marshall Hampton

Two more solutions:

#ugly:
x,y = 0,0
while 2^x*3^y != 12 and x < 10:
y = 0
x = x + 1
while 2^x*3^y != 12 and y < 10:
y = y + 1

#short:
for x,y in CartesianProduct(range(10),range(10)):
if 2^x*3^y==12:
break

-Marshall Hampton

On Jul 23, 4:31 am, mac8090  wrote:
> How does one break from a double for loop, or a loop of two variables?
> for example:
>
> for x in range(10):
>  for y in range(10):
>   if 2^x*3^y==12:
> break
>
> (x,y)
>
> I want this to return (2,1) rather than (9,1). This is just a
> simplified example, but that is the approximate situation.
>
> Any ideas?
--~--~-~--~~~---~--~~
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: numerical eigenforms

2009-07-23 Thread Minh Nguyen

Hi Ron,

On Thu, Jul 23, 2009 at 5:13 PM, rje wrote:



> p.s.  Just to make sure there is at least one thing useful in this
> post, I point out a misprint after the word "polynomial" at
> http://www.sagemath.org/doc/bordeaux_2008/level_one_forms.html

This is now ticket #6600

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

-- 
Regards
Minh Van Nguyen

--~--~-~--~~~---~--~~
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: breaking out of double for loops

2009-07-23 Thread Minh Nguyen

On Thu, Jul 23, 2009 at 8:41 PM, Carlo
Hamalainen wrote:
>
> On Thu, Jul 23, 2009 at 12:31 PM, mac8090 wrote:
>> How does one break from a double for loop, or a loop of two variables?
>
> One way is to use an exception:
>
>
> class GetOut(Exception): pass
>
> try:
>for x in range(10):
>for y in range(10):
>if 2^x*3^y==12:
>raise GetOut
> except GetOut:
>pass
>
> print x, y
>
> $ sage foo.sage
> 2 1

Using exceptions to break out of multiple loops is discussed at this thread

http://mail.python.org/pipermail/python-list/2002-January/123690.html

-- 
Regards
Minh Van Nguyen

--~--~-~--~~~---~--~~
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: breaking out of double for loops

2009-07-23 Thread Carlo Hamalainen

On Thu, Jul 23, 2009 at 12:31 PM, mac8090 wrote:
> How does one break from a double for loop, or a loop of two variables?

One way is to use an exception:


class GetOut(Exception): pass

try:
for x in range(10):
for y in range(10):
if 2^x*3^y==12:
raise GetOut
except GetOut:
pass

print x, y

$ sage foo.sage
2 1



-- 
Carlo Hamalainen
http://carlo-hamalainen.net

--~--~-~--~~~---~--~~
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: breaking out of double for loops

2009-07-23 Thread Laurent

mac8090 ha scritto:
>
> for x in range(10):
>  for y in range(10):
>   if 2^x*3^y==12:
> break
>
> (x,y)
>
>   

I would like that :

def foo():
   for x in range(10):
  for y in range(10):
 if 2^x*3^y==12:
return (x,y)


The return command exits the function (in particular the two loops).

Hope that it helps

Laurent


--~--~-~--~~~---~--~~
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] breaking out of double for loops

2009-07-23 Thread mac8090


How does one break from a double for loop, or a loop of two variables?
for example:


for x in range(10):
 for y in range(10):
  if 2^x*3^y==12:
break

(x,y)




I want this to return (2,1) rather than (9,1). This is just a
simplified example, but that is the approximate situation.

Any ideas?
--~--~-~--~~~---~--~~
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: changeing sage -b (cython)

2009-07-23 Thread Robert Bradshaw

I'm not sure if or when either of these will be available, but  
neither are trivial. Both questions are probably better asked on the  
cython lists.

- Robert


On Jul 22, 2009, at 12:17 PM, Ethan Van Andel wrote:

> Robert,
>
> Is there any prediction for when numpy complex types will work?
> (outside of the notebook, when compiling via sage -b)


On Jul 22, 2009, at 12:56 PM, Ethan Van Andel wrote:
>
> Yet another question:
>
> When I compile my class, I get something like this:
>
> cdef class Riemann_Map:
> cdef int N, B, ncorners
> cdef f
> cdef opp
> cdef double complex a
> cdef np.ndarray[float,ndim = 1] tester
>   ^
> 
>
> /home/evlutte/opt/sage-3.2.3/devel/sage-main/sage/plot/riemann.pyx:
> 39:19: Buffer types only allowed as function local variables
>
> Is there any way around this, that is, any way to get efficient array
> performance from my self.something arrays?


--~--~-~--~~~---~--~~
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: numerical eigenforms

2009-07-23 Thread Minh Nguyen

On Thu, Jul 23, 2009 at 5:13 PM, rje wrote:



> p.s.  Just to make sure there is at least one thing useful in this
> post, I point out a misprint after the word "polynomial" at
> http://www.sagemath.org/doc/bordeaux_2008/level_one_forms.html

You're invited to upload a patch to the trac server. If you rather
prefer that someone else do it, I'd be more than happy to do it in
your name.

-- 
Regards
Minh Van Nguyen

--~--~-~--~~~---~--~~
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: numerical eigenforms

2009-07-23 Thread rje

It's not so much that I haven't read the documentation, but rather
that the definitions have been unclear.
It's not Sage, it's me--things have been unclear all my life.   To
paraphrase from 1969's "Both sides now", I really don't know
"numerical_eigenforms" at all.  What Sage calls a cusp form on Gamma1
(N) with nebentypus  is what I have called, since childhood, a cusp
form on Gamma0(N) with character multiplier.  I blame my parents. The
command n=numerical_eigenforms(Gamma0(N),k)
evidently deals with the case of trivial nebentypus, which of course
explains why n.ap(2) returns an empty list when k is odd. On the other
hand, if I'm thinking correctly, the command
n=numerical_eigenforms(Gamma1(N),k)
should handle *all* the nebentypuses (sorry if that's the incorrect
plural), i.e.,  all Dirichlet characters mod N.  To see if I have the
slightest idea what is going on, I wrote this one line Sage program:

sage: numerical_eigenforms(Gamma1(11),2).systems_of_abs(14)
[
[1.3281310261, 3.44297864737, 4.23200071553, 7.37063348168, 1.0,
12.2051447409],
[1.3281310261, 3.44297864737, 4.23200071553, 7.37063348168, 1.0,
12.2051447409],
[1.3281310261, 3.44297864737, 4.23200071553, 7.37063348168, 11.0,
12.2051447409],
[1.3281310261, 3.44297864737, 4.23200071553, 7.37063348168, 11.0,
12.2051447409],
[2.0, 1.0, 1.0, 2.0, 1.0, 4.0],
[2.49721204096, 2.2684571924, 5.3935303785, 6.21882320691, 11.0,
13.3429547647],
[2.49721204096, 2.2684571924, 5.3935303785, 6.21882320691, 11.0,
13.3429547647],
[2.49721204096, 2.2684571924, 5.3935303785, 6.21882320691, 1.0,
13.3429547647],
[2.49721204096, 2.2684571924, 5.3935303785, 6.21882320691, 1.0,
13.3429547647],
[3.0, 4.0, 6.0, 8.0, 1.0, 14.0]
]
Fine, the fifth item in this list corresponds to something even I can
understand--it's the weight 2 newform on Gamma0(11) which is simply a
product of four eta functions, and it can be found on the opening page
of Stein's Modular Forms Explorer.  The last item in the list I kinda
understand, but I'm not really sure how it corresponds to a standard
"eigenform"; the eigenvalues a(p) (except for p=11) are the
coefficients of the (nonholomorphic) Eisenstein series of weight 2
(sorta akin to a weight 2 oldform on the full modular group).  The
other eight items in the list are--well, I dunno.  One might guess
that items 1-4 correspond to four Galois conjugate eigenforms with a
quintic nebentypus mod 11, and similarly for items 6-9.  But there are
no such weight 2 "eigenforms" with quintic nebentypus in the space of
cusp forms, are there?  One certainly won't find them in the Modular
Forms Explorer.  So what are these animals?  I leave with the
following challenge: Use Sage to determine (algebraically, not just
numerically) the first ten coefficients c(p) of the "eigenform"
corresponding to item 1 in the list.rje

p.s.  Just to make sure there is at least one thing useful in this
post, I point out a misprint after the word "polynomial" at
http://www.sagemath.org/doc/bordeaux_2008/level_one_forms.html

**
On Jul 19, 12:18 pm, William Stein  wrote:
> 2009/7/15rje:
>
>
>
> > What is going on here? Does this only work for even weights?rje
>
> > sage: n=numerical_eigenforms(15,3);n.ap(2)
> > []
**
> Type
>
> sage: numerical_eigenforms?
>
> and read it.   In particular, the first input is the group and if a
> number N is given that it just defaults to Gamma0(N).  So the above is
> correctly giving you the eigenvalues for Gamma0(15) and odd weight.
>
> sage: n=numerical_eigenforms(Gamma1(15),3);n.ap(2)
> [-5.0 - 1.99021290795e-14*I, -3.0 + 2.40206990184e-13*I, 5.0 +
> 3.72521051072e-12*I, 1.001 - 4.0*I, 0.9998 + 4.0*I,
> -3.0 - 3.86606026001e-12*I, 0.224744871392 - 0.224744871392*I,
> 0.224744871392 + 0.224744871392*I, -2.22474487139 - 2.22474487139*I,
> 1.0 - 4.0*I, -3.48610029732e-14 - 2.2360679775*I, -1.0 +
> 1.43583146453e-14*I, -4.27435864481e-14 + 2.2360679775*I, 1.0 + 4.0*I,
> -2.22474487139 + 2.22474487139*I, 1.0 - 1.21528935033e-14*I]
>
> 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
-~--~~~~--~~--~--~---