Skip to content

remove some unused function and some formatting cleanup#1045

Merged
happycube merged 1 commit into
happycube:mainfrom
oyvindln:cleanup
Jun 13, 2026
Merged

remove some unused function and some formatting cleanup#1045
happycube merged 1 commit into
happycube:mainfrom
oyvindln:cleanup

Conversation

@oyvindln

@oyvindln oyvindln commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Checklist

  • I have searched the open pull requests to confirm this change has not already been submitted.
  • My branch is up to date with the target branch.
  • I have tested my changes and all existing tests pass.
  • I have updated documentation where necessary.
  • My code follows the project's coding standards (see CONTRIBUTING.md).

Description

Remove some unused functions and imports and clean up some formatting

Comment thread lddecode/utils.py
# standard numeric/scientific libraries
import numpy as np
import scipy.signal as sps
from scipy.special import i0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be needed if the sinc lut ever needs to be regenerated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might make sense to move it to where the sinc lut functions are since it's tied to those

Comment thread lddecode/utils.py
Comment on lines +76 to +124
# kaiser_beta = 5
sinc_tap_count = 16 # must be multiple of 2
sinc_phase_count = 2**16

@njit
def sinc(x):
if x == 0.0:
return 1.0
x_pi = np.pi * x
return math.sin(x_pi) / x_pi
# @njit
# def sinc(x):
# if x == 0.0:
# return 1.0
# x_pi = np.pi * x
# return math.sin(x_pi) / x_pi


def kaiser_window(x, a, beta, i0_beta):
r = x / a
if r < -1.0 or r > 1.0:
return 0.0

t = math.sqrt(1.0 - r * r)
return i0(beta * t) / i0_beta
# def kaiser_window(x, a, beta, i0_beta):
# r = x / a
# if r < -1.0 or r > 1.0:
# return 0.0
#
# t = math.sqrt(1.0 - r * r)
# return i0(beta * t) / i0_beta


# https://ccrma.stanford.edu/~jos/sasp/Kaiser_Windows_Transforms.html
def build_kaiser_lut(beta, taps, phases):
a = taps // 2

offsets = np.arange(a - 1, -a - 1, -1)
offsets_len = len(offsets)

table = np.zeros((phases + 1, taps), dtype=np.float32)
weights = np.empty(offsets_len, dtype=np.float32)
i0_beta = i0(beta)

for i in range(phases):
phase = i / phases

s = 0.0
for j in range(offsets_len):
x = offsets[j] + phase
weight = sinc(x) * kaiser_window(x, a, beta, i0_beta)

weights[j] = weight
s += weight

table[i, :] = weights / s

# copy the last phase to avoid bounds checking later on when we do linear interpolation
table[phases] = table[phases - 1]

return table
# def build_kaiser_lut(beta, taps, phases):
# a = taps // 2
#
# offsets = np.arange(a - 1, -a - 1, -1)
# offsets_len = len(offsets)
#
# table = np.zeros((phases + 1, taps), dtype=np.float32)
# weights = np.empty(offsets_len, dtype=np.float32)
# i0_beta = i0(beta)
#
# for i in range(phases):
# phase = i / phases
#
# s = 0.0
# for j in range(offsets_len):
# x = offsets[j] + phase
# weight = sinc(x) * kaiser_window(x, a, beta, i0_beta)
#
# weights[j] = weight
# s += weight
#
# table[i, :] = weights / s
#
# # copy the last phase to avoid bounds checking later on when we do linear interpolation
# table[phases] = table[phases - 1]
#
# return table

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would make sense to move the sinc lut code into it's own file vs. commenting it out, so it has a better chance of surviving additional cleanup activities.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah wasn't sure how to best handle it

@happycube happycube merged commit da689f4 into happycube:main Jun 13, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants