Ask Your Question
0

An error when use subs

asked 2021-11-09 11:51:07 +0200

lijr07 gravatar image

I defined a simple function as follows.

def BarInvolution(q,l): 
    r1=l
    r=r1.subs(q=1/q)

    return r

Then I use the following codes.

R=PolynomialRing(QQ,'a',15) 
a=R.gens()
BarInvolution(a[5], a[5]+1)

But it has the following errors:


KeyError Traceback (most recent call last) <ipython-input-212-6b33633fbe0d> in <module>() 1 ----> 2 BarInvolution(a[Integer(5)], a[Integer(5)])

<ipython-input-209-4f401596da47> in BarInvolution(q, l) 1 def BarInvolution(q,l): 2 r1=l ----> 3 r=r1.subs(q=Integer(1)/q) 4 5 return r

/Users/jianrongli/SageMath/local/lib/python3.7/site-packages/sage/rings/polynomial/multi_polynomial_libsingular.pyx in sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular.subs (build/cythonized/sage/rings/polynomial/multi_polynomial_libsingular.cpp:29147)() 3485 gd = parent.gens_dict(copy=False) 3486 for m,v in kw.iteritems(): -> 3487 m = gd[m] 3488 for i from 0 < i <= _ring.N: 3489 if p_GetExp((<mpolynomial_libsingular>m)._poly, i, _ring) != 0:

KeyError: 'q'

How to fix this problem? Thank you very much!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-11-09 12:59:21 +0200

Max Alekseyev gravatar image

Use r=r1.subs({q:1/q}) instead of r=r1.subs(q=1/q).

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-11-09 11:51:07 +0200

Seen: 171 times

Last updated: Nov 09 '21