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

Invalid C variables are possible #47

Closed
moorepants opened this issue May 24, 2017 · 1 comment
Closed

Invalid C variables are possible #47

moorepants opened this issue May 24, 2017 · 1 comment
Milestone

Comments

@moorepants
Copy link
Member

I used i as a state variable and opty creates ii and in in the C code. in is an invalid variable name in C, so the compilation fails. I think SymPy deals with this properly now with the CCode printers, but maybe this one slipped through.

(pendulum-robot) moorepants@garuda:cython_files$ python ufuncify_matrix_0_setup.py build_ext --inplace
Compiling ufuncify_matrix_0.pyx because it changed.
[1/1] Cythonizing ufuncify_matrix_0.pyx

Error compiling Cython file:
------------------------------------------------------------
...
    void eval_matrix(double matrix[3], double thetai,
                 double omegai,
                 double ii,
                 double thetan,
                 double omegan,
                 double in,
                       ^
------------------------------------------------------------

ufuncify_matrix_0.pyx:11:24: Expected ')', found 'in'
Traceback (most recent call last):
  File "ufuncify_matrix_0_setup.py", line 13, in <module>
    ext_modules=cythonize([extension]))
  File "/home/moorepants/miniconda3/envs/pendulum-robot/lib/python3.6/site-packages/Cython/Build/Dependencies.py", line 934, in cythonize
    cythonize_one(*args)
  File "/home/moorepants/miniconda3/envs/pendulum-robot/lib/python3.6/site-packages/Cython/Build/Dependencies.py", line 1056, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: ufuncify_matrix_0.pyx
@moorepants moorepants added this to the Version 1.3.0 milestone Jul 23, 2024
@moorepants
Copy link
Member Author

These are the reserved words we look for in SymPy:

reserved_words = [
    'auto', 'break', 'case', 'char', 'const', 'continue', 'default', 'do',
    'double', 'else', 'enum', 'extern', 'float', 'for', 'goto', 'if', 'int',
    'long', 'register', 'return', 'short', 'signed', 'sizeof', 'static',
    'struct', 'entry',  # never standardized, we'll leave it here anyway
    'switch', 'typedef', 'union', 'unsigned', 'void', 'volatile', 'while'
]

which does not include "in".

moorepants added a commit to moorepants/opty that referenced this issue Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant