Skip to content

Commit 1cc0125

Browse files
author
grigory
committed
Add small improvements
1 parent f857a34 commit 1cc0125

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ for snr in snr_range:
4343
for _ in range(messages):
4444
msg = generate_binary_message(size=K)
4545
encoded = codec.encode(msg)
46-
transmitted = bpsk.transmit(message=msg, snr_db=snr)
46+
transmitted = bpsk.transmit(message=encoded, snr_db=snr)
4747
decoded = codec.decode(transmitted)
4848

4949
bit_errors, frame_error = compute_fails(msg, decoded)

python_polar_coding/polar_codes/fast_ssc/decoder.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ class FastSSCDecoder(SCDecoder):
1010
"""Implements Fast SSC decoding algorithm."""
1111
node_class = FastSSCNode
1212

13-
def __init__(self, n: int,
14-
mask: np.array,
15-
is_systematic: bool = True,
16-
code_min_size: int = 0):
13+
def __init__(
14+
self,
15+
n: int,
16+
mask: np.array,
17+
is_systematic: bool = True,
18+
code_min_size: int = 0,
19+
):
1720
super().__init__(n=n, mask=mask, is_systematic=is_systematic)
1821
self._decoding_tree = self.node_class(
1922
mask=self.mask,

python_polar_coding/polar_codes/fast_ssc/node.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ def __init__(self, mask, name=ROOT, N_min=None, **kwargs):
4040
self.is_computed = False
4141
self._build_decoding_tree()
4242

43+
def __str__(self):
44+
return ''.join([str(m) for m in self._mask])
45+
4346
@property
4447
def N(self):
4548
return self._mask.size
@@ -135,10 +138,10 @@ def get_node_type(self):
135138
return FastSSCNode.ZERO_NODE
136139
if self._check_is_one(self._mask) and self.N >= self.one_min_size:
137140
return FastSSCNode.ONE_NODE
138-
if self.N >= self.spc_min_size and self._check_is_spc(self._mask):
139-
return FastSSCNode.SINGLE_PARITY_CHECK
140141
if self.N >= self.repetition_min_size and self._check_is_parity(self._mask): # noqa
141142
return FastSSCNode.REPETITION
143+
if self.N >= self.spc_min_size and self._check_is_spc(self._mask):
144+
return FastSSCNode.SINGLE_PARITY_CHECK
142145
return FastSSCNode.OTHER
143146

144147
def _check_is_one(self, mask):

python_polar_coding/polar_codes/g_fast_ssc/node.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ def get_node_type(self):
2727
ntype = super().get_node_type()
2828
if ntype != self.OTHER:
2929
return ntype
30-
if self._check_is_g_repetition():
30+
if self._check_is_g_repetition(self._mask):
3131
return self.G_REPETITION
32-
if self._check_is_rg_parity():
32+
if self._check_is_rg_parity(self._mask):
3333
return self.RG_PARITY
3434
return self.OTHER
3535

@@ -46,15 +46,15 @@ def _build_decoding_tree(self):
4646
cls(mask=left_mask, name=self.LEFT, N_min=self.M, parent=self, AF=self.AF)
4747
cls(mask=right_mask, name=self.RIGHT, N_min=self.M, parent=self, AF=self.AF)
4848

49-
def _check_is_g_repetition(self):
49+
def _check_is_g_repetition(self, mask):
5050
"""Check the node is Generalized Repetition node.
5151
5252
Based on: https://arxiv.org/pdf/1804.09508.pdf, Section III, A.
5353
5454
"""
5555
# 1. Split mask into T chunks, T in range [2, 4, ..., N/2]
5656
for t in splits(self.MIN_CHUNKS, self.N // 2):
57-
chunks = np.split(self._mask, t)
57+
chunks = np.split(mask, t)
5858

5959
last = chunks[-1]
6060
last_ok = (
@@ -74,15 +74,15 @@ def _check_is_g_repetition(self):
7474

7575
return False
7676

77-
def _check_is_rg_parity(self):
77+
def _check_is_rg_parity(self, mask):
7878
"""Check the node is Relaxed Generalized Parity Check node.
7979
8080
Based on: https://arxiv.org/pdf/1804.09508.pdf, Section III, B.
8181
8282
"""
8383
# 1. Split mask into T chunks, T in range [2, 4, ..., N/2]
8484
for t in splits(self.MIN_CHUNKS, self.N // 2):
85-
chunks = np.split(self._mask, t)
85+
chunks = np.split(mask, t)
8686

8787
first = chunks[0]
8888
if not self._check_is_zero(first):

0 commit comments

Comments
 (0)