Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python nested parenthesis function parameter list invalid syntax

Tags:

python-3.x

The code from the page chaotic attractor reconstruction. returns an error when running under Python 3.4.4 as follows:

SyntaxError: invalid syntax

at the 2nd opening parenthesis in the parameter part of the function:

def rossler_odes((x, y, z), (a, b, c)):
    return numpy.array([-y - z, x + a * y, b + z * (x - c)])

I am guessing this could be a Python version issue e.g. code created for version older than 3.4.4. I do not know Python but I wish to run this to learn the physics and of course the language.

like image 883
user250343 Avatar asked Dec 02 '25 22:12

user250343


1 Answers

Tuple parameter unpacking has been removed in Python 3, see PEP 3113, also What's new in Python 3.0. As suggested there, the easiest way to make your code Python 2/3 compatible is to use

def rossler_odes(x_y_z, a_b_c):
    x, y, z = x_y_z
    a, b, c = a_b_c
    return numpy.array([-y - z, x + a * y, b + z * (x - c)])
like image 88
stephan Avatar answered Dec 05 '25 19:12

stephan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!