def scan(self, A1, X1):
from numpy import empty<EOL>from numpy.linalg import multi_dot<EOL>from numpy_sugar import epsilon, is_all_finite<EOL>from scipy.linalg import cho_solve<EOL>A1 = asarray(A1, float)<EOL>X1 = asarray(X1, float)<EOL>if not is_all_finite(A1):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if not is_all_finite(X1):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if A1.shape[<NUM_LIT:1>] == <NUM_LIT:0>:<EOL><INDENT>beta_se = sqrt(self.null_beta_covariance.diagonal())<EOL>return {<EOL>"<STR_LIT>": self.null_lml(),<EOL>"<STR_LIT>": unvec(self.null_beta, (self._ncovariates, -<NUM_LIT:1>)),<EOL>"<STR_LIT>": unvec(beta_se, (self._ncovariates, -<NUM_LIT:1>)),<EOL>"<STR_LIT>": empty((<NUM_LIT:0>,)),<EOL>"<STR_LIT>": empty((<NUM_LIT:0>,)),<EOL>"<STR_LIT>": self.null_scale,<EOL>}<EOL><DEDENT>X1X1 = X1.T @ X1<EOL>XX1 = self._X.T @ X1<EOL>AWA1 = self._WA.T @ A1<EOL>A1W = A1.T @ self._W<EOL>GX1 = self._G.T @ X1<EOL>MRiM1 = kron(AWA1, XX1)<EOL>M1RiM1 = kron(A1W @ A1, X1X1)<EOL>M1Riy = vec(multi_dot([X1.T, self._Y, A1W.T]))<EOL>XRiM1 = kron(self._WL0.T @ A1, GX1)<EOL>ZiXRiM1 = cho_solve(self._Lz, XRiM1)<EOL>MRiXZiXRiM1 = self._XRiM.T @ ZiXRiM1<EOL>M1RiXZiXRiM1 = XRiM1.T @ ZiXRiM1<EOL>M1RiXZiXRiy = XRiM1.T @ self._ZiXRiy<EOL>T0 = [[self._MRiM, MRiM1], [MRiM1.T, M1RiM1]]<EOL>T1 = [[self._MRiXZiXRiM, MRiXZiXRiM1], [MRiXZiXRiM1.T, M1RiXZiXRiM1]]<EOL>T2 = [self._MRiy, M1Riy]<EOL>T3 = [self._MRiXZiXRiy, M1RiXZiXRiy]<EOL>MKiM = block(T0) - block(T1)<EOL>MKiy = block(T2) - block(T3)<EOL>beta = rsolve(MKiM, MKiy)<EOL>mKiy = beta.T @ MKiy<EOL>cp = self._ntraits * self._ncovariates<EOL>effsizes0 = unvec(beta[:cp], (self._ncovariates, self._ntraits))<EOL>effsizes1 = unvec(beta[cp:], (X1.shape[<NUM_LIT:1>], A1.shape[<NUM_LIT:1>]))<EOL>np = self._nsamples * self._ntraits<EOL>sqrtdot = self._yKiy - mKiy<EOL>scale = clip(sqrtdot / np, epsilon.tiny, inf)<EOL>lml = self._static_lml() / <NUM_LIT:2> - np * safe_log(scale) / <NUM_LIT:2> - np / <NUM_LIT:2><EOL>effsizes_se = sqrt(clip(scale * pinv(MKiM).diagonal(), epsilon.tiny, inf))<EOL>effsizes0_se = unvec(effsizes_se[:cp], (self._ncovariates, self._ntraits))<EOL>effsizes1_se = unvec(effsizes_se[cp:], (X1.shape[<NUM_LIT:1>], A1.shape[<NUM_LIT:1>]))<EOL>return {<EOL>"<STR_LIT>": lml,<EOL>"<STR_LIT>": effsizes0,<EOL>"<STR_LIT>": effsizes1,<EOL>"<STR_LIT>": scale,<EOL>"<STR_LIT>": effsizes0_se,<EOL>"<STR_LIT>": effsizes1_se,<EOL>}<EOL>
LML, fixed-effect sizes, and scale of the candidate set.

Parameters
----------
A1 : (p, e) array_like
    Trait-by-environments design matrix.
X1 : (n, m) array_like
    Variants set matrix.

Returns
-------
lml : float
    Log of the marginal likelihood for the set.
effsizes0 : (c, p) ndarray
    Fixed-effect sizes for the covariates.
effsizes0_se : (c, p) ndarray
    Fixed-effect size standard errors for the covariates.
effsizes1 : (m, e) ndarray
    Fixed-effect sizes for the candidates.
effsizes1_se : (m, e) ndarray
    Fixed-effect size standard errors for the candidates.
scale : float
    Optimal scale.