Python 3 syntax error on filter(lambda (x, y): )
cclauss opened this issue · comments
At least one Python 3 syntax error remains...
./tools/benchmark/make_plots.py:36:43: E999 SyntaxError: invalid syntax
filt_with_indices = filter(lambda (index, value): keep_indices[index], enumerate(value))
^
Is there a test case around this code?
A simple fix would be to remove the parens around (index, value) but that works sometimes and not others so a strong test case is needed. In general, modern Python used list comprehensions instead of filter() and map() especially when used with lambdas.
https://docs.python.org/3/whatsnew/3.0.html#views-and-iterators-instead-of-lists
A simple fix would be to remove the parens around (index, value) but that works sometimes and not others
This won't work certainly because the argument of lambda is a tuple which is deconstructed here. This is no longer possible in Python 3; I suppose the easiest solution is to say lambda x: keep_indices[x[0]], enumerate(x[1])
.
There are no tests for any of this code, this is just a set of data collection scripts for bench testing.
I will rework it as a list comprehension.
Fixed by removal in #41