Skip to content

Commit

Permalink
Switch partition code return arguments
Browse files Browse the repository at this point in the history
Fixes #45 which was caused by calling np.split with an uneven length array. Use np.split_array instead which meant to switch partition codes around
  • Loading branch information
cycomanic committed Feb 12, 2023
1 parent 6325ce6 commit 948910b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions qampy/core/equalisation/equalisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,10 @@ def generate_partition_codes_complex(M):
Returns
-------
parts : array_like
the boundaries between the different codes for parititioning
codes : array_like
the nearest symbol radius
parts : array_like
the boundaries between the different codes for parititioning
"""
syms = cal_symbols_qam(M)
scale = cal_scaling_factor_qam(M)
Expand All @@ -331,7 +331,7 @@ def generate_partition_codes_complex(M):
part_r = syms_r[:-1] + np.diff(syms_r)/2
part_i = syms_i[:-1] + np.diff(syms_i)/2
parts = part_r + 1.j*part_i
return np.hstack([parts, codes])
return np.hstack([codes, parts])

def generate_partition_codes_radius(M):
"""
Expand All @@ -344,17 +344,17 @@ def generate_partition_codes_radius(M):
Returns
-------
codes : array_like
the nearest symbol radius
parts : array_like
the boundaries between the different codes for parititioning
codes : array_like
the nearest symbol radius
"""
syms = cal_symbols_qam(M)
scale = cal_scaling_factor_qam(M)
syms /= np.sqrt(scale)
codes = np.unique(abs(syms)**4/abs(syms)**2)
parts = codes[:-1] + np.diff(codes)/2
return np.hstack([parts,codes])
return np.hstack([codes, parts])

def _cal_training_symbol_len(os, ntaps, L):
return int(L//os//ntaps-1)*int(ntaps)
Expand Down
4 changes: 2 additions & 2 deletions qampy/core/equalisation/pythran_equalisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,14 @@ def mcma_error(Xest, s1, i):
return dr*Xest.real + di*Xest.imag*J

def rde_error(Xest, symbs, i):
partition, codebook = np.split(symbs, 2)
codebook, partition = np.array_split(symbs, 2)
sq = abs(Xest)**2
r = partition_value(sq, partition.real, codebook.real)
return Xest*(r-sq)

def mrde_error(Xest, symbs, i):
J = Xest.dtype.type(1j)
partition, codebook = np.split(symbs, 2)
codebook, partition = np.array_split(symbs, 2)
sq = Xest.real**2 + J*Xest.imag**2
r = partition_value(sq.real, partition.real, codebook.real) + J * partition_value(sq.imag, partition.imag, codebook.imag)
return (r.real - sq.real)*Xest.real + J*(r.imag - sq.imag)*Xest.imag
Expand Down

0 comments on commit 948910b

Please sign in to comment.