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
grc: cpp generation fails to generate vector variable #4955
Comments
Just to clarify on what the expected behavior is, are we expecting the following line? std::vector<double> variable_0 = {1.0, 2.0, 3.0, 4.0}; I produced it using |
Yes , the expected behavior is to get std::vector input_vector = {0.0, 1.0, 2.0, 3}; variable_block1 vl with value 4 |
Ok. Assign that to me. Ill try to fix it. |
I believe the problem lies with import ast
ast.literal_eval("[float(x) for x in range(4)]") This problem would be fixed by replacing eval("[float(x) for x in range(4)]") This bug disappears once I replace # Determine the lvalue type
def get_type(element, _vtype):
evaluated = None
try:
evaluated = eval(element)
# ...
if _vtype == None:
_vtype = type(evaluated)
if self.vtype in ['bool', 'gr_complex'] or 'std::map' in self.vtype or 'std::vector' in self.vtype:
evaluated = eval(value)
# ... Not sure if its wise to change it though. |
On main, with this fg: https://gist.github.com/marcusmueller/c9741d435e8ec7aa5ba23db90a987334 we get a different error:
|
Define in grc a variable block with value
[float(x) for x in range(4)]
Python code will be generated but cpp code generation fails with:
That is why in in block.py
evaluated = ast.literal_eval(element) fails for
element = [float(x) for x in range(4)]
with ValueError: malformed node or string: <ast.ListComp object at 0x7fd8a0e92eb0>
The text was updated successfully, but these errors were encountered: