ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 31 May 2019 15:28:23 +0200AttributeError: 'dict' object has no attribute 'solve'https://ask.sagemath.org/question/46729/attributeerror-dict-object-has-no-attribute-solve/How I can fix this error '''AttributeError: 'dict' object has no attribute 'solve'
It appears after I tried to `solve(P)`:
G = I.groebner_basis()
P = {}
ind = 0
for i in range (n):
if (G[i].degree() < num):
ind = ind+1
P[ind] = G[i]
solve(P)Thu, 30 May 2019 23:56:09 +0200https://ask.sagemath.org/question/46729/attributeerror-dict-object-has-no-attribute-solve/Answer by nbruin for <p>How I can fix this error '''AttributeError: 'dict' object has no attribute 'solve'
It appears after I tried to <code>solve(P)</code>:</p>
<pre><code>G = I.groebner_basis()
P = {}
ind = 0
for i in range (n):
if (G[i].degree() < num):
ind = ind+1
P[ind] = G[i]
solve(P)
</code></pre>
https://ask.sagemath.org/question/46729/attributeerror-dict-object-has-no-attribute-solve/?answer=46730#post-id-46730I don't think solve does what you hope it does. It seems from your code that you want to select elements from a groebner basis of bounded degree (I guess n is the length of G?) and want to find the solutions to those equations.
If the equations you select still define a 0-dimensional variety and you're interested in solutions that take values in the ground field, you might be able to do something like
J=ideal([f for f in I.groebner_basis() if f.degree() lt num])
J.variety()
Putting your selected polynomials in a dictionary is probably not a good idea. You'd be better off putting them in a list, i.e.
P=[]
...
P.append(G[i])
...Fri, 31 May 2019 00:24:48 +0200https://ask.sagemath.org/question/46729/attributeerror-dict-object-has-no-attribute-solve/?answer=46730#post-id-46730Comment by Maori for <p>I don't think solve does what you hope it does. It seems from your code that you want to select elements from a groebner basis of bounded degree (I guess n is the length of G?) and want to find the solutions to those equations.</p>
<p>If the equations you select still define a 0-dimensional variety and you're interested in solutions that take values in the ground field, you might be able to do something like</p>
<pre><code>J=ideal([f for f in I.groebner_basis() if f.degree() lt num])
J.variety()
</code></pre>
<p>Putting your selected polynomials in a dictionary is probably not a good idea. You'd be better off putting them in a list, i.e.</p>
<pre><code>P=[]
...
P.append(G[i])
...
</code></pre>
https://ask.sagemath.org/question/46729/attributeerror-dict-object-has-no-attribute-solve/?comment=46740#post-id-46740Thank you. Firstly, I make `P=[]` then (in my code P based on Groebner Basis of ideal, that is why it works)
J=ideal([f for f in P])
J.variety()
And it helpsFri, 31 May 2019 15:28:23 +0200https://ask.sagemath.org/question/46729/attributeerror-dict-object-has-no-attribute-solve/?comment=46740#post-id-46740