-
Notifications
You must be signed in to change notification settings - Fork 36
spektrum-scanner: fix plot_rssi.py script #49
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See inline question
spectrum-scanner/tools/plot_rssi.py
Outdated
@@ -65,7 +66,7 @@ def plot_rssi(self, port): | |||
tidx = int(timestamp / (self.dt * 1000000)) % (Z.shape[1]) | |||
except ValueError: | |||
continue | |||
logging.debug("data: tidx=%d if=%d t=%d", tidx, iface_id, timestamp) | |||
logging.debug("data: tidx={} if={} cnt={} t={}".format(tidx, iface_id, count, timestamp)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this change necessary?
The original statement avoids evaluating the format when logging is disabled, an insignificant performance difference here, but in other situations the impact can be noticeable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mhm, I read/heard that the {}
+ format()
notation is the more (?) pythonic way to do string formatting nowadays. And I added count
so its used, otherwise flake8 complains about an unused variable - though we could also completely omit that.
Also, you really think performance is (that) critical? I mean this python typically runs on standard desktop PCs, right?�
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like I wrote, it does not make any difference here, but in general, it would be undesirable to evaluate the format string at all if it is going to be discarded anyway because of loglevel < LOG_DEBUG. To reduce the developer confusion and to adhere to best practices, I would prefer to stay with the recommended style of pushing the variables as arguments instead of preformatting the message.
Some relevant articles:
https://reinout.vanrees.org/weblog/2015/06/05/logging-formatting.html
https://www.reddit.com/r/Python/comments/387oog/when_will_logging_use_newstyle_string_formatting/
https://realpython.com/python-logging/#logging-variable-data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mhm, I see ...
@gebart addressed comments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine, untested ACK
I tested 😉 |
Adapt python script to comply with python coding conventions, i.e. fixing error reported by flake8.
08a30fb
to
4998410
Compare
spektrum-scanner: fix plot_rssi.py script
Adapt python script to comply with python coding conventions, i.e.
fixing error reported by flake8.