Simulator now returns correct length BERs list no matter the simulation state

This commit is contained in:
Andreas Tsouchlos 2022-11-16 19:42:04 +01:00
parent e27a86969e
commit dd485dfee0

View File

@ -221,7 +221,18 @@ class Simulator:
[BER_decoder_1, BER_decoder_2, ...] [BER_decoder_1, BER_decoder_2, ...]
""" """
SNRs = np.array(self._SNRs) 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 return SNRs, BERs