Skip to content

Commit

Permalink
remove randomness when equally common modulations found
Browse files Browse the repository at this point in the history
  • Loading branch information
jopohl committed Nov 19, 2019
1 parent e7927be commit 30e7442
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/urh/ainterpretation/AutoInterpretation.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ def get_most_frequent_value(values: list):
return result


def most_common(values: list):
"""
Return the most common value in a list. In case of ties, return the value that appears first in list
:param values:
:return:
"""
counter = Counter(values)
return max(values, key=counter.get)


def detect_noise_level(magnitudes):
if len(magnitudes) <= 3:
return 0
Expand Down Expand Up @@ -189,7 +199,7 @@ def detect_modulation_for_messages(signal: IQArray, message_indices: list) -> st
if len(modulations_for_messages) == 0:
return None

return max(set(modulations_for_messages), key=modulations_for_messages.count)
return most_common(modulations_for_messages)


def detect_center(rectangular_signal: np.ndarray, max_size=None):
Expand Down

0 comments on commit 30e7442

Please sign in to comment.