Coverage for src/lsqfitgp/_GP/__init__.py: 100%
1 statements
« prev ^ index » next coverage.py v7.6.3, created at 2024-10-15 19:54 +0000
« prev ^ index » next coverage.py v7.6.3, created at 2024-10-15 19:54 +0000
1# lsqfitgp/_GP/__init__.py
2#
3# Copyright (c) 2023, Giacomo Petrillo
4#
5# This file is part of lsqfitgp.
6#
7# lsqfitgp is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# lsqfitgp is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with lsqfitgp. If not, see <http://www.gnu.org/licenses/>.
20from ._gp import GP 1abcdef
22# TODO planned rewrite:
23# Methods:
24# Processes
25# .defproc(key, *args, *, deriv=0)
26# *args is either (mean, kernel) or just (kernel,). The mean is an
27# ordinary callable.
28# Inspection
29# .elements() return a read-only mapping of keys -> named tuples with
30# fields ancestors=(tuple of keys), kind=str (x, cov, transf), shape,
31# x (array or None), proc (proc key or None). The mapping generates
32# the descriptions on the fly in __getitem__.
33# .processes() analogous with ancestors, kind (kernel, transf), kernel
34# (Kernel or None)
35# .dtype the x dtype, None if no x passed yet
36# .kernel(*args) if one key a Kernel, if two a CrossKernel
37# .meanfunc(prockey)
38# .__repr__() -> multiline readable description
39# Mean functions
40# .__init__(*args, ...) supports either only the kernel or the mean and
41# the kernel of the DefaultProcess.
42# .add(*args) arrays/dicts mean and cov or just cov, replaces .addcov.
43# Conditioning
44# .condition(given, givencov=None) -> new GP, with appended new keys and
45# values to condition on. given and givencov keep dict layout like
46# now.
47# .extend(given, givencov=None) -> new GP, like current predfromfit. It
48# sets a flag about the kind of conditioning in the list of given
49# stuff. I have to derive how to condition and extend together.
50# Distribution access
51# .mean(key) -> array, the key can be a pytree
52# .cov(*args) -> if one arg: square covariance, if two args: cross
53# covariance. The keys can be pytrees, and the result is the pytree
54# product with matrices as leaves.
55# .gvars(key, keepcorr=True) -> tree of arrays of gvars. keepcorr=True
56# won't work if condition was not passed gvars, so this default raises
57# an error if that happens.
58# .sample(key, n=1) -> array, key can be a pytree. caches the decomp?
59# Density
60# ._decomp(y, ycov=None) -> resid, cov (like _prior_decomp now)
61# .logpdf(y, ycov=None) -> like marginal_likelihood now
63# TODO methods to implement linear models. The elegant way to do this is with
64# kernels taking a formula, but that would not take advantage of the fact that
65# the kernel is low-rank if I re-implement Woodbury. I need to define an element
66# for the coefficients, and then the process works by definining finite
67# transformations of this element instead of going through the usual kernel
68# route.
69#
70# A more general route would be `features` mechanism for kernels: a kernel can
71# provide itself a way to evaluate a covariance matrix as a low-rank product.