Skip to content

Constants + Utils updates#36

Merged
vratins merged 1 commit into
mainfrom
dev_formatting
Mar 9, 2026
Merged

Constants + Utils updates#36
vratins merged 1 commit into
mainfrom
dev_formatting

Conversation

@vratins

@vratins vratins commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

Small PR that adds graph creation constants to constants.py and makes changes to utils.py to use those constants (as well slightly improving the tqdm logging utility function.

Also makes formatting changes to util plotting functions.

Copilot AI left a comment

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.

Pull request overview

This PR centralizes graph/feature hyperparameters into src/constants.py and updates utilities to consume those constants, while also improving tqdm-compatible logging and reformatting/clarifying plotting utilities.

Changes:

  • Add feature-dimension and cutoff constants (NUM_RBF, RBF_CUTOFF, NODE_FEATURE_DIM) to src/constants.py.
  • Update utils.rbf() defaults and expand docstrings; extend setup_logging_for_tqdm() with configurable level + optional file logging.
  • Reformat/clarify visualization utilities and adjust minor test docstrings/whitespace.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/constants.py Introduces centralized constants for RBF encoding and node features, plus normalizes edge-type literals.
src/utils.py Uses new constants for RBF defaults, expands logging helper functionality, and reformats plotting helpers/docstrings.
tests/test_utils.py Small docstring/whitespace cleanup in OT coupling tests.
Comments suppressed due to low confidence (2)

src/utils.py:279

  • mate_pos is documented and used as optional (you pass None from create_trajectory_gif and guard with if mate_pos is not None), but the type annotation is np.ndarray. Update the annotation to accept None to match actual usage and avoid type-checker errors.
    ax,
    protein_pos: np.ndarray,
    mate_pos: np.ndarray,
    water_pred: np.ndarray,

src/utils.py:284

  • xlim/ylim/zlim default to None but are annotated as tuple[float, float]. Adjust the annotations to be optional (e.g., tuple[float, float] | None) so the signature matches the defaults and intended calling pattern.
    title: str = "",
    xlim: tuple[float, float] = None,
    ylim: tuple[float, float] = None,
    zlim: tuple[float, float] = None,

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils.py
Comment on lines +28 to +31
def setup_logging_for_tqdm(
level: str = "INFO",
log_file: str | None = None,
):

Copilot AI Feb 26, 2026

Copy link

Choose a reason for hiding this comment

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

setup_logging_for_tqdm now has new behavior (configurable log level + optional file sink/dir creation) but there are no unit tests covering these paths. Since tests/test_utils.py already exercises other utilities, consider adding a small test that calls setup_logging_for_tqdm(level=..., log_file=tmp_path/...) and asserts it doesn’t raise and creates/writes the log file.

Copilot uses AI. Check for mistakes.
@DorisMai

Copy link
Copy Markdown
Collaborator

Util updates are primarily stylistic changes, so merging shouldn’t harm the main branch. My personal preference is that the visualization-related functions might be cleaner as a separate script. They are not part of the core model logic and have quite a lot of hard-coded args like color and marker size that might be subject to quite some changes in the future. But this is really just a minor/non-blocking comment.

Comment thread src/utils.py
level: Log level (DEBUG, INFO, WARNING, ERROR)
log_file: Optional path to log file for persistent logging
"""
from pathlib import Path

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

keep all imports together at the top. Running ruff format and/or ruff check --fix can help do this automatically.

Comment thread src/utils.py

def rbf(r: Tensor, num_gaussians: int = 16, cutoff: float = 8.0) -> Tensor:
"""Radial basis function encoding of distances using Bessel functions."""
def rbf(r: Tensor, num_gaussians: int = NUM_RBF, cutoff: float = RBF_CUTOFF) -> Tensor:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This really applies to the code above: keep your code organized and put constants at the top. Generally it should go imports, then constants, then methods, then classes. It just makes for easier reading.

@DorisMai DorisMai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Style changes (organizing import order) should hopefully be addressed after merging PR #39 and #45 where pre-commit hooks run to check and fix these things (address issue #27 ). Approving for now to address the current batch of PRs.

@vratins
vratins merged commit b6fc094 into main Mar 9, 2026
4 checks passed
@vratins vratins linked an issue Mar 10, 2026 that may be closed by this pull request
@vratins vratins mentioned this pull request Mar 16, 2026
@vratins
vratins deleted the dev_formatting branch March 19, 2026 15:43
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.

fix relative imports

4 participants