Skip to content

Commit

Permalink
Fix DivideByZero exception
Browse files Browse the repository at this point in the history
Use log(a/b) == log(a) - log(b) to avoid divide by zero.
  • Loading branch information
Chris Hiszpanski committed Mar 15, 2023
1 parent 5d0361d commit de3b0fc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion python/demod.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def work(self, input_items, output_items):
# bit being a 0 or 1. Confidence of 0 is equally likely 0 or 1.
# Positive confidence levels are more likely 1 and negative values
# are more likely 0.
self.bit_confidence = 10.0*np.log10(bit1_amps/bit0_amps)
self.bit_confidence = 10.0*(np.log10(bit1_amps)-np.log10(bit0_amps))

# Send PDU message to decoder
meta = pmt.to_pmt({
Expand Down

0 comments on commit de3b0fc

Please sign in to comment.