This file is indexed.

/usr/lib/python2.7/dist-packages/pymc/gp/Mean.py is in python-pymc 2.2+ds-1.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Copyright (c) Anand Patil, 2007

__docformat__='reStructuredText'

from numpy import *
from .GPutils import regularize_array, trisolve

__all__ = ['Mean','zero_fn']

class Mean(object):
    """
    M = Mean(eval_fun, **params)


    A Gaussian process mean.


    :Arguments:
    
        -   `eval_fun`: A function that takes an argument x of shape  (n,ndim), where n is
            any integer and ndim is the dimensionality of  the space, or shape (n). In the
            latter case ndim should be assumed to be 1..

        -   `params`: Parameters to be passed to eval_fun


    :SeeAlso: Covariance, Realization, Observe
    """

    def __init__(self, eval_fun, **params):

        self.ndim = None
        self.observed = False
        self.obs_mesh = None
        self.base_mesh = None
        self.obs_vals = None
        self.obs_V = None
        self.reg_mat = None
        self.obs_len = None
        self.mean_under = None
        self.Uo = None
        self.obs_piv = None

        self.eval_fun = eval_fun
        self.params = params

    def observe(self, C, obs_mesh_new, obs_vals_new, mean_under = None):
        """
        Synchronizes self's observation status with C's.
        Values of observation are given by obs_vals.

        obs_mesh_new and obs_vals_new should already have
        been sliced, as Covariance.observe(..., output_type='o') does.
        """

        self.C = C
        self.obs_mesh = C.obs_mesh
        self.obs_len = C.obs_len

        self.Uo = C.Uo

        # Evaluate the underlying mean function on the new observation mesh.
        if mean_under is None:
            mean_under_new = C._mean_under_new(self, obs_mesh_new)
        else:
            mean_under_new = mean_under

        # If self hasn't been observed yet:
        if not self.observed:

            self.dev = (obs_vals_new - mean_under_new)

            self.reg_mat = C._unobs_reg(self)

        # If self has been observed already:
        elif len(obs_vals_new)>0:

            # Rank of old observations.
            m_old = len(self.dev)

            # Deviation of new observation from mean without regard to old observations.
            dev_new = (obs_vals_new - mean_under_new)


            # Again, basis covariances get special treatment.
            self.reg_mat = C._obs_reg(self, dev_new, m_old)

            # Stack deviations of old and new observations from unobserved mean.
            self.dev = hstack((self.dev, dev_new))
        self.observed = True

    def __call__(self, x, observed = True, regularize=True, Uo_Cxo=None):

        # Record original shape of x and regularize it.
        orig_shape = shape(x)
        if len(orig_shape)>1:
            orig_shape = orig_shape[:-1]

        if regularize:
            x=regularize_array(x)

        ndimx = x.shape[-1]
        lenx = x.shape[0]


        # Safety.
        if self.ndim is not None:
            if not self.ndim == ndimx:
                raise ValueError("The number of spatial dimensions of x does not match the number of spatial dimensions of the Mean instance's base mesh.")

        # Evaluate the unobserved mean
        M = self.eval_fun(x,**self.params).squeeze()

        # Condition. Basis covariances get special treatment. See documentation for formulas.
        if self.observed and observed:
            M = self.C._obs_eval(self, M, x, Uo_Cxo)

        return M.reshape(orig_shape)

def zero_fn(x):
    "A function mapping any argument to zero."
    return zeros(x.shape[:-1])