ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 17 May 2019 21:58:18 +0200How to recreate traceback?https://ask.sagemath.org/question/46565/how-to-recreate-traceback/Hello, Sage Community.
When we write something like `sin(t)` without previously defining the variable `t`, we get a traceback like
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-138-17829414d33a> in <module>()
----> 1 sin(t)
NameError: name 't' is not defined
I would like to reproduce this text automatically. I have tried the following:
try:
sin(t)
except:
_typ_, _val_, _tb_ = sys.exc_info()
traceback.print_exception(_typ_, _val_, _tb_)
However, this produces a less rich output:
Traceback (most recent call last):
File "<ipython-input-139-55b9ce98509c>", line 2, in <module>
sin(t)
NameError: name 't' is not defined
How could I reproduce the rich output?
Thanks in advance for your answers!dsejasFri, 17 May 2019 21:58:18 +0200https://ask.sagemath.org/question/46565/Traceback errorhttps://ask.sagemath.org/question/33456/traceback-error/ Hello,
I am new to Sage Math and new to this forum. Basically, I have written code to generate a specific graph on 10 vertices from its adjacency matrix. I am receiving an error (pasted below), but when my advisor runs the same exact code on his machine, he does not receive an error. I do not know how to resolve this situation. I've pasted my code below, and the error that I receive follows. Any insight would be much appreciated, and let me know if you need more details (e.g., information about the machine I'm using, operating system, etc.).
sage: M = Matrix([(0,0,1,0,1,1,1,0,1,1), (0,0,0,1,1,1,0,1,1,1), \
(1,0,0,1,1,1,1,0,0,0), (0,1,1,0,1,1,0,1,0,0), (1,1,1,1,0,1,0,0,1,0), \
(1,1,1,1,1,0,0,0,0,1), (1,0,1,0,0,0,0,1,1,1), (0,1,0,1,0,0,1,0,1,1), \
(1,1,0,0,1,0,1,1,0,1), (1,1,0,0,0,1,1,1,1,0)])
sage: M
[0 0 1 0 1 1 1 0 1 1]
[0 0 0 1 1 1 0 1 1 1]
[1 0 0 1 1 1 1 0 0 0]
[0 1 1 0 1 1 0 1 0 0]
[1 1 1 1 0 1 0 0 1 0]
[1 1 1 1 1 0 0 0 0 1]
[1 0 1 0 0 0 0 1 1 1]
[0 1 0 1 0 0 1 0 1 1]
[1 1 0 0 1 0 1 1 0 1]
[1 1 0 0 0 1 1 1 1 0]
sage: G = Graph(M); G
Graph on 10 vertices
sage: G.plot().show()
Here is the error.
Traceback (most recent call last): [0 0 0 1 1 1 0 1 1 1]
File "", line 1, in <module>
File "/private/var/folders/sw/0pqlf1452k58z_jbk3_yv5m97h2tyd/T/tmpabbyzH/___code___.py", line 5
G = Graph(M); G
^
SyntaxError: invalid syntax
JEAThu, 19 May 2016 21:56:50 +0200https://ask.sagemath.org/question/33456/Can't find Cause of Traceback Errorhttps://ask.sagemath.org/question/29923/cant-find-cause-of-traceback-error/ I'm trying to convert this code that runs in Python 2.7 to Sage but can't even get a hint from Sage at what line the code is not accepted by Sage.
def Ramanujan(t):
cubes = [x**3 for x in range(1,t/10)]
crev = [] ''' Calculating Cube Roots'''
for x,x3 in enumerate(cubes): crev[x3] = x + 1
sums = sorted(x + y for x in cubes for y in cubes if y < x) ''' Organizing Data'''
for i in range(1, len(sums)-1):
if sums[i-1] != sums[i] and sums[i] == sums[i+1]: ''' Finding solutions'''
if sums[i]<=t: ''' Limiting how many solutions printed.'''
print "%10d"%(sums[i]) ''' Printing desired outputs '''
else:
break ''' Ending the function.'''
The only thing that Sage will report back is Traceback Error for SyntaxError: invalid syntax but no line information..
Can anyone tell where specifically the syntax is invalid??KristofferHMon, 12 Oct 2015 05:40:23 +0200https://ask.sagemath.org/question/29923/scary muli_polynomial_ring warninghttps://ask.sagemath.org/question/10426/scary-muli_polynomial_ring-warning/Thw following warning message looks pretty scary, since it is accompanied by a stack trace. And I have absolutely no idea (yet) as to what it is trying to tell me. Is the result it prints in the end reliable? If so, why the fuss? And if not, what is causing this problem? Is this an indication of a bug?
sage: R1.<cosAlpha, sinAlpha> = AA[]
sage: QR1 = R1.quotient(R1.ideal(cosAlpha^2 + sinAlpha^2 - 1))
sage: QR1(-8*sinAlpha - 4*sinAlpha*cosAlpha + 5*2*(2*sinAlpha*cosAlpha)*(cosAlpha*cosAlpha - sinAlpha*sinAlpha))
verbose 0 (3490: multi_polynomial_ideal.py, groebner_basis) Warning: falling back to very slow toy implementation.
singular_ring_delete(ring*) called with NULL pointer.
File "<stdin>", line 1, in <module>
File "_sage_input_4.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("UVIxKC04KnNpbkFscGhhIC0gNCpzaW5BbHBoYSpjb3NBbHBoYSArIDUqMiooMipzaW5BbHBoYSpjb3NBbHBoYSkqKGNvc0FscGhhKmNvc0FscGhhIC0gc2luQWxwaGEqc2luQWxwaGEpKQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))' + '\n', '', 'single')
File "", line 1, in <module>
File "/tmp/tmpKfaoEi/___code___.py", line 3, in <module>
exec compile(u'QR1(-_sage_const_8 *sinAlpha - _sage_const_4 *sinAlpha*cosAlpha + _sage_const_5 *_sage_const_2 *(_sage_const_2 *sinAlpha*cosAlpha)*(cosAlpha*cosAlpha - sinAlpha*sinAlpha))' + '\n', '', 'single')
File "", line 1, in <module>
File "sage/rings/quotient_ring.py", line 993, in _element_constructor_
return self.element_class(self, x)
File "sage/rings/quotient_ring_element.py", line 99, in __init__
self._reduce_()
File "sage/rings/quotient_ring_element.py", line 118, in _reduce_
self.__rep = I.reduce(self.__rep)
File "sage/rings/polynomial/multi_polynomial_ideal.py", line 4019, in reduce
strat = self._groebner_strategy()
File "sage/rings/polynomial/multi_polynomial_ideal.py", line 910, in _groebner_strategy
return GroebnerStrategy(MPolynomialIdeal(self.ring(), self.groebner_basis()))
Exception KeyError: (The ring pointer 0x0,) in 'sage.libs.singular.ring.singular_ring_delete' ignored
-40*cosAlphabar*sinAlphabar^3 + 16*cosAlphabar*sinAlphabar - 8*sinAlphabarMvGWed, 07 Aug 2013 10:06:35 +0200https://ask.sagemath.org/question/10426/