You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is the signature doesn't match the domain, so the incorrect conversion map is being called.
More specifically, I have an algebra (with a basis) where I want to be able to construct elements from the input of (R, R, R). However it errors out because it's trying to apply the natural coercion from the base ring into my algebra.
classFoo(Parent):
def__init__(self, R):
Parent.__init__(self, base=R, category=AlgebrasWithBasis(R))
def_element_constructor_(self, *args):
returnself.element_class(self, *args)
classElement(Element): # Remember to import Element in the command linedef__init__(self, parent, *args):
Element.__init__(self, parent)
self.value=argsdef_repr_(self):
return"bar: {}".format(self.value)
So try:
sage: F = Foo(ZZ)
sage: F._element_constructor_(1, 2, 3)
bar: (1, 2, 3)
sage: F(1, 2, 3)
...
TypeError: Underlying map <type 'instancemethod'> does not accept additional arguments
Really I'm wanting a (conversion) map from R x R x R to my algebra.
Note that F(1) goes into an infinite loop because I haven't defined a one() method, nor multiplication.
If you want a conversion map from R x R x R, then you should call it with F( (1, 2, 3) ). I'd say the problem is that your signature isn't supported out of the box (and I don't think it should). If you want to support more liberal syntax for F(...) then you can implement it ad-hoc.
Actually I first wanted R x M for some other parent M. So F(3, (1,2)) (which is what my repr currently looks like) does not with the same error as above, but this works F((1, 2), 3) (because there is no coercion map in the first arg). I can reverse my repr order, but I prefer my current output.
The problem is the signature doesn't match the domain, so the incorrect conversion map is being called.
More specifically, I have an algebra (with a basis) where I want to be able to construct elements from the input of
(R, R, R)
. However it errors out because it's trying to apply the natural coercion from the base ring into my algebra.So try:
Really I'm wanting a (conversion) map from
R x R x R
to my algebra.Note that
F(1)
goes into an infinite loop because I haven't defined aone()
method, nor multiplication.CC: @vbraun @nbruin @nbruin @simon-king-jena
Component: coercion
Keywords: algebras, base ring
Issue created by migration from https://trac.sagemath.org/ticket/16054
The text was updated successfully, but these errors were encountered: