Skip to content

Commit

Permalink
Use if/else not and/or to avoid dividing by zero.
Browse files Browse the repository at this point in the history
The and/or idiom doesn't work here because "x and 0" is always False,
so the or branch gets evaluated.

Fixes #8.
  • Loading branch information
mutability committed Dec 29, 2015
1 parent 0ae9bf1 commit 00c13b8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mlat/client/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def log_and_reset(self):
log('Receiver: {0:6.1f} msg/s received {1:6.1f} msg/s processed ({2:.0f}%)',
self.receiver_rx_messages / elapsed,
processed / elapsed,
(self.receiver_rx_messages == 0) and 0 or (100.0 * processed / self.receiver_rx_messages))
0 if self.receiver_rx_messages == 0 else 100.0 * processed / self.receiver_rx_messages)
log('Server: {0:6.1f} kB/s from server {1:4.1f}kB/s TCP to server {2:6.1f}kB/s UDP to server',
self.server_rx_bytes / elapsed / 1000.0,
self.server_tx_bytes / elapsed / 1000.0,
Expand Down

0 comments on commit 00c13b8

Please sign in to comment.