PX4 / sapog

Sapog - advanced multiplatform ESC firmware
https://kb.zubax.com/x/cYAh
BSD 3-Clause "New" or "Revised" License
204 stars 142 forks source link

Python 3 syntax error on filter(lambda (x, y): ) #38

Closed cclauss closed 5 years ago

cclauss commented 5 years ago

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

pavel-kirienko commented 5 years ago

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.

cclauss commented 5 years ago

I will rework it as a list comprehension.

pavel-kirienko commented 5 years ago

Fixed by removal in #41