Skip to content

Conversation

@syedzayyan
Copy link
Contributor

Checklist

  • I've formatted the new code by running uv run poe format before committing.
  • I've added tests for new code.
  • I've added docstrings for the new code.

Description

This is in reference to the issue #558 . I have created another helper function to calculate S and moved it out to utils instead. I have kept the eigen computation bits so that the tests don't fail.

Not sure if this is the preferred way. I did think of moving the S calculations to the _call_ function itself but it maybe required for other kernels in the future?

Issue Number: #558

Copy link
Owner

@thomaspinder thomaspinder left a comment

Choose a reason for hiding this comment

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

Just one suggested comment. A sign of our poor testing perhaps, but can you also just ensure that the graph kernel notebook runs identically to the current prod version?

In your revision, you may also bump the patch version in init.py.

return params[tuple_indices]


def calculate_S(kernel):
Copy link
Owner

Choose a reason for hiding this comment

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

Can we rename this function to something more informative and add types please?

return params[tuple_indices]


def calculate_S(kernel):
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
def calculate_S(kernel):
def calculate_heat_semigroup(kernel: GraphKernel) -> Float[Array, "N N"]:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried out having a GraphKernel type but that leads to circular import errors. A way to seperate out the calculate_heat_semigroup function in utils file would be to have a base Graph class and the GraphKernel inherit the base class. Then calculate_heat_semigroup could just check for the base type. I am not sure if that is necessary at this point or if many graph kernels actually use eigenvalues. Thus I put the calculate_heat_semigroup function in the graph file itself for now.

I checked the notebook as well and it seems all is fine.

Copy link
Owner

Choose a reason for hiding this comment

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

To bypass a circular import only for the needs of types, you can do

from __future__ import annotations
from import beartype.typing as tp

if tp.TYPE_CHECKING:
    from gpjax.kernels.non_euclidean.graph import GraphKernel

Overall this looks good. Can you please bump the version in gpjax/__init__.py?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're a genius! Worked like a charm. Function is back in utils and bumped init

@thomaspinder thomaspinder merged commit 587b1f7 into thomaspinder:main Oct 28, 2025
20 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.

2 participants