From 74892a0ac946801d504651e5c5c362f6ad5f78cd Mon Sep 17 00:00:00 2001 From: Rob Speer Date: Fri, 29 Jul 2016 12:34:09 -0400 Subject: [PATCH] Make the almost-median deterministic when it rounds down to 0 --- wordfreq_builder/wordfreq_builder/word_counts.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wordfreq_builder/wordfreq_builder/word_counts.py b/wordfreq_builder/wordfreq_builder/word_counts.py index 7b94c8f..76f07cc 100644 --- a/wordfreq_builder/wordfreq_builder/word_counts.py +++ b/wordfreq_builder/wordfreq_builder/word_counts.py @@ -190,8 +190,9 @@ def merge_freqs(freq_dicts): missing_values += 1 if missing_values > 2: continue - - freqs.append(freq) + freqs.append(0.) + else: + freqs.append(freq) if freqs: median = statistics.median(freqs) @@ -208,7 +209,7 @@ def merge_freqs(freq_dicts): return merged -def write_wordlist(freqs, filename, cutoff=1e-9): +def write_wordlist(freqs, filename, cutoff=1e-8): """ Write a dictionary of either raw counts or frequencies to a file of comma-separated values.