Hello,

Yay, that worked!!! I needed to create and appropriately assign the
attribute Element to this class.
Thank you! :)

I'm attaching the updated error file now.

Arpit.


On 20 June 2016 at 00:45, Vincent Delecroix <20100.delecr...@gmail.com>
wrote:

> You might want to read
>
>
> http://doc.sagemath.org/html/en/thematic_tutorials/coercion_and_categories.html#coercion-and-categories
>
> I answer to your specific questions below.
>
>
> On 19/06/16 21:08, Arpit Merchant wrote:
>
>>
>>>
>>> 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.
>>>
>>>
>>> Just to restate, MyParent here is CenterSkewPolynomialRing which inherits
>> from class PolynomialRing_general which inherits from
>> sage.algebras.algebra.Algebra. Indeed, the constructor of
>> CenterSkewPolynomialRing takes `element_class` as input (which by default,
>> is None).
>>
>
> What are you doing with this element_class from the input? The only
> reasonable thing would be
>
> def __init__(self, element_class, ...):
>      self.Element = element_class
>      Algebra.__init__(self, ...)
>
> But the name "element_class" is confusing because of the
> category/parent/element logic that takes the attribute Element to build a
> new attribute named element_class.
>
> What does MyElement represent in your example? What is its connection to
>> MyParent?
>>
>
> In the context of PolynomialRing (as a parent) it would be Polynomial.
>
> And since Element is itself a class, won't writing Element = MyElement give
>> a syntax error?
>>
>
> No. These belong to very different things. There is the Element class and
> here you are creating an attribute of a class named Element.
>
>
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-devel@googlegroups.com.
> Visit this group at https://groups.google.com/group/sage-devel.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.
too few successful tests, not using stored timings
Running doctests with ID 2016-06-20-00-59-25-8e75afbe.
Git branch: apply_skew_polynomials_patch
Using --optional=mpir,python2,sage
Doctesting 1 file.
sage -t src/sage/rings/polynomial/skew_polynomial_ring.py
**********************************************************************
File "src/sage/rings/polynomial/skew_polynomial_ring.py", line 589, in 
sage.rings.polynomial.skew_polynomial_ring.SkewPolynomialRing_general.twist_map
Failed example:
    S.twist_map(-1)
Expected:
    Traceback (most recent call last):
    ...
    NotImplementedError
Got:
    <BLANKLINE>
    Traceback (most recent call last):
      File 
"/home/arpit/Documents/GSOC_16/sage-7.2/local/lib/python2.7/site-packages/sage/doctest/forker.py",
 line 496, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File 
"/home/arpit/Documents/GSOC_16/sage-7.2/local/lib/python2.7/site-packages/sage/doctest/forker.py",
 line 858, in compile_and_execute
        exec(compiled, globs)
      File "<doctest 
sage.rings.polynomial.skew_polynomial_ring.SkewPolynomialRing_general.twist_map[6]>",
 line 1, in <module>
        S.twist_map(-Integer(1))
      File 
"/home/arpit/Documents/GSOC_16/sage-7.2/local/lib/python2.7/site-packages/sage/rings/polynomial/skew_polynomial_ring.py",
 line 605, 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-7.2/src/build/cythonized/sage/categories/map.c:8985)
        return generic_power(self, n)
      File "sage/structure/element.pyx", line 3671, in 
sage.structure.element.generic_power 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/structure/element.c:28593)
        return generic_power_c(a,n,one)
      File "sage/structure/element.pyx", line 3704, in 
sage.structure.element.generic_power_c 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/structure/element.c:29266)
        a = ~a
    TypeError: bad operand type for unary ~: 
'sage.rings.morphism.RingHomomorphism_im_gens'
**********************************************************************
File "src/sage/rings/polynomial/skew_polynomial_ring.py", line 995, in 
sage.rings.polynomial.skew_polynomial_ring.SkewPolynomialRing_general.centre
Failed example:
    a = (3*t^2 + 4*t + 6)*x^2 + (2*t + 1)*x + 3*t^2 + 6*t + 4
Exception raised:
    Traceback (most recent call last):
      File 
"/home/arpit/Documents/GSOC_16/sage-7.2/local/lib/python2.7/site-packages/sage/doctest/forker.py",
 line 496, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File 
