Ask Your Question

Revision history [back]

Singular objects break after using in Sage

I don't understand why this code breaks:

R1 = singular.ring('(0,a)','(x,y)','dp')
f1 = singular('x^2')
g1 = singular('x')
fsage = f1.sage()
gsage = g1.sage()
print(f1)
print(g1)
print(fsage)
print(gsage)
g2 = fsage.reduce(gsage)
print(g2)
print(f1)

It gives this result:

x^2
x
x^2
x
0
Traceback (most recent call last):    print(g1)
  File "", line 1, in <module>

  File "/tmp/tmpO7_2ph/___code___.py", line 13, in <module>
    exec compile(u'print(f1)
  File "", line 1, in <module>

  File "/home/sage/sage-7.2/local/lib/python2.7/site-packages/sage/interfaces/singular.py", line 1318, in __repr__
    elif self.type() == 'matrix':
  File "/home/sage/sage-7.2/local/lib/python2.7/site-packages/sage/interfaces/singular.py", line 2059, in type
    return m.group(1)
AttributeError: 'NoneType' object has no attribute 'group'

f1 prints fine the first time, but after running the reduce, it seems like it no longer exists. I'm trying to use f1 for other things after doing a reduce, but can't seem to find any way to do it.