Skip to content

Commit

Permalink
testing hamming kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
e-dorigatti committed Dec 20, 2024
1 parent 9b32536 commit 831a03e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/bofire/kernels/test_categorical.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import torch
from botorch.models.kernels.categorical import CategoricalKernel
from botorch.models.transforms.input import OneHotToNumeric

from bofire.kernels.categorical import HammingKernelWithOneHots


def test_hamming_with_one_hot():
k1 = CategoricalKernel()
k2 = HammingKernelWithOneHots()

xin_oh = torch.eye(3)
xin_cat = OneHotToNumeric(3, categorical_features={0: 3}).transform(xin_oh)

z1 = k1(xin_cat).to_dense()
z2 = k2(xin_oh).to_dense()

assert torch.allclose(z1, z2)

0 comments on commit 831a03e

Please sign in to comment.