"/home/arpit/Documents/GSOC_16/sage-7.2/local/lib/python2.7/site-packages/sage/doctest/forker.py",
 line 858, in compile_and_execute
        exec(compiled, globs)
      File "<doctest 
sage.rings.polynomial.skew_polynomial_ring.SkewPolynomialRing_general.centre[7]>",
 line 1, in <module>
        a = (Integer(3)*t**Integer(2) + Integer(4)*t + 
Integer(6))*x**Integer(2) + (Integer(2)*t + Integer(1))*x + 
Integer(3)*t**Integer(2) + Integer(6)*t + Integer(4)
      File "sage/structure/element.pyx", line 1798, in 
sage.structure.element.RingElement.__mul__ 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/structure/element.c:16351)
        return coercion_model.bin_op(left, right, mul)
      File "sage/structure/coerce.pyx", line 1020, in 
sage.structure.coerce.CoercionModel_cache_maps.bin_op 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/structure/coerce.c:8743)
        action = self.get_action(xp, yp, op, x, y)
      File "sage/structure/coerce.pyx", line 1557, in 
sage.structure.coerce.CoercionModel_cache_maps.get_action 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/structure/coerce.c:15560)
        action = self.discover_action(R, S, op, r, s)
      File "sage/structure/coerce.pyx", line 1697, in 
sage.structure.coerce.CoercionModel_cache_maps.discover_action 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/structure/coerce.c:17010)
        action = (<Parent>R).get_action(S, op, True, r, s)
      File "sage/structure/parent.pyx", line 2742, in 
sage.structure.parent.Parent.get_action 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/structure/parent.c:21612)
        action = self.discover_action(S, op, self_on_left, self_el, S_el)
      File "sage/structure/parent.pyx", line 2818, in 
sage.structure.parent.Parent.discover_action 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/structure/parent.c:22849)
        action = detect_element_action(self, S, self_on_left, self_el, S_el)
      File "sage/structure/coerce_actions.pyx", line 230, in 
sage.structure.coerce_actions.detect_element_action 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/structure/coerce_actions.c:5232)
        return (RightModuleAction if X_on_left else LeftModuleAction)(Y, X, y, 
x)
      File "sage/structure/coerce_actions.pyx", line 339, in 
sage.structure.coerce_actions.ModuleAction.__init__ 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/structure/coerce_actions.c:6087)
        self.extended_base = pushout(G, S)
      File 
"/home/arpit/Documents/GSOC_16/sage-7.2/local/lib/python2.7/site-packages/sage/categories/pushout.py",
 line 3667, in pushout
        while len(Ss) > 0 and Rs[-1].has_coerce_map_from(Ss[-1]):
      File "sage/structure/parent.pyx", line 2238, in 
sage.structure.parent.Parent.has_coerce_map_from 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/structure/parent.c:17921)
        cpdef bint has_coerce_map_from(self, S) except -2:
      File "sage/structure/parent.pyx", line 2260, in 
sage.structure.parent.Parent.has_coerce_map_from 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/structure/parent.c:17871)
        return self._internal_coerce_map_from(S) is not None
      File "sage/structure/parent.pyx", line 2400, in 
sage.structure.parent.Parent._internal_coerce_map_from 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/structure/parent.c:18788)
        mor = self.discover_coerce_map_from(S)
      File "sage/structure/parent.pyx", line 2591, in 
sage.structure.parent.Parent.discover_coerce_map_from 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/structure/parent.c:19948)
        mor = mor * connecting
      File "sage/categories/map.pyx", line 906, in 
sage.categories.map.Map.__mul__ 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/categories/map.c:7354)
        return self._composition(right)
      File "sage/categories/map.pyx", line 947, in 
sage.categories.map.Map._composition 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/categories/map.c:7606)
        return self._composition_(right, H)
      File "sage/rings/morphism.pyx", line 786, in 
sage.rings.morphism.RingHomomorphism._composition_ 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/rings/morphism.c:5895)
        return homset([self(g) for g in right.im_gens()], False)
      File 
"/home/arpit/Documents/GSOC_16/sage-7.2/local/lib/python2.7/site-packages/sage/rings/homset.py",
 line 263, in __call__
        return morphism.RingHomomorphism_from_quotient(self, phi)
      File "sage/rings/morphism.pyx", line 1749, in 
