From da0e94b27dfdf11e7cd79ba684ba1b809c03e294 Mon Sep 17 00:00:00 2001 From: ST John Date: Fri, 24 Feb 2023 15:44:28 +0200 Subject: [PATCH 1/5] .pyspelling.yml and wordlist-custom.txt --- .pyspelling.yml | 43 +++++++++++ wordlist-custom.txt | 174 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 217 insertions(+) create mode 100644 .pyspelling.yml create mode 100644 wordlist-custom.txt diff --git a/.pyspelling.yml b/.pyspelling.yml new file mode 100644 index 000000000..b482b03a7 --- /dev/null +++ b/.pyspelling.yml @@ -0,0 +1,43 @@ +matrix: +- name: Python Source + aspell: + lang: en + d: en_GB + dictionary: + wordlists: + - wordlist-custom.txt + pipeline: + - pyspelling.filters.python: + strings: true + - pyspelling.filters.context: + context_visible_first: true + # escapes: \\[\\`~] + delimiters: + # ignore code examples + - open: '>>>' + close: '$' + # ignore .. math:: blocks + - open: '(?s)^(?P *)\.\. math::[\n]*' + close: '^[ ]*$' + # ignore :math:`` inline + - open: ':math:(?P`+)' + close: '(?P=open)' + # Ignore multiline content between fences (fences can have 3 or more back ticks) + # ``` + # content + # ``` + - open: '(?s)^(?P *`{3,})$' + close: '^(?P=open)$' + # Ignore text between inline back ticks + - open: '(?P`+)' + close: '(?P=open)' + - open: 'http://' + close: '[: \n]' + - open: 'https://' + close: '[: \n]' + - open: 'pragma:' + close: '$' + - open: '__all__ = \[' + close: ']' + sources: + - gpjax/**/[a-z]*.py diff --git a/wordlist-custom.txt b/wordlist-custom.txt new file mode 100644 index 000000000..5fd81bf1b --- /dev/null +++ b/wordlist-custom.txt @@ -0,0 +1,174 @@ +TODO + +GPJax +GPFlow +GPFlow's +GPG +JAX +Jax +JaxKern +JaxUtils +NumPyro +Distrax +PyTree + +jax +optax +tqdm +args +kwargs +config +concat +jaxutils +init +natgrads +gauss +hermite +inv + +ARD +bijection +bijectors +variational +jitter +probit +dataset +datapoints +hyperparameter +hyperparameters +param +params +parameterisation +parameterisations +trainables +trainability +unconstrain +unexpanded +unparsable +untagged +branchless +elementwise +pointwise +precompute +dimensionality +lengthscale +stateful +reimplement +subclasses +optimisers +subsample +getter + +i'th +j'th + +bool +boolean +iters +num +optim +loc +softplus + +sd +nd + +str + +elbo +pdf +diag +cov +cholesky +sqrt + +Kxx +Kxz +Kzx +KxzKzz +KxzLz +Ktt +Ktx +Ktz +Kxt +Kzt +Kzz +Lz +Lp +LpLp +Lq +LqLp +LqLq +Lx +wx +mz +uu + +df +du +dx + +MxD +NxD +NxM +NxN + + +Diggle +Frobenius +Hensman +MacKay +Ribeiro +Salimbeni +Titsias +et +al + +Mahalanobis +Matérn +Schur +Geostatistics + +Matern +RBF +AbstractKernel +AbstractKernelComputation +AbstractLikelihood +AbstractMeanFunction +AbstractPosterior +AbstractPrior +AbstractVariationalFamily +AbstractVariationalGaussian +AbstractVariationalInference +CollapsedVariationalGaussian +CollapsedVI +CombinationKernel +ConjugatePosterior +ConstantDiagonalKernelComputation +CovarianceOperator +CPython +DenseKernelComputation +DiagonalKernelComputation +ExpectationVariationalGaussian +GaussianDistribution +GradientTransformation +GraphKernel +InferenceState +KeyArray +LinearOperator +MeanFunction +MultivariateNormalTri +NaturalVariationalGaussian +NonConjugate +NonConjugatePosterior +Optax +ParameterState +PoweredExponential +PRNG +PRNGKey +ProductKernel +RationalQuadratic +StochasticVI +SumKernel +VariationalGaussian +WhitenedVariationalGaussian From cad3a8d87c5360bded23eaa664bbbee08dda192d Mon Sep 17 00:00:00 2001 From: ST John Date: Fri, 24 Feb 2023 15:44:50 +0200 Subject: [PATCH 2/5] fix more typos --- gpjax/gaussian_distribution.py | 2 +- gpjax/gps.py | 10 +++++----- gpjax/kernels.py | 6 +++--- gpjax/natural_gradients.py | 4 ++-- gpjax/parameters.py | 2 +- gpjax/variational_families.py | 2 +- gpjax/variational_inference.py | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/gpjax/gaussian_distribution.py b/gpjax/gaussian_distribution.py index 526688e27..25a94a29f 100644 --- a/gpjax/gaussian_distribution.py +++ b/gpjax/gaussian_distribution.py @@ -241,7 +241,7 @@ def _kl_divergence( # Mahalanobis term, (μp - μq)ᵀ Σp⁻¹ (μp - μq) = tr [(μp - μq)ᵀ [LpLpᵀ]⁻¹ (μp - μq)] = (fr[Lp⁻¹(μp - μq)])² mahalanobis = _frobeinius_norm_squared( sqrt_p.solve(diff) - ) # TODO: Need to improve this. Perhaps add a Mahalanobis method to LinearOperators. + ) # TODO: Need to improve this. Perhaps add a Mahalanobis method to ``LinearOperator``s. # KL[q(x)||p(x)] = [ [(μp - μq)ᵀ Σp⁻¹ (μp - μq)] - n - log|Σq| + log|Σp| + tr[Σp⁻¹ Σq] ] / 2 return (mahalanobis - n_dim - sigma_q.log_det() + sigma_p.log_det() + trace) / 2.0 diff --git a/gpjax/gps.py b/gpjax/gps.py index 34867ba9a..7d72b2ff9 100644 --- a/gpjax/gps.py +++ b/gpjax/gps.py @@ -199,7 +199,7 @@ def predict( ) -> Callable[[Float[Array, "N D"]], GaussianDistribution]: """Compute the predictive prior distribution for a given set of parameters. The output of this function is a function that computes - a distrx distribution for a given set of inputs. + a Distrax distribution for a given set of inputs. In the following example, we compute the predictive prior distribution and then evaluate it on the interval :math:`[0, 1]`: @@ -444,8 +444,8 @@ def predict(test_inputs: Float[Array, "N D"]) -> GaussianDistribution: test_inputs (Float[Array, "N D"]): A Jax array of test inputs. Returns: - GaussianDistribution: A ``GaussianDistribution`` - object that represents the predictive distribution. + A ``GaussianDistribution`` object that represents the + predictive distribution. """ # Unpack test inputs @@ -723,8 +723,8 @@ def marginal_log_likelihood( Unlike the marginal_log_likelihood function of the ConjugatePosterior object, the marginal_log_likelihood function of the - NonConjugatePosterior object does not provide an exact marginal - log-likelihood function. Instead, the NonConjugatePosterior object + ``NonConjugatePosterior`` object does not provide an exact marginal + log-likelihood function. Instead, the ``NonConjugatePosterior`` object represents the posterior distributions as a function of the model's hyperparameters and the latent function. Markov chain Monte Carlo, variational inference, or Laplace approximations can then be used to diff --git a/gpjax/kernels.py b/gpjax/kernels.py index 6e2034e2c..825217e17 100644 --- a/gpjax/kernels.py +++ b/gpjax/kernels.py @@ -266,7 +266,7 @@ def cross_covariance( ########################################## -# Abtract classes +# Abstract classes ########################################## class AbstractKernel(PyTree): """ @@ -1040,8 +1040,8 @@ def __call__( Args: params (Dict): Parameter set for which the kernel should be evaluated on. - x (Float[Array, "1 D"]): Index of the ith vertex. - y (Float[Array, "1 D"]): Index of the jth vertex. + x (Float[Array, "1 D"]): Index of the i'th vertex. + y (Float[Array, "1 D"]): Index of the j'th vertex. Returns: Float[Array, "1"]: The value of :math:`k(v_i, v_j)`. diff --git a/gpjax/natural_gradients.py b/gpjax/natural_gradients.py index 596bb6597..baa169390 100644 --- a/gpjax/natural_gradients.py +++ b/gpjax/natural_gradients.py @@ -124,7 +124,7 @@ def _expectation_elbo( def _rename_expectation_to_natural(params: Dict) -> Dict: """ This function renames the gradient components (that have expectation - parameterisation keys) to match the natural parameterisation pytree. + parameterisation keys) to match the natural parameterisation PyTree. Args: params (Dict): A dictionary of variational Gaussian parameters @@ -145,7 +145,7 @@ def _rename_expectation_to_natural(params: Dict) -> Dict: def _rename_natural_to_expectation(params: Dict) -> Dict: """ This function renames the gradient components (that have natural - parameterisation keys) to match the expectation parameterisation pytree. + parameterisation keys) to match the expectation parameterisation PyTree. Args: params (Dict): A dictionary of variational Gaussian parameters diff --git a/gpjax/parameters.py b/gpjax/parameters.py index 69e74d484..02a438c98 100644 --- a/gpjax/parameters.py +++ b/gpjax/parameters.py @@ -192,7 +192,7 @@ def recursive_bijectors(ps, bs) -> Tuple[Dict, Dict]: else: bijector = Identity warnings.warn( - f"Parameter {key} has no transform. Defaulting to identity transfom." + f"Parameter {key} has no transform. Defaulting to identity transform." ) bs[key] = bijector return bs diff --git a/gpjax/variational_families.py b/gpjax/variational_families.py index 7d16eb4d6..c9fe35877 100644 --- a/gpjax/variational_families.py +++ b/gpjax/variational_families.py @@ -575,7 +575,7 @@ class ExpectationVariationalGaussian(AbstractVariationalGaussian): The variational family is q(f(·)) = ∫ p(f(·)|u) q(u) du, where u = f(z) are the function values at the inducing inputs z and the distribution over the inducing inputs is q(u) = N(μ, S). Expressing the variational distribution, in the form of the exponential family, q(u) = exp(θᵀ T(u) - a(θ)), gives rise to the natural parameterisation θ = (θ₁, θ₂) = (S⁻¹μ, -S⁻¹/2) and - sufficient stastics T(u) = [u, uuᵀ]. The expectation parameters are given by η = ∫ T(u) q(u) du. This gives a parameterisation, + sufficient statistics T(u) = [u, uuᵀ]. The expectation parameters are given by η = ∫ T(u) q(u) du. This gives a parameterisation, η = (η₁, η₁) = (μ, S + uuᵀ) to perform model inference over. """ diff --git a/gpjax/variational_inference.py b/gpjax/variational_inference.py index 308beab95..846fb1ccd 100644 --- a/gpjax/variational_inference.py +++ b/gpjax/variational_inference.py @@ -40,7 +40,7 @@ class AbstractVariationalInference(PyTree): - """A base class for inference and training of variational families against an extact posterior""" + """A base class for inference and training of variational families against an exact posterior""" def __init__( self, From 07a2bfc28d6d778e83b384b51fd8e259be148b50 Mon Sep 17 00:00:00 2001 From: ST John Date: Fri, 24 Feb 2023 15:47:53 +0200 Subject: [PATCH 3/5] comments --- wordlist-custom.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wordlist-custom.txt b/wordlist-custom.txt index 5fd81bf1b..60520103c 100644 --- a/wordlist-custom.txt +++ b/wordlist-custom.txt @@ -114,6 +114,7 @@ NxM NxN +# names from references etc. Diggle Frobenius Hensman @@ -131,6 +132,7 @@ Geostatistics Matern RBF +# object types that are referenced throughout AbstractKernel AbstractKernelComputation AbstractLikelihood From 6c5c88218d7ceb7883898829fa9375e8197b3edc Mon Sep 17 00:00:00 2001 From: ST John Date: Fri, 24 Feb 2023 16:01:33 +0200 Subject: [PATCH 4/5] fix __all__ filter --- .pyspelling.yml | 7 +++++-- wordlist-custom.txt | 7 +------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.pyspelling.yml b/.pyspelling.yml index b482b03a7..1029f5ffb 100644 --- a/.pyspelling.yml +++ b/.pyspelling.yml @@ -7,6 +7,11 @@ matrix: wordlists: - wordlist-custom.txt pipeline: + - pyspelling.filters.context: + context_visible_first: true + delimiters: + - open: '__all__ = \[[^]]*' + close: '\]' - pyspelling.filters.python: strings: true - pyspelling.filters.context: @@ -37,7 +42,5 @@ matrix: close: '[: \n]' - open: 'pragma:' close: '$' - - open: '__all__ = \[' - close: ']' sources: - gpjax/**/[a-z]*.py diff --git a/wordlist-custom.txt b/wordlist-custom.txt index 60520103c..15d3e2a10 100644 --- a/wordlist-custom.txt +++ b/wordlist-custom.txt @@ -17,14 +17,9 @@ optax tqdm args kwargs -config -concat jaxutils init -natgrads -gauss -hermite -inv +config ARD bijection From 076846465b46b116dabda1fd76eda599a04b9aa6 Mon Sep 17 00:00:00 2001 From: ST John Date: Fri, 24 Feb 2023 16:03:09 +0200 Subject: [PATCH 5/5] comments --- .pyspelling.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.pyspelling.yml b/.pyspelling.yml index 1029f5ffb..478aa73ba 100644 --- a/.pyspelling.yml +++ b/.pyspelling.yml @@ -10,6 +10,7 @@ matrix: - pyspelling.filters.context: context_visible_first: true delimiters: + # needs to come *before* pyspelling.filters.python - open: '__all__ = \[[^]]*' close: '\]' - pyspelling.filters.python: @@ -18,10 +19,10 @@ matrix: context_visible_first: true # escapes: \\[\\`~] delimiters: - # ignore code examples + # ignore code examples (up to end of line) - open: '>>>' close: '$' - # ignore .. math:: blocks + # ignore .. math:: blocks (up to next blank line) - open: '(?s)^(?P *)\.\. math::[\n]*' close: '^[ ]*$' # ignore :math:`` inline @@ -36,10 +37,12 @@ matrix: # Ignore text between inline back ticks - open: '(?P`+)' close: '(?P=open)' + # URLs - open: 'http://' close: '[: \n]' - open: 'https://' close: '[: \n]' + # pragma: ... - open: 'pragma:' close: '$' sources: