Skip to content

Commit

Permalink
Merge pull request #936 from gchq/fix/incorrect-gradient-periodic-ker…
Browse files Browse the repository at this point in the history
…nel-test

fix: correct sign of periodic kernel expected gradient
  • Loading branch information
gw265981 authored Jan 24, 2025
2 parents 8308711 + 7928834 commit 3630ddc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Pylint pre-commit hook is now configured as the Pylint docs recommend. (https://github.com/gchq/coreax/pull/899)
- Type annotations so that core coreax package passes Pyright. (https://github.com/gchq/coreax/pull/906)
- Type annotations so that the example scripts pass Pyright. (https://github.com/gchq/coreax/pull/921)
- Incorrectly-implemented tests for the gradients of `PeriodicKernel`. (https://github.com/gchq/coreax/pull/936)

### Changed

Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -1971,7 +1971,7 @@ def problem(self, request, kernel: PeriodicKernel) -> _Problem: # noqa: C901
)
return _Problem(x, y, expected_distances, modified_kernel)

def expected_grad_x(
def expected_grad_y(
self, x: ArrayLike, y: ArrayLike, kernel: PeriodicKernel
) -> np.ndarray:
x = np.atleast_2d(x)
Expand All @@ -1998,10 +1998,10 @@ def expected_grad_x(
)
return expected_gradients

def expected_grad_y(
def expected_grad_x(
self, x: ArrayLike, y: ArrayLike, kernel: PeriodicKernel
) -> np.ndarray:
return -self.expected_grad_x(x, y, kernel)
return -self.expected_grad_y(x, y, kernel)

def expected_divergence_x_grad_y(
self, x: ArrayLike, y: ArrayLike, kernel: PeriodicKernel
Expand Down

0 comments on commit 3630ddc

Please sign in to comment.