sage.rings.morphism.RingHomomorphism_from_quotient.__init__ 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/rings/morphism.c:12757)
        if phi(x) != 0:
      File "sage/categories/map.pyx", line 780, in 
sage.categories.map.Map.__call__ 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/categories/map.c:6329)
        return self._call_(x)
      File "sage/rings/morphism.pyx", line 1243, in 
sage.rings.morphism.RingHomomorphism_im_gens._call_ 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/rings/morphism.c:9393)
        return x._im_gens_(self.codomain(), self.im_gens())
      File "sage/rings/integer.pyx", line 769, in 
sage.rings.integer.Integer._im_gens_ 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/rings/integer.c:7037)
        return codomain._coerce_(self)
      File "sage/structure/parent_old.pyx", line 239, in 
sage.structure.parent_old.Parent._coerce_ 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/structure/parent_old.c:4547)
        return self.coerce(x)
      File "sage/structure/parent.pyx", line 1351, in 
sage.structure.parent.Parent.coerce 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/structure/parent.c:11131)
        return (<map.Map>mor)._call_(x)
      File "sage/categories/map.pyx", line 1697, in 
sage.categories.map.FormalCompositeMap._call_ 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/categories/map.c:11365)
        x = f._call_(x)
      File "sage/rings/polynomial/skew_polynomial_element.pyx", line 3095, in 
sage.rings.polynomial.skew_polynomial_element.SkewPolynomialBaseringInjection._call_
 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/rings/polynomial/skew_polynomial_element.c:26051)
        cpdef Element _call_(self, x):
      File "sage/rings/polynomial/skew_polynomial_element.pyx", line 3096, in 
sage.rings.polynomial.skew_polynomial_element.SkewPolynomialBaseringInjection._call_
 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/rings/polynomial/skew_polynomial_element.c:25999)
        return self._new_constant_poly_(x, self._codomain)
    TypeError: 'NoneType' object is not callable
**********************************************************************
File "src/sage/rings/polynomial/skew_polynomial_ring.py", line 998, in 
sage.rings.polynomial.skew_polynomial_ring.SkewPolynomialRing_general.centre
Failed example:
    c = a + b; c
Exception raised:
    Traceback (most recent call last):
      File 
"/home/arpit/Documents/GSOC_16/sage-7.2/local/lib/python2.7/site-packages/sage/doctest/forker.py",
 line 496, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File 
"/home/arpit/Documents/GSOC_16/sage-7.2/local/lib/python2.7/site-packages/sage/doctest/forker.py",
 line 858, in compile_and_execute
        exec(compiled, globs)
      File "<doctest 
sage.rings.polynomial.skew_polynomial_ring.SkewPolynomialRing_general.centre[9]>",
 line 1, in <module>
        c = a + b; c
    NameError: name 'a' is not defined
**********************************************************************
File "src/sage/rings/polynomial/skew_polynomial_ring.py", line 1000, in 
sage.rings.polynomial.skew_polynomial_ring.SkewPolynomialRing_general.centre
Failed example:
    c.parent()
Exception raised:
    Traceback (most recent call last):
      File 
"/home/arpit/Documents/GSOC_16/sage-7.2/local/lib/python2.7/site-packages/sage/doctest/forker.py",
 line 496, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File 
"/home/arpit/Documents/GSOC_16/sage-7.2/local/lib/python2.7/site-packages/sage/doctest/forker.py",
 line 858, in compile_and_execute
        exec(compiled, globs)
      File "<doctest 
sage.rings.polynomial.skew_polynomial_ring.SkewPolynomialRing_general.centre[10]>",
 line 1, in <module>
        c.parent()
    NameError: name 'c' is not defined
**********************************************************************
2 items had failures:
   3 of  18 in 
sage.rings.polynomial.skew_polynomial_ring.SkewPolynomialRing_general.centre
   1 of  12 in 
sage.rings.polynomial.skew_polynomial_ring.SkewPolynomialRing_general.twist_map
    [151 tests, 4 failures, 0.22 s]
----------------------------------------------------------------------
sage -t src/sage/rings/polynomial/skew_polynomial_ring.py  # 4 doctests failed
----------------------------------------------------------------------
Total time for all tests: 0.3 seconds
    cpu time: 0.2 seconds
    cumulative wall time: 0.2 seconds

Reply via email to