Describe the bug
In PositionalEncoding.forward(), the sequence length check uses assert instead of raising a proper exception. Assertions are stripped when Python is run with the -O (optimize) flag, meaning this validation silently disappears in production.
Relevant code:
pyaptamer/aptatrans/layers/_encoder.py, line 81
assert x.shape[1] <= self.max_len, (
f"Input sequence length {x.shape[1]} exceeds maximum length {self.max_len}."
)
Expected behavior
Use an explicit ValueError instead of assert:
if x.shape[1] > self.max_len:
raise ValueError(
f"Input sequence length {x.shape[1]} exceeds maximum length {self.max_len}."
)
This ensures the check always runs regardless of Python optimization flags.
Versions
0.1.0a1
Describe the bug
In
PositionalEncoding.forward(), the sequence length check usesassertinstead of raising a proper exception. Assertions are stripped when Python is run with the-O(optimize) flag, meaning this validation silently disappears in production.Relevant code:
pyaptamer/aptatrans/layers/_encoder.py, line 81Expected behavior
Use an explicit
ValueErrorinstead ofassert:This ensures the check always runs regardless of Python optimization flags.
Versions
0.1.0a1