@@ -123,16 +123,14 @@ def emitter_converter(size_par, data):
123
123
# Bit counter one for a given parity
124
124
cont_bo = 0
125
125
# counter to control the loop reading
126
- cont_loop = 0
127
- for x in data_ord :
126
+ for cont_loop , x in enumerate (data_ord ):
128
127
if x is not None :
129
128
try :
130
129
aux = (bin_pos [cont_loop ])[- 1 * (bp )]
131
130
except IndexError :
132
131
aux = "0"
133
132
if aux == "1" and x == "1" :
134
133
cont_bo += 1
135
- cont_loop += 1
136
134
parity .append (cont_bo % 2 )
137
135
138
136
qtd_bp += 1
@@ -164,21 +162,20 @@ def receptor_converter(size_par, data):
164
162
parity_received = []
165
163
data_output = []
166
164
167
- for x in range ( 1 , len ( data ) + 1 ):
165
+ for i , item in enumerate ( data , 1 ):
168
166
# Performs a template of bit positions - who should be given,
169
167
# and who should be parity
170
- if qtd_bp < size_par and (np .log (x ) / np .log (2 )).is_integer ():
168
+ if qtd_bp < size_par and (np .log (i ) / np .log (2 )).is_integer ():
171
169
data_out_gab .append ("P" )
172
170
qtd_bp = qtd_bp + 1
173
171
else :
174
172
data_out_gab .append ("D" )
175
173
176
174
# Sorts the data to the new output size
177
175
if data_out_gab [- 1 ] == "D" :
178
- data_output .append (data [ cont_data ] )
176
+ data_output .append (item )
179
177
else :
180
- parity_received .append (data [cont_data ])
181
- cont_data += 1
178
+ parity_received .append (item )
182
179
183
180
# -----------calculates the parity with the data
184
181
data_out = []
@@ -215,17 +212,14 @@ def receptor_converter(size_par, data):
215
212
for bp in range (1 , size_par + 1 ):
216
213
# Bit counter one for a certain parity
217
214
cont_bo = 0
218
- # Counter to control loop reading
219
- cont_loop = 0
220
- for x in data_ord :
215
+ for cont_loop , x in enumerate (data_ord ):
221
216
if x is not None :
222
217
try :
223
218
aux = (bin_pos [cont_loop ])[- 1 * (bp )]
224
219
except IndexError :
225
220
aux = "0"
226
221
if aux == "1" and x == "1" :
227
222
cont_bo += 1
228
- cont_loop += 1
229
223
parity .append (str (cont_bo % 2 ))
230
224
231
225
qtd_bp += 1
0 commit comments