Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solveset.py "ValueError: list.remove(x): x not in list" #15422

Open
jmgc opened this issue Oct 23, 2018 · 13 comments
Open

solveset.py "ValueError: list.remove(x): x not in list" #15422

jmgc opened this issue Oct 23, 2018 · 13 comments

Comments

@jmgc
Copy link
Contributor

jmgc commented Oct 23, 2018

Using the nonlinsolve solver in simply version 1.3, python 3.6, I get the error:

sympy/solvers/solveset.py:2635: ValueError: list.remove(x): x not in list

I have checked the code, and it seems that the value can be removed twice, as there is the same code in line 2550. There is a simple solution just checking if the value is still in the list, but as the code is quite complex, I do not know if this is a good idea.

For test purposes, the call is:

X = sp.Matrix(sp.MatrixSymbol('X', 6, 6))

variables = [sym for sym in X]

Riccati = sp.Matrix([[-X[0, 0] + 1, -X[0, 1] + 1, -X[0, 2], -X[0, 3], -X[0, 4], -X[0, 5]], [-X[1, 0] + 1, -((X[2, 2] + 3)*X[0, 5]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[0, 2]*X[2, 5]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[5, 0] - ((X[5, 5] + 1)*X[0, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[0, 5]*X[5, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[2, 0] + X[0, 0] - X[1, 1] + 1, -((X[2, 2] + 3)*X[0, 5]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[0, 2]*X[2, 5]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[5, 1] - ((X[5, 5] + 1)*X[0, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[0, 5]*X[5, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[2, 1] + X[0, 1] - X[1, 2], -X[1, 3], -((X[2, 2] + 3)*X[0, 5]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[0, 2]*X[2, 5]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[5, 3] - ((X[5, 5] + 1)*X[0, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[0, 5]*X[5, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[2, 3] + X[0, 3] - X[1, 4], -((X[2, 2] + 3)*X[0, 5]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[0, 2]*X[2, 5]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[5, 4] - ((X[5, 5] + 1)*X[0, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[0, 5]*X[5, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[2, 4] + X[0, 4] - X[1, 5]], [-X[2, 0], -((X[2, 2] + 3)*X[1, 5]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[1, 2]*X[2, 5]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[5, 0] - ((X[5, 5] + 1)*X[1, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[1, 5]*X[5, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[2, 0] + X[1, 0] - X[2, 1], -((X[2, 2] + 3)*X[1, 5]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[1, 2]*X[2, 5]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[5, 1] - ((X[5, 5] + 1)*X[1, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[1, 5]*X[5, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[2, 1] + X[1, 1] - X[2, 2], -X[2, 3], -((X[2, 2] + 3)*X[1, 5]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[1, 2]*X[2, 5]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[5, 3] - ((X[5, 5] + 1)*X[1, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[1, 5]*X[5, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[2, 3] + X[1, 3] - X[2, 4], -((X[2, 2] + 3)*X[1, 5]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[1, 2]*X[2, 5]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[5, 4] - ((X[5, 5] + 1)*X[1, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[1, 5]*X[5, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[2, 4] + X[1, 4] - X[2, 5]], [-X[3, 0], -X[3, 1], -X[3, 2], -X[3, 3] + 1, -X[3, 4] - 1, -X[3, 5]], [-X[4, 0], -((X[2, 2] + 3)*X[3, 5]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[2, 5]*X[3, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[5, 0] - ((X[5, 5] + 1)*X[3, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[3, 5]*X[5, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[2, 0] + X[3, 0] - X[4, 1], -((X[2, 2] + 3)*X[3, 5]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[2, 5]*X[3, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[5, 1] - ((X[5, 5] + 1)*X[3, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[3, 5]*X[5, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[2, 1] + X[3, 1] - X[4, 2], -X[4, 3] - 1, -((X[2, 2] + 3)*X[3, 5]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[2, 5]*X[3, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[5, 3] - ((X[5, 5] + 1)*X[3, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[3, 5]*X[5, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[2, 3] + X[3, 3] - X[4, 4] + 1, -((X[2, 2] + 3)*X[3, 5]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[2, 5]*X[3, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[5, 4] - ((X[5, 5] + 1)*X[3, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[3, 5]*X[5, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[2, 4] + X[3, 4] - X[4, 5]], [-X[5, 0], -((X[2, 2] + 3)*X[4, 5]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[2, 5]*X[4, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[5, 0] - ((X[5, 5] + 1)*X[4, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[4, 5]*X[5, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[2, 0] + X[4, 0] - X[5, 1], -((X[2, 2] + 3)*X[4, 5]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[2, 5]*X[4, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[5, 1] - ((X[5, 5] + 1)*X[4, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[4, 5]*X[5, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[2, 1] + X[4, 1] - X[5, 2], -X[5, 3], -((X[2, 2] + 3)*X[4, 5]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[2, 5]*X[4, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[5, 3] - ((X[5, 5] + 1)*X[4, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[4, 5]*X[5, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[2, 3] + X[4, 3] - X[5, 4], -((X[2, 2] + 3)*X[4, 5]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[2, 5]*X[4, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[5, 4] - ((X[5, 5] + 1)*X[4, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]) - X[4, 5]*X[5, 2]/((X[2, 2] + 3)*(X[5, 5] + 1) - X[2, 5]*X[5, 2]))*X[2, 4] + X[4, 4] - X[5, 5]]])

results = sp.nonlinsolve(Riccati, variables)

Thanks in advance,

Jose M.

@jmgc
Copy link
Contributor Author

jmgc commented Oct 23, 2018

I have debugged the code with the previous code. I have found that at some point, the value of res is:

res = {}

while result is:

result = <class 'list'>: [{_X35: 1/2 + sqrt(5)/2}, {_X35: -sqrt(5)/2 + 1/2}]

As a result, res cannot be removed from result. I have also verified that the code in line 2550 is not reached.

@smichr
Copy link
Member

smichr commented Oct 25, 2018

I think the following could be changed to if delete_res and res:

if delete_res:

The case of no res is already guarded with an if res in the preceding instance of result.remove(res).

Note: this is now at line 3048 (see this SO).

@jmgc
Copy link
Contributor Author

jmgc commented Oct 25, 2018

I have made some more checks, and it seems that the problem is that res contains an empty dictionary (res = {}), and result does not contain an element with an empty dictionary. Therefore, res cannot be removed from result.

The easy solution would be to include an if delete_res and res in result:. However, my concern is that the absence of an empty dictionary inside results could be a simptom of the real bug. For this reason, I think it would be better to have the point of view of the person/s that wrote the function.

@jmgc
Copy link
Contributor Author

jmgc commented Nov 6, 2020

The present issue seems to be a symptom of an interesting problem:

I have been digging in this issue on commit ae883bf. I have applied the proposed solution:

if delete_res and res in result:

to line 3178 of solveset.

I have found a new issue on the degree function of polytools.py, as it did not take into account the -oo case. I have modified the return statement:

    result = p.degree(gen)
    return Integer(result) if result is int else result

I have found a new issue on Add. For some reason solve set generates the following value:

a = sp.Add(sp.Integer(1), sp.S.Complexes)

It gives the error:

AttributeError: 'Complexes' object has no attribute 'as_coeff_Mul'

Any ideas to make solveset work on the present case?

@jmgc
Copy link
Contributor Author

jmgc commented Nov 6, 2020

It seems the possibility of making and Add with non-expressions has been deprecated (see #19445) but it is still alive in solveset.

@oscarbenjamin
Copy link
Contributor

Where exactly does that happen in solveset?

@jmgc
Copy link
Contributor Author

jmgc commented Nov 6, 2020

I do not know exactly, but using it with the Riccati expression generates this Add case. So at some point it is being generated.

@oscarbenjamin
Copy link
Contributor

Can you show the full traceback?

@jmgc
Copy link
Contributor Author

jmgc commented Nov 6, 2020

The traceback:

def test_issue_15422():
        from sympy import nonlinsolve, MatrixSymbol
        X = Matrix(MatrixSymbol('X', 6, 6))
    
        variables = [sym for sym in X]
    
        Riccati = Matrix([[-X[0, 0] + 1, -X[0, 1] + 1, -X[0, 2], -X[0, 3], -X[0, 4], -X[0, 5]], [-X[1, 0] + 1, -(
                (X[2, 2] + 3) * X[0, 5] / ((X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[0, 2] * X[2, 5] / (
                    (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2])) * X[5, 0] - ((X[5, 5] + 1) * X[0, 2] / (
                (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[0, 5] * X[5, 2] / ((X[2, 2] + 3) * (X[5, 5] + 1) - X[
            2, 5] * X[5, 2])) * X[2, 0] + X[0, 0] - X[1, 1] + 1, -(
                (X[2, 2] + 3) * X[0, 5] / ((X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[0, 2] * X[2, 5] / (
                    (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2])) * X[5, 1] - ((X[5, 5] + 1) * X[0, 2] / (
                (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[0, 5] * X[5, 2] / ((X[2, 2] + 3) * (X[5, 5] + 1) - X[
            2, 5] * X[5, 2])) * X[2, 1] + X[0, 1] - X[1, 2], -X[1, 3], -(
                (X[2, 2] + 3) * X[0, 5] / ((X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[0, 2] * X[2, 5] / (
                    (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2])) * X[5, 3] - ((X[5, 5] + 1) * X[0, 2] / (
                (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[0, 5] * X[5, 2] / ((X[2, 2] + 3) * (X[5, 5] + 1) - X[
            2, 5] * X[5, 2])) * X[2, 3] + X[0, 3] - X[1, 4], -(
                (X[2, 2] + 3) * X[0, 5] / ((X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[0, 2] * X[2, 5] / (
                    (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2])) * X[5, 4] - ((X[5, 5] + 1) * X[0, 2] / (
                (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[0, 5] * X[5, 2] / ((X[2, 2] + 3) * (X[5, 5] + 1) - X[
            2, 5] * X[5, 2])) * X[2, 4] + X[0, 4] - X[1, 5]], [-X[2, 0], -(
                (X[2, 2] + 3) * X[1, 5] / ((X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[1, 2] * X[2, 5] / (
                    (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2])) * X[5, 0] - ((X[5, 5] + 1) * X[1, 2] / (
                (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[1, 5] * X[5, 2] / ((X[2, 2] + 3) * (X[5, 5] + 1) - X[
            2, 5] * X[5, 2])) * X[2, 0] + X[1, 0] - X[2, 1], -(
                (X[2, 2] + 3) * X[1, 5] / ((X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[1, 2] * X[2, 5] / (
                    (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2])) * X[5, 1] - ((X[5, 5] + 1) * X[1, 2] / (
                (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[1, 5] * X[5, 2] / ((X[2, 2] + 3) * (X[5, 5] + 1) - X[
            2, 5] * X[5, 2])) * X[2, 1] + X[1, 1] - X[2, 2], -X[2, 3], -(
                (X[2, 2] + 3) * X[1, 5] / ((X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[1, 2] * X[2, 5] / (
                    (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2])) * X[5, 3] - ((X[5, 5] + 1) * X[1, 2] / (
                (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[1, 5] * X[5, 2] / ((X[2, 2] + 3) * (X[5, 5] + 1) - X[
            2, 5] * X[5, 2])) * X[2, 3] + X[1, 3] - X[2, 4], -(
                (X[2, 2] + 3) * X[1, 5] / ((X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[1, 2] * X[2, 5] / (
                    (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2])) * X[5, 4] - ((X[5, 5] + 1) * X[1, 2] / (
                (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[1, 5] * X[5, 2] / ((X[2, 2] + 3) * (X[5, 5] + 1) - X[
            2, 5] * X[5, 2])) * X[2, 4] + X[1, 4] - X[2, 5]],
                             [-X[3, 0], -X[3, 1], -X[3, 2], -X[3, 3] + 1, -X[3, 4] - 1, -X[3, 5]], [-X[4, 0], -(
                    (X[2, 2] + 3) * X[3, 5] / ((X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[2, 5] * X[3, 2] / (
                        (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2])) * X[5, 0] - ((X[5, 5] + 1) * X[3, 2] / (
                    (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[3, 5] * X[5, 2] / ((X[2, 2] + 3) * (
                    X[5, 5] + 1) - X[2, 5] * X[5, 2])) * X[2, 0] + X[3, 0] - X[4, 1], -(
                    (X[2, 2] + 3) * X[3, 5] / ((X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[2, 5] * X[3, 2] / (
                        (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2])) * X[5, 1] - ((X[5, 5] + 1) * X[3, 2] / (
                    (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[3, 5] * X[5, 2] / ((X[2, 2] + 3) * (
                    X[5, 5] + 1) - X[2, 5] * X[5, 2])) * X[2, 1] + X[3, 1] - X[4, 2], -X[4, 3] - 1, -(
                    (X[2, 2] + 3) * X[3, 5] / ((X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[2, 5] * X[3, 2] / (
                        (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2])) * X[5, 3] - ((X[5, 5] + 1) * X[3, 2] / (
                    (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[3, 5] * X[5, 2] / ((X[2, 2] + 3) * (
                    X[5, 5] + 1) - X[2, 5] * X[5, 2])) * X[2, 3] + X[3, 3] - X[4, 4] + 1, -(
                    (X[2, 2] + 3) * X[3, 5] / ((X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[2, 5] * X[3, 2] / (
                        (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2])) * X[5, 4] - ((X[5, 5] + 1) * X[3, 2] / (
                    (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[3, 5] * X[5, 2] / ((X[2, 2] + 3) * (
                    X[5, 5] + 1) - X[2, 5] * X[5, 2])) * X[2, 4] + X[3, 4] - X[4, 5]], [-X[5, 0], -(
                    (X[2, 2] + 3) * X[4, 5] / ((X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[2, 5] * X[4, 2] / (
                        (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2])) * X[5, 0] - ((X[5, 5] + 1) * X[4, 2] / (
                    (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[4, 5] * X[5, 2] / ((X[2, 2] + 3) * (
                    X[5, 5] + 1) - X[2, 5] * X[5, 2])) * X[2, 0] + X[4, 0] - X[5, 1], -(
                    (X[2, 2] + 3) * X[4, 5] / ((X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[2, 5] * X[4, 2] / (
                        (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2])) * X[5, 1] - ((X[5, 5] + 1) * X[4, 2] / (
                    (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[4, 5] * X[5, 2] / ((X[2, 2] + 3) * (
                    X[5, 5] + 1) - X[2, 5] * X[5, 2])) * X[2, 1] + X[4, 1] - X[5, 2], -X[5, 3], -(
                    (X[2, 2] + 3) * X[4, 5] / ((X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[2, 5] * X[4, 2] / (
                        (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2])) * X[5, 3] - ((X[5, 5] + 1) * X[4, 2] / (
                    (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[4, 5] * X[5, 2] / ((X[2, 2] + 3) * (
                    X[5, 5] + 1) - X[2, 5] * X[5, 2])) * X[2, 3] + X[4, 3] - X[5, 4], -(
                    (X[2, 2] + 3) * X[4, 5] / ((X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[2, 5] * X[4, 2] / (
                        (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2])) * X[5, 4] - ((X[5, 5] + 1) * X[4, 2] / (
                    (X[2, 2] + 3) * (X[5, 5] + 1) - X[2, 5] * X[5, 2]) - X[4, 5] * X[5, 2] / ((X[2, 2] + 3) * (
                    X[5, 5] + 1) - X[2, 5] * X[5, 2])) * X[2, 4] + X[4, 4] - X[5, 5]]])
    
>       results = nonlinsolve(Riccati, variables)

test_solveset.py:2590: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../solveset.py:3492: in nonlinsolve
    soln = nonlinsolve(system, symbols)
../solveset.py:3517: in nonlinsolve
    res = _handle_positive_dimensional(polys, symbols, denominators)
../solveset.py:3264: in _handle_positive_dimensional
    result = substitution(
../solveset.py:3191: in substitution
    new_result_real, solve_call1, cnd_call1 = _solve_using_known_values(
../solveset.py:3175: in _solve_using_known_values
    newresult, delete_res = _append_new_soln(
../solveset.py:2995: in _append_new_soln
    satisfy_exclude = _check_exclude(rnew, imgset_yes)
../solveset.py:2956: in _check_exclude
    satisfy_exclude = any(
../solveset.py:2957: in <genexpr>
    checksol(d, rnew_) for d in exclude)
../solvers.py:307: in checksol
    _, val = val.as_content_primitive()
../../core/add.py:1047: in as_content_primitive
    con, prim = self.func(*[_keep_coeff(*a.as_content_primitive(
../../core/add.py:1047: in <listcomp>
    con, prim = self.func(*[_keep_coeff(*a.as_content_primitive(
../../core/mul.py:1879: in as_content_primitive
    c, p = a.as_content_primitive(radical=radical, clear=clear)
../../core/add.py:1047: in as_content_primitive
    con, prim = self.func(*[_keep_coeff(*a.as_content_primitive(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <[AttributeError("'Complexes' object has no attribute 'as_coeff_Mul'") raised in repr()] Add object at 0x14b445a90>

    def primitive(self):
        """
        Return ``(R, self/R)`` where ``R``` is the Rational GCD of ``self```.
    
        ``R`` is collected only from the leading coefficient of each term.
    
        Examples
        ========
    
        >>> from sympy.abc import x, y
    
        >>> (2*x + 4*y).primitive()
        (2, x + 2*y)
    
        >>> (2*x/3 + 4*y/9).primitive()
        (2/9, 3*x + 2*y)
    
        >>> (2*x/3 + 4.2*y).primitive()
        (1/3, 2*x + 12.6*y)
    
        No subprocessing of term factors is performed:
    
        >>> ((2 + 2*x)*x + 2).primitive()
        (1, x*(2*x + 2) + 2)
    
        Recursive processing can be done with the ``as_content_primitive()``
        method:
    
        >>> ((2 + 2*x)*x + 2).as_content_primitive()
        (2, x*(x + 1) + 1)
    
        See also: primitive() function in polytools.py
    
        """
    
        terms = []
        inf = False
        for a in self.args:
>           c, m = a.as_coeff_Mul()
E           AttributeError: 'Complexes' object has no attribute 'as_coeff_Mul'

../../core/add.py:985: AttributeError```

@oscarbenjamin
Copy link
Contributor

I can't reproduce that traceback.

@jmgc
Copy link
Contributor Author

jmgc commented Nov 6, 2020

You have to make the modifications indicated previously on solveset.py and polytools.py.

@oscarbenjamin
Copy link
Contributor

The line here replaces a symbol with a set:

rnew[k] = v.subs(sym, sol)

@smichr
Copy link
Member

smichr commented Aug 31, 2021

The line here replaces a symbol with a set:

The Set Interval.open(-oo, -1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants