Skip to content
This repository was archived by the owner on Mar 25, 2024. It is now read-only.

Commit f89eb58

Browse files
committed
Comprehansive lists rule
1 parent 2c490b5 commit f89eb58

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

ModulationPy/ModulationPy.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,7 @@ def llr_preparation(self):
142142
ones[ind].append(code_book_demod[idx])
143143
return zeros, ones
144144

145-
146-
147-
'''
148-
149-
MODULATION ALGORITHMS
150-
'''
145+
''' MODULATION ALGORITHMS '''
151146

152147
def __bin_modulate(self, x):
153148

@@ -243,7 +238,7 @@ def __ApproxLLR(self, x, noise_var):
243238
METHODS TO EXECUTE
244239
'''
245240

246-
def modulate(self, x):
241+
def modulate(self, msg):
247242

248243
''' Modulates binary or decimal stream.
249244
Parameters
@@ -256,18 +251,18 @@ def modulate(self, x):
256251
Modulated symbols (signal envelope).
257252
'''
258253

259-
if (self.bin_input == True) and ((len(x) % int(np.log2(self.M))) != 0):
254+
if (self.bin_input == True) and ((len(msg) % int(np.log2(self.M))) != 0):
260255
raise ValueError("The length of the binary input should be a multiple of log2(M)")
261256

262-
if (self.bin_input == True) and ((max(x) > 1.) or (min(x) < 0.)):
257+
if (self.bin_input == True) and ((max(msg) > 1.) or (min(msg) < 0.)):
263258
raise ValueError("The input values should be 0s or 1s only!")
264-
if (self.bin_input == False) and ((max(x) > (self.M - 1)) or (min(x) < 0.)):
259+
if (self.bin_input == False) and ((max(msg) > (self.M - 1)) or (min(msg) < 0.)):
265260
raise ValueError("The input values should be in following range: [0, ... M-1]!")
266261

267262
if self.bin_input == True:
268-
modulated = self.__bin_modulate(x)
263+
modulated = self.__bin_modulate(msg)
269264
else:
270-
modulated = self.__dec_modulate(x)
265+
modulated = [self.code_book[dec] for dec in msg]
271266
return np.array(modulated)
272267

273268
def demodulate(self, x, noise_var=1.):

0 commit comments

Comments
 (0)