Skip to content

Add type hints and docstrings to util.py (#1141)#1213

Open
khushthecoder wants to merge 4 commits intomalariagen:masterfrom
khushthecoder:fix/issue-1141-util-docstrings
Open

Add type hints and docstrings to util.py (#1141)#1213
khushthecoder wants to merge 4 commits intomalariagen:masterfrom
khushthecoder:fix/issue-1141-util-docstrings

Conversation

@khushthecoder
Copy link
Contributor

Fixes #1141 — Type hints and docstrings for key utility functions in util.py

Summary

Adds PEP 484 type hints and comprehensive NumPy-style docstrings to 7 key internal utility functions in malariagen_data/util.py: _true_runs, _hash_params, _jitter, _value_error, _da_concat, _jackknife_ci, and _pdist_abs_hamming.


Key Changes

  • Documentation only: No runtime logic or behavioral changes were made
  • Typing added: Introduced proper standard library typing (e.g., Any, NoReturn, Sequence)
  • Numba safe: Carefully preserved existing @numba.njit decorators, using base np.ndarray annotations where strictly constrained external types would cause JIT compilation failures
  • Docstrings: All 7 functions now have numpydoc-compliant parameter, return type, and notes sections to clearly explain their implicit constraints (e.g. JSON-serializability requirements for hashing)

Add PEP 484 type hints and NumPy-style docstrings to seven internal
utility functions: _true_runs, _hash_params, _jitter, _value_error,
_da_concat, _jackknife_ci, and _pdist_abs_hamming.

- Use Union types where callers pass pd.Series (for _jitter) or plain
  lists (for _jackknife_ci) to avoid mypy and typeguard errors.
- Add typing imports: Any, NoReturn, Sequence.
- No behavioral changes; only annotations and docstrings.

Fixes malariagen#1141
@khushthecoder khushthecoder force-pushed the fix/issue-1141-util-docstrings branch from 8d0420d to 299830f Compare March 23, 2026 20:50
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.

Add type hints and comprehensive docstrings to utility functions in util.py

1 participant