Skip to content

Commit dccd6e3

Browse files
committed
Correct some type errors and optimise links.py
1 parent 71f988b commit dccd6e3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

commpy/links.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def link_performance(link_model, SNRs, send_max, err_min, send_chunk=None, code_
5959
"""
6060

6161
# Initialization
62-
BERs = np.empty_like(SNRs, dtype=float)
62+
BERs = np.zeros_like(SNRs)
6363
# Set chunk size and round it to be a multiple of num_bits_symbol*nb_tx to avoid padding
6464
if send_chunk is None:
6565
send_chunk = err_min
@@ -83,7 +83,7 @@ def link_performance(link_model, SNRs, send_max, err_min, send_chunk=None, code_
8383
# Deals with MIMO channel
8484
if isinstance(link_model.channel, MIMOFlatChannel):
8585
nb_symb_vector = len(channel_output)
86-
received_msg = np.empty(int(math.ceil(len(msg) / link_model.rate)), int)
86+
received_msg = np.empty(int(math.ceil(len(msg) / link_model.rate)))
8787
for i in range(nb_symb_vector):
8888
received_msg[receive_size * i:receive_size * (i + 1)] = \
8989
link_model.receive(channel_output[i], link_model.channel.channel_gains[i],
@@ -101,6 +101,8 @@ def link_performance(link_model, SNRs, send_max, err_min, send_chunk=None, code_
101101
bit_err += (msg != link_model.decoder(received_msg)[:len(msg)]).sum()
102102
bit_send += send_chunk
103103
BERs[id_SNR] = bit_err / bit_send
104+
if bit_err < err_min:
105+
break
104106
return BERs
105107

106108

0 commit comments

Comments
 (0)