From dd485dfee011713ccd00b8f9f7492e619d87dcb5 Mon Sep 17 00:00:00 2001 From: Andreas Tsouchlos Date: Wed, 16 Nov 2022 19:42:04 +0100 Subject: [PATCH] Simulator now returns correct length BERs list no matter the simulation state --- sw/utility/simulation.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sw/utility/simulation.py b/sw/utility/simulation.py index b0b7fe8..84cf7fb 100644 --- a/sw/utility/simulation.py +++ b/sw/utility/simulation.py @@ -221,7 +221,18 @@ class Simulator: [BER_decoder_1, BER_decoder_2, ...] """ SNRs = np.array(self._SNRs) - BERs = [np.array(BER_array) for BER_array in self._BERs] + + # If the BERs of a decoder have not been calculated for all SNRs, + # fill the rest up with zeros to match the length of the 'SNRs' array + BERs = [] + for decoder_BER_list in self._BERs: + padded = np.pad(decoder_BER_list, (0, len(self._SNRs) - len(decoder_BER_list))) + BERs.append(padded) + + # If the BERs have not been calculated for all decoders, fill up the BERs list + # with zero-vectors to match the length of the 'decoders' list + for i in range(len(self._decoders) - len(BERs)): + BERs.append(np.zeros(len(self._SNRs))) return SNRs, BERs