You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the kernel computation is a dataclass that takes in the kernel as its argument.
@dataclassclassAbstractKernelComputation:
r"""Abstract class for kernel computations."""kernel: "gpjax.kernels.base.AbstractKernel"# noqa: F821
This means when defining the compute_engine of a kernel, we cannot initialise the Computation before initialising the kernel, so have to pass an uninitialised class through compute_engine = DenseKernelComputation :
The refactoring proposed by @daniel-dodd is easily implemented (PR coming soon), however it would be even nicer at some point to also avoid problems with circular imports. If we want to have correct typing annotations in gpjax.kernels.computations submodules, we would have to import kernels classes, e.g. AbstractKernel, which creates a circular dependency since compute_engine is part of a kernel.
This would not be a problem when using the typing.TYPE_CHECKING block. It would work for static type checkers, but not for runtime type checking with beartype for some reason I don't fully understand yet. Solutions might include selectively disabling runtime checking or a relatively large refactoring.
Currently:
Currently the kernel computation is a dataclass that takes in the kernel as its argument.
This means when defining the
compute_engine
of a kernel, we cannot initialise the Computation before initialising the kernel, so have to pass an uninitialised class throughcompute_engine = DenseKernelComputation
:Proposal:
kernel
argument on theAbstractKernelComputation
so that the class can be initialised independently of the kernel.kernel
pytree, through thegram
,cross_covariance
methods ofAbstractKernelComputation
.DenseKernelComputation()
instead ofDenseKernelComputation
to thecompute_engine
.The text was updated successfully, but these errors were encountered: