AttributeError: 'CenterSkewPolynomialRing_with_category' object
has no attribute 'element_class'
is due to some bad initialization. There should be an attribute
"Element" defined on the parent before calling the "Parent" constructor.
In other words, you should follow the following pattern
class MyElement(Element):
...
class MyParent(Parent):
Element = MyElement
def __init__(self, ...):
...
Parent.__init__(self, ...)
1 class MyElement(Element):
2 ...
3
4 class MyParent(Parent):
5 Element = MyElement
6
7 def __init__(self, ...):
8 ...
9 Parent.__init__(self, ...)
I'm not sure I understand what you mean. Could you please elaborate
a little?
The attribute `element_class` of parents is created during the parent
constructor, i.e. the __init__. It creates with dynamical inheritance a
new class "element_class" which will inherits new methods depending of
the category of your parent.
In order to work, there should be an attribute "Element" available (line 5 in the above snippet). Your
class `CenterSkewPolynomialRing` is a parent that modelizes a set. It either inherits from Parent, or Ring or something similar. And the objects that belong to it should inherit from Element or RingElement or something similar.
Vincent
--
You received this message because you are subscribed to a topic in the Google Groups "sage-devel" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sage-devel/swN1Djn66KE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sage-devel+...@googlegroups.com.
To post to this group, send email to sage-...@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.
The errors (there's numerous instances of each of these errors occurring. Please find below one of each type):
(1)
sage: R.<t> = QQ[]
sage: sigma = R.hom([t+1])
sage: S.<x> = R['x', sigma]
sage: S.twist_map(-1)
Got - TypeError: bad operand type for unary ~: 'sage.rings.morphism.RingHomomorphism_im_gens'
Expected - NotImplementedError
(2)
sage: k.<t> = GF(5^3)
sage: Frob = k.Frobenius_endomorphism()
sage: S.<x> = k.['x', Frob]
sage: a = x^3 + (t^2 + 1)*x^2 + (2*t + 3)*x + t^2 + t + 2
Got - Exception raised:
... (traceback)
TypeError: Cannot convert int to sage.structure.element.Element
too few successful tests, not using stored timings
Running doctests with ID 2016-07-07-14-07-44-39349bdf.
Git branch: fix_skew_polynomials_patch
Using --optional=mpir,python2,sage
Doctesting 1 file.
sage -t src/sage/rings/polynomial/skew_polynomial_element.pyx
**********************************************************************
File "src/sage/rings/polynomial/skew_polynomial_element.pyx", line 100, in sage.rings.polynomial.skew_polynomial_element
Failed example:
q,r = c.quo_rem(b,side=Left)
Expected:
Traceback (most recent call last):
...
NotImplementedError
Got:
<BLANKLINE>
Traceback (most recent call last):
File "/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 498, in _run
self.compile_and_execute(example, compiler, test.globs)
File "/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 861, in compile_and_execute
exec(compiled, globs)
File "<doctest sage.rings.polynomial.skew_polynomial_element[19]>", line 1, in <module>
q,r = c.quo_rem(b,side=Left)
File "sage/rings/polynomial/skew_polynomial_element.pyx", line 1232, in sage.rings.polynomial.skew_polynomial_element.SkewPolynomial.quo_rem (/home/arpit/Documents/GSOC_16/sage/src/build/cythonized/sage/rings/polynomial/skew_polynomial_element.c:11397)
return self.lquo_rem(other)
File "sage/rings/polynomial/skew_polynomial_element.pyx", line 1092, in sage.rings.polynomial.skew_polynomial_element.SkewPolynomial.lquo_rem (/home/arpit/Documents/GSOC_16/sage/src/build/cythonized/sage/rings/polynomial/skew_polynomial_element.c:10375)
c = parent.twist_map(-db)(inv*a[i+db])
File "/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/rings/polynomial/skew_polynomial_ring.py", line 607, in twist_map
map = self._map**n
File "sage/categories/map.pyx", line 1264, in sage.categories.map.Map.__pow__ (/home/arpit/Documents/GSOC_16/sage/src/build/cythonized/sage/categories/map.c:9103)
return generic_power(self, n)
File "sage/structure/element.pyx", line 3496, in sage.structure.element.generic_power (/home/arpit/Documents/GSOC_16/sage/src/build/cythonized/sage/structure/element.c:27116)
return generic_power_c(a,n,one)
File "sage/structure/element.pyx", line 3529, in sage.structure.element.generic_power_c (/home/arpit/Documents/GSOC_16/sage/src/build/cythonized/sage/structure/element.c:27789)
a = ~a
TypeError: bad operand type for unary ~: 'sage.rings.morphism.RingHomomorphism_im_gens'
Killed due to segmentation fault
**********************************************************************
Tests run before process (pid=13179) failed:
sage: R.<t> = ZZ[] ## line 19 ##
sage: sigma = R.hom([t+1]) ## line 20 ##
sage: S.<x> = R['x',sigma]; S ## line 21 ##
Skew Polynomial Ring in x over Univariate Polynomial Ring in t over Integer Ring twisted by t |--> t + 1
sage: a = t + x + 1; a ## line 26 ##
x + t + 1
sage: b = S([t^2,t+1,1]); b ## line 28 ##
x^2 + (t + 1)*x + t^2
sage: c = S.random_element(degree=3,monic=True); c ## line 30 ##
x^3 + (-95*t^2 + t + 2)*x^2 + (-t^2 + t)*x + 2*t - 8
sage: a + b ## line 35 ##
x^2 + (t + 2)*x + t^2 + t + 1
sage: a - b ## line 37 ##
-x^2 - t*x - t^2 + t + 1
sage: a * b ## line 40 ##
x^3 + (2*t + 3)*x^2 + (2*t^2 + 4*t + 2)*x + t^3 + t^2
sage: b * a ## line 42 ##
x^3 + (2*t + 4)*x^2 + (2*t^2 + 3*t + 2)*x + t^3 + t^2
sage: a * b == b * a ## line 44 ##
False
sage: b^2 ## line 47 ##
x^4 + (2*t + 4)*x^3 + (3*t^2 + 7*t + 6)*x^2 + (2*t^3 + 4*t^2 + 3*t + 1)*x + t^4
sage: b^2 == b*b ## line 49 ##
True
sage: q,r = c.quo_rem(b) # default side is right ## line 80 ##
sage: q ## line 81 ##
x - 95*t^2
sage: r ## line 83 ##
(95*t^3 + 93*t^2 - t - 1)*x + 95*t^4 + 2*t - 8
sage: c == q*b + r ## line 85 ##
True
sage: q == c // b ## line 91 ##
True
sage: r == c % b ## line 93 ##
True
sage: q,r = c.quo_rem(b,side=Left) ## line 100 ##
sage: k.<t> = GF(5^3) ## line 107 ##
sage: Frob = k.frobenius_endomorphism() ## line 108 ##
sage: S.<x> = k['x',Frob] ## line 109 ##
sage: a = x^4 + (4*t + 1)*x^3 + (t^2 + 3*t + 3)*x^2 + (3*t^2 + 2*t + 2)*x + 3*t^2 + 3*t + 1 ## line 110 ##
------------------------------------------------------------------------
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/cysignals/signals.so(+0x4525)[0x7f64f35b6525]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/cysignals/signals.so(+0x4575)[0x7f64f35b6575]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/cysignals/signals.so(+0x72a7)[0x7f64f35b92a7]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x10330)[0x7f64f8402330]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/rings/polynomial/skew_polynomial_element.so(+0x3370b)[0x7f648591470b]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/structure/element.so(+0x30fa0)[0x7f64ed67afa0]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/rings/polynomial/skew_polynomial_element.so(+0x9d8c)[0x7f64858ead8c]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyObject_RichCompare+0x129)[0x7f64f86b0269]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/rings/morphism.so(+0x260c3)[0x7f649a9c00c3]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(+0xbcb2f)[0x7f64f86ccb2f]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyObject_Call+0x43)[0x7f64f8662bc3]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x3b2e)[0x7f64f871724e]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x830)[0x7f64f871a560]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(+0x8449c)[0x7f64f869449c]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyObject_Call+0x43)[0x7f64f8662bc3]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(+0x615dd)[0x7f64f86715dd]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyObject_Call+0x43)[0x7f64f8662bc3]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(+0xbdd75)[0x7f64f86cdd75]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/rings/morphism.so(+0x6f21)[0x7f649a9a0f21]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/rings/morphism.so(+0x2206d)[0x7f649a9bc06d]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/categories/map.so(+0x9241)[0x7f64ed40c241]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/categories/map.so(+0x1521f)[0x7f64ed41821f]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/categories/map.so(+0xff85)[0x7f64ed412f85]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/categories/map.so(+0x1332b)[0x7f64ed41632b]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyNumber_Multiply+0xbb)[0x7f64f866050b]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x2965)[0x7f64f8716085]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x830)[0x7f64f871a560]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(+0x8449c)[0x7f64f869449c]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/structure/parent_old.so(+0xb105)[0x7f64ef281105]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/structure/parent.so(+0x31c5a)[0x7f64ef035c5a]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/structure/parent.so(+0x3531e)[0x7f64ef03931e]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/structure/parent.so(+0x46dff)[0x7f64ef04adff]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/structure/parent.so(+0x4762e)[0x7f64ef04b62e]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x6494)[0x7f64f8719bb4]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x830)[0x7f64f871a560]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(+0x8449c)[0x7f64f869449c]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/structure/coerce_actions.so(+0x5741)[0x7f64ec6e4741]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/structure/coerce_actions.so(+0x18586)[0x7f64ec6f7586]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(+0xbcb2f)[0x7f64f86ccb2f]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/structure/coerce_actions.so(+0x165a6)[0x7f64ec6f55a6]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/structure/parent.so(+0xacd1)[0x7f64ef00ecd1]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/structure/parent.so(+0x2b9b2)[0x7f64ef02f9b2]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/structure/parent.so(+0x3eb29)[0x7f64ef042b29]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/structure/coerce.so(+0x2c420)[0x7f64ec938420]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/structure/coerce.so(+0xf4d2)[0x7f64ec91b4d2]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/structure/coerce.so(+0x30f3f)[0x7f64ec93cf3f]
/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/structure/element.so(+0xf4ad)[0x7f64ed6594ad]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyNumber_Multiply+0xbb)[0x7f64f866050b]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x2965)[0x7f64f8716085]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x830)[0x7f64f871a560]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalCode+0x19)[0x7f64f871a689]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x58de)[0x7f64f8718ffe]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x830)[0x7f64f871a560]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5936)[0x7f64f8719056]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x830)[0x7f64f871a560]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5936)[0x7f64f8719056]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x830)[0x7f64f871a560]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5936)[0x7f64f8719056]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x830)[0x7f64f871a560]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(+0x8449c)[0x7f64f869449c]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyObject_Call+0x43)[0x7f64f8662bc3]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(+0x615dd)[0x7f64f86715dd]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyObject_Call+0x43)[0x7f64f8662bc3]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(+0xbdd75)[0x7f64f86cdd75]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyObject_Call+0x43)[0x7f64f8662bc3]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x3b2e)[0x7f64f871724e]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x830)[0x7f64f871a560]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5936)[0x7f64f8719056]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5a59)[0x7f64f8719179]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x830)[0x7f64f871a560]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(+0x8449c)[0x7f64f869449c]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyObject_Call+0x43)[0x7f64f8662bc3]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(+0x615dd)[0x7f64f86715dd]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyObject_Call+0x43)[0x7f64f8662bc3]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(+0xbdf8d)[0x7f64f86cdf8d]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(+0xbcb2f)[0x7f64f86ccb2f]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyObject_Call+0x43)[0x7f64f8662bc3]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x3b2e)[0x7f64f871724e]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5a59)[0x7f64f8719179]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x830)[0x7f64f871a560]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5936)[0x7f64f8719056]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x830)[0x7f64f871a560]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5936)[0x7f64f8719056]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x830)[0x7f64f871a560]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5936)[0x7f64f8719056]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x830)[0x7f64f871a560]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5936)[0x7f64f8719056]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x830)[0x7f64f871a560]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5936)[0x7f64f8719056]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x830)[0x7f64f871a560]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyEval_EvalCode+0x19)[0x7f64f871a689]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyRun_FileExFlags+0x8a)[0x7f64f873e45a]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(PyRun_SimpleFileExFlags+0xd7)[0x7f64f873f9e7]
/home/arpit/Documents/GSOC_16/sage/local/lib/libpython2.7.so.1.0(Py_Main+0xc25)[0x7f64f8755bd5]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7f64f7941f45]
python[0x40072e]
------------------------------------------------------------------------
Attaching gdb to process id 13179.
Saved trace to /home/arpit/.sage/crash_logs/crash_VcXzuj.log
------------------------------------------------------------------------
Unhandled SIGSEGV: A segmentation fault occurred.
This probably occurred because a *compiled* module has a bug
in it and is not properly wrapped with sig_on(), sig_off().
Python will now terminate.
------------------------------------------------------------------------
**********************************************************************
----------------------------------------------------------------------
sage -t src/sage/rings/polynomial/skew_polynomial_element.pyx # Killed due to segmentation fault
----------------------------------------------------------------------
Total time for all tests: 0.4 seconds
cpu time: 0.0 seconds
cumulative wall time: 0.0 seconds