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

symbol names in QSD code generator are not sanitized #15

Closed
goerz opened this issue Dec 23, 2015 · 3 comments
Closed

symbol names in QSD code generator are not sanitized #15

goerz opened this issue Dec 23, 2015 · 3 comments
Assignees
Labels

Comments

@goerz
Copy link
Member

goerz commented Dec 23, 2015

In symbolic expressions, it is often desirable to use LaTeX strings as a symbol name, so that the symbols are rendered nicely in a notebook. For example,

k = symbols("\kappa", positive=True)

When such a symbol is defined and translated to QSD code, there is a resulting C++ line

double \kappa = 2;

which is not valid C++ code. All symbol names must be sanitized to contain only word characters (alphanumeric ASCII symbols and underscores)

@goerz goerz self-assigned this Dec 23, 2015
@goerz goerz added the bug label Dec 23, 2015
goerz added a commit that referenced this issue Dec 23, 2015
@goerz goerz closed this as completed in 70ab01b Dec 23, 2015
@goerz
Copy link
Member Author

goerz commented Dec 24, 2015

The problem is actually more fundamental: We need to ensure that in any expression, the sanitized names for any symbols are used.

@goerz goerz reopened this Dec 24, 2015
@goerz goerz closed this as completed in 1b963b1 Dec 24, 2015
@ntezak
Copy link
Contributor

ntezak commented Jan 28, 2016

Actually you can just leave out the backslashes everywhere. It still renders nicely.

@goerz
Copy link
Member Author

goerz commented Jan 28, 2016

True, but I frequently like to use more complex LaTeX code such as '\chi^{(1)}_0' for symbol names. In any case, the symbol names can be arbitrary unicode strings, while valid C++ variable names are only a subset of ASCII. So, we can't get around doing some sanitation while deriving variable names from symbol names.

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

No branches or pull requests

2 participants