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 10a144a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion python/demod.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ 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)
with np.errstate(divide='ignore'):
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 10a144a

Please sign in to comment.