-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
Iterating over a generator-iterator from a Lua function #243
Comments
mfrigerio17
pushed a commit
to mfrigerio17/ctgen
that referenced
this issue
Sep 19, 2023
This is an attempt to simplify the workflow, by avoiding having python calling lua, calling python, calling lua, etc.. The motivation is also to work around this bug: scoder/lupa#243 With such purpose in mind, I now use Lua for the generation of the assignments of the matrix coefficients, rather than Python. This change breaks the existing code generation backends.
mfrigerio17
pushed a commit
to mfrigerio17/ctgen
that referenced
this issue
Oct 26, 2023
This is an attempt to simplify the workflow, by avoiding having python calling lua, calling python, calling lua, etc.. The motivation is also to work around this bug: scoder/lupa#243 With such purpose in mind, I now use Lua for the generation of the assignments of the matrix coefficients, rather than Python. This change breaks the existing code generation backends. Also, the code now requires the language-specifics to have an explicit function to turn a sympy expression into text. This is used instead of the naive call to Sympy's __str__, to give the backend more chances for customization. For example, powers in Sympy (Python) are written with '**', which is not a valid operator in other languages like C. Therefore, simply using __str__ would cause invalid code to be generated.
mfrigerio17
pushed a commit
to mfrigerio17/ctgen
that referenced
this issue
Apr 30, 2024
This is an attempt to simplify the workflow, by avoiding having python calling lua, calling python, calling lua, etc.. The motivation is also to work around this bug: scoder/lupa#243 With such purpose in mind, I now use Lua for the generation of the assignments of the matrix coefficients, rather than Python. This change breaks the existing code generation backends. Also, the code now requires the language-specifics to have an explicit function to turn a sympy expression into text. This is used instead of the naive call to Sympy's __str__, to give the backend more chances for customization. For example, powers in Sympy (Python) are written with '**', which is not a valid operator in other languages like C. Therefore, simply using __str__ would cause invalid code to be generated.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok, this seems convoluted and best illustrated with code that reproduces the problem (Ubuntu 22.04, Python 3.10.12, Lupa 2.0, Lua 5.4)
What the code does:
Output:
Expected output
When the generator is invoked from within a Lua function (using
python.iter
) thenself.table.key1
mysteriously become a tuple with three elements(<the generator itself>, None, <the actual value>)
even though it should just bevalue1
.Any idea?
The text was updated successfully, but these errors were encountered: