[sage-support] Strange error

2014-10-23 Thread João Alberto
I am running the following Python example from the book Learning
Python, from Mark Lutz and David Ascher, but Sage is returning a
TypeError after presenting the correct response. Can anyone explain me
why? I've found this very strange.

sage: class Commuter:
: def __init__(self, val):
: self.val = val
: def __add__(self, other):
: print add, self.val, other
: def __radd__(self, other):
: print radd, self.val, other
:
sage: x = Commuter(88)
sage: y = Commuter(99)
sage: x + 1
add 88 1
sage: 1 + y
radd 99 1
---
TypeError Traceback (most recent call last)
ipython-input-76-e047f7a3a32a in module()
 1 Integer(1) + y

/usr/local/Sagemath/sage-6.3/local/lib/python2.7/site-packages/sage/structure/element.so
in sage.structure.element.RingElement.__add__
(build/cythonized/sage/structure/element.c:14696)()

/usr/local/Sagemath/sage-6.3/local/lib/python2.7/site-packages/sage/structure/coerce.so
in sage.structure.coerce.CoercionModel_cache_maps.bin_op
(build/cythonized/sage/structure/coerce.c:8323)()

TypeError: unsupported operand parent(s) for '+': 'Integer Ring' and
'type 'instance''

-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Strange error using R pexpect interface?

2011-06-06 Thread kcrisman
I'm using R matrices to use an R program and then do things with it in
Sage.  For some reason Sage doesn't get the right answer for
matrices above a certain size.

The first one is right (it gives the space that is in the returned
string) while the second one makes no sense; ZZ='' is what actually
comes back.  But there is no real reason for this - what's special
about the length? - and doing these in Sage's r_console() gives normal
results for the matrix.

So I feel like pexpect must be doing something naughty.  Does anyone
have any ideas what might be going on so I can use more data?

Thanks,
- kcrisman


sage: ZZ = r.eval('matrix(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2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, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2,
2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1,
1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 4, 4, 4, 4, 2, 2, 2, 2, 4, 4, 4, 4, 2, 2, 2, 2, 3, 3, 3,
3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 1, 1, 1, 1, 4, 4, 4, 4, 1, 1, 1, 1,
3, 3, 3, 3, 2, 2, 2, 2, 4, 4, 4, 4, 1, 1, 1, 1, 4, 4, 4, 4, 1, 1, 1,
1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 1, 1, 1, 1, 3, 3, 3, 3, 1,
1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 3, 3, 3, 3, 4, 4, 4, 4, 2, 2, 2, 2,
3, 3, 3, 3, 2, 2, 2, 2, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 4, 4, 4, 4, 1,
1, 1, 1, 3),ncol=4)'); ZZ[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
URL: http://www.sagemath.org


[sage-support] strange error message when using maxima

2010-10-02 Thread Oscar Gerardo Lazo Arjona

When I use sage from the command line I get the following error message:

sage: integral(x,x)
'import site' failed; use -v for traceback
Traceback (most recent call last):
  File /home/oscar/sage-4.5.2/local/bin/sage-cleaner, line 21, in 
module

import os, shutil, sys, time, socket
  File /home/oscar/sage-4.5.2/local/lib/python/os.py, line 49, in 
module

import posixpath as path
  File /home/oscar/sage-4.5.2/local/lib/python/posixpath.py, line 14, 
in module

import stat
  File stat.py, line 2, in module
from sage.all_cmdline import *   # import sage library
ImportError: No module named sage.all_cmdline
1/2*x^2

But as you can see, sage returns the correct answer. If I start sage 
from ~/sage-4.5.2 I don't get the error message:


sage: integral(x,x)
1/2*x^2

I think that this might be related to the way in which I added 
~/sage-4.5.2 to my PATH: I put the following line at the end of my 
~/.bashrc file (Ubuntu 10.04):


export PATH=$PATH:/home/oscar/sage-4.5.2

I also think this is Maxima-related, since it appears to happen only 
when calling Maxima (It does not happen anymore once Maxima has been 
started). I've had this error since sage 3.x but I thought I was making 
some no0bish mistake (which might still be the case).


thanks!

Oscar


--
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
URL: http://www.sagemath.org


[sage-support] Strange Error in Converting polynomials to vector

2007-10-01 Thread Ahmad

I just tried this and when the field is bigger or equal  to 2^16 I got
following error:

2^15: Fine!

K.a = GF(2^15, 'a')
V = K.vector_space()
z = (a+1)^13
V(z)

(1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0)


2^16: Error!

K.a = GF(2^16, 'a')
V = K.vector_space()
z = (a+1)^13
V(z)



Exception (click to the left for traceback):
...
TypeError: can't initialize vector from nonzero non-list



I just wanted to know what is the difference between case 2^15 and
2^16.

Thanx in advance!

Bests,
Ahmad


--~--~-~--~~~---~--~~
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://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~--~~~~--~~--~--~---