Skip to content

Commit 66cd7fd

Browse files
authored
[DOC] Fix PSeAAC docstring errors and malformed error messages (#360)
#### Reference Issues/PRs Fixes previously unreported issues in the `pseaac` module. #### What does this implement/fix? Explain your changes. Four fixes: 1. `PSeAAC.transform()` docstring listed `lambda_val` and `weight` as parameters but the method only takes `protein_sequence`. Also had wrong default `0.15` vs actual `0.05`. Removed phantom params. 2. `AptaNetPSeAAC` docstring example imported `PSeAAC` instead of `AptaNetPSeAAC`. Fixed. 3. Missing space in f-string: `"divisible by" f"group_props"` → `"divisible bygroup_props"`. Added space. 4. Missing space: `"custom_groups`,not both."` → `", not both."`. #### What should a reviewer concentrate their feedback on? - Whether the `transform()` docstring is accurate after removing the phantom params #### Did you add any tests for the change? Yes. Added `test_pseaac_group_props_and_custom_groups_conflict` and `test_pseaac_indivisible_group_props` to `pyaptamer/pseaac/tests/test_pseaac.py`. #### Any other comments? - `pytest pyaptamer/pseaac/tests/test_pseaac.py` — 13 passed - `pre-commit run --all-files` — all passed #### PR checklist - [x] The PR title starts with either [ENH], [MNT], [DOC], or [BUG]. - [x] Added/modified tests - [x] Used pre-commit hooks when committing to ensure that code is compliant with hooks. Co-authored-by: kunal14901 <kunal14901@users.noreply.github.com>
1 parent c01f3fb commit 66cd7fd

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

pyaptamer/pseaac/_pseaac_aptanet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ class AptaNetPSeAAC:
8989
9090
Example
9191
-------
92-
>>> from pyaptamer.pseaac import PSeAAC
93-
>>> pseaac = PSeAAC()
92+
>>> from pyaptamer.pseaac import AptaNetPSeAAC
93+
>>> pseaac = AptaNetPSeAAC()
9494
>>> features = pseaac.transform("ACDEFGHIKLMNPQRHIKLMNPQRSTVWHIKLMNPQRSTVWY")
9595
>>> print(features[:10])
9696
[0.006 0.006 0.006 0.006 0.006 0.006 0.018 0.018 0.018 0.018]

pyaptamer/pseaac/_pseaac_general.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def __init__(
127127

128128
if group_props is not None and custom_groups is not None:
129129
raise ValueError(
130-
"Specify only one of `group_props` or `custom_groups`,not both."
130+
"Specify only one of `group_props` or `custom_groups`, not both."
131131
)
132132

133133
self.np_matrix = aa_props(
@@ -148,7 +148,7 @@ def __init__(
148148
else:
149149
if self._n_cols % group_props != 0:
150150
raise ValueError(
151-
f"Number of properties ({self._n_cols}) must be divisible by"
151+
f"Number of properties ({self._n_cols}) must be divisible by "
152152
f"group_props ({group_props})."
153153
)
154154
self.prop_groups = [
@@ -219,12 +219,6 @@ def transform(self, protein_sequence):
219219
protein_sequence : str
220220
The input protein sequence consisting of valid amino acid characters
221221
(A, C, D, E, F, G, H, I, K, L, M, N, P, Q, R, S, T, V, W, Y).
222-
lambda_val : int, default=30
223-
The maximum distance between residues considered in the sequence-order
224-
correlation (θ) calculations.
225-
weight : float, default=0.15
226-
The weight factor that balances the contribution of sequence-order
227-
correlation features relative to amino acid composition features.
228222
229223
Returns
230224
-------

pyaptamer/pseaac/tests/test_pseaac.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,15 @@ def test_pseaac_configurations(
125125
assert len(vec) == expected_len, (
126126
f"Expected vector length {expected_len}, but got {len(vec)}"
127127
)
128+
129+
130+
def test_pseaac_group_props_and_custom_groups_conflict():
131+
"""Both group_props and custom_groups cannot be specified at the same time."""
132+
with pytest.raises(ValueError, match="not both"):
133+
PSeAAC(group_props=3, custom_groups=[[0, 1, 2]])
134+
135+
136+
def test_pseaac_indivisible_group_props():
137+
"""Error message must be readable when group_props doesn't divide n_props."""
138+
with pytest.raises(ValueError, match="divisible by group_props"):
139+
PSeAAC(prop_indices=[0, 1, 2, 3, 4], group_props=3)

0 commit comments

Comments
 (0)