예제 #1
0
파일: covariance.py 프로젝트: noinil/PyEMMA
    def weights(self, value):
        from pyemma.coordinates.data import DataInMemory
        import types

        if is_float_vector(value):
            value = DataInMemory(value)
        elif isinstance(value, (list, tuple)):
            value = DataInMemory(value)
        elif isinstance(value, numbers.Integral):
            value = float(value) if value is not None else 1.0
        elif hasattr(value, 'weights') and type(getattr(
                value, 'weights')) == types.MethodType:
            from pyemma.coordinates.data._base.transformer import StreamingTransformer

            class compute_weights_streamer(StreamingTransformer):
                def __init__(self, func):
                    super(compute_weights_streamer, self).__init__()
                    self.func = func

                def dimension(self):
                    return 1

                def _transform_array(self, X):
                    return self.func.weights(X)

                def describe(self):
                    pass

            value = compute_weights_streamer(value)

        self._weights = value
예제 #2
0
    def __init__(self,
                 c00=True,
                 c0t=False,
                 ctt=False,
                 remove_constant_mean=None,
                 remove_data_mean=False,
                 reversible=False,
                 bessel=True,
                 sparse_mode='auto',
                 modify_data=False,
                 lag=0,
                 weights=None,
                 stride=1,
                 skip=0,
                 chunksize=None,
                 ncov_max=float('inf')):
        super(LaggedCovariance, self).__init__(chunksize=chunksize)

        if (c0t or ctt) and lag == 0:
            raise ValueError("lag must be positive if c0t=True or ctt=True")
        if is_float_vector(weights):
            weights = ensure_float_vector(weights)
        if remove_constant_mean is not None and remove_data_mean:
            raise ValueError(
                'Subtracting the data mean and a constant vector simultaneously is not supported.'
            )
        if remove_constant_mean is not None:
            remove_constant_mean = ensure_float_vector(remove_constant_mean)
        self.set_params(c00=c00,
                        c0t=c0t,
                        ctt=ctt,
                        remove_constant_mean=remove_constant_mean,
                        remove_data_mean=remove_data_mean,
                        reversible=reversible,
                        sparse_mode=sparse_mode,
                        modify_data=modify_data,
                        lag=lag,
                        bessel=bessel,
                        weights=weights,
                        stride=stride,
                        skip=skip,
                        ncov_max=ncov_max)

        self._rc = None
        self._used_data = 0