FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ModulationPy/tests.py at master · Judithcodes/ModulationPy · GitHub
Judithcodes
/
ModulationPy
Public
forked from
kirlf/ModulationPy
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
ModulationPy
/
tests.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
69 lines (50 loc) · 2.71 KB
Breadcrumbs
ModulationPy
/
tests.py
Copy path
File metadata and controls
69 lines (50 loc) · 2.71 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import
unittest
import
numpy
as
np
from
ModulationPy
.
ModulationPy
import
QAMModem
,
PSKModem
class
TestThing
(
unittest
.
TestCase
):
def
test_QAMModem
(
self
):
""" QAM modem modulation and demodulation tests"""
Ms
=
[
4
,
16
,
64
]
# modulation orders
for
M
in
Ms
:
print
(
"Modulation order: "
+
str
(
M
))
# Hard decision, Gray mapping, binary IO
mlpr
=
int
(
np
.
log2
(
M
))
#multiplier
size
=
mlpr
*
int
(
1e4
)
msg
=
np
.
random
.
randint
(
2
,
size
=
size
)
Modem
=
QAMModem
(
M
,
gray_map
=
True
,
bin_input
=
True
,
soft_decision
=
False
,
bin_output
=
True
)
np
.
testing
.
assert_array_equal
(
msg
,
Modem
.
demodulate
(
Modem
.
modulate
(
msg
)))
# Hard decision, binary mapping, binary IO
Modem
=
QAMModem
(
M
,
gray_map
=
False
,
bin_input
=
True
,
soft_decision
=
False
,
bin_output
=
True
)
np
.
testing
.
assert_array_equal
(
msg
,
Modem
.
demodulate
(
Modem
.
modulate
(
msg
)))
# Hard decision, Gray mapping, non-binary IO
size
=
int
(
1e5
)
msg
=
np
.
random
.
randint
(
2
,
size
=
size
)
Modem
=
QAMModem
(
M
,
gray_map
=
True
,
bin_input
=
False
,
soft_decision
=
False
,
bin_output
=
False
)
np
.
testing
.
assert_array_equal
(
msg
,
Modem
.
demodulate
(
Modem
.
modulate
(
msg
)))
# Hard decision, binary mapping, non-binary IO
Modem
=
QAMModem
(
M
,
gray_map
=
False
,
bin_input
=
False
,
soft_decision
=
False
,
bin_output
=
False
)
np
.
testing
.
assert_array_equal
(
msg
,
Modem
.
demodulate
(
Modem
.
modulate
(
msg
)))
def
test_PSKModem
(
self
):
""" PSK modem modulation and demodulation tests"""
Ms
=
[
2
,
4
,
8
,
16
,
32
]
# modulation order
for
M
in
Ms
:
print
(
"Modulation order: "
+
str
(
M
))
# Hard decision, Gray mapping, binary IO
mlpr
=
int
(
np
.
log2
(
M
))
#multiplier
size
=
mlpr
*
int
(
1e4
)
msg
=
np
.
random
.
randint
(
2
,
size
=
size
)
Modem
=
PSKModem
(
M
,
gray_map
=
True
,
bin_input
=
True
,
soft_decision
=
False
,
bin_output
=
True
)
np
.
testing
.
assert_array_equal
(
msg
,
Modem
.
demodulate
(
Modem
.
modulate
(
msg
)))
# Hard decision, binary mapping, binary IO
Modem
=
PSKModem
(
M
,
gray_map
=
False
,
bin_input
=
True
,
soft_decision
=
False
,
bin_output
=
True
)
np
.
testing
.
assert_array_equal
(
msg
,
Modem
.
demodulate
(
Modem
.
modulate
(
msg
)))
# Hard decision, Gray mapping, non-binary IO
size
=
int
(
1e5
)
msg
=
np
.
random
.
randint
(
2
,
size
=
size
)
Modem
=
PSKModem
(
M
,
gray_map
=
True
,
bin_input
=
False
,
soft_decision
=
False
,
bin_output
=
False
)
np
.
testing
.
assert_array_equal
(
msg
,
Modem
.
demodulate
(
Modem
.
modulate
(
msg
)))
# Hard decision, binary mapping, non-binary IO
Modem
=
PSKModem
(
M
,
gray_map
=
False
,
bin_input
=
False
,
soft_decision
=
False
,
bin_output
=
False
)
np
.
testing
.
assert_array_equal
(
msg
,
Modem
.
demodulate
(
Modem
.
modulate
(
msg
)))
if
__name__
==
'__main__'
:
unittest
.
main
()
Back
|
FazBrowse Home
|
New Git URL