pymks/stats.py
def _correlate(X_, s, correlations):
    """
    Helper function used to calculate the unnormalized correlation counts.

    Args:
        X_ (ND array): The discretized microstructure function, an
            `(n_samples, n_x, ..., n_states)` shaped array
            where `n_samples` is the number of samples, `n_x` is thes
            patial discretization, and n_states is the number of local states.
        s (tuple): shape of the Fkernel used for the convolution

    Returns:
        correlation counts for a given microstructure function

    Example

    >>> from pymks.datasets import make_microstructure
    >>> from pymks.bases import PrimitiveBasis
    >>> X = make_microstructure(n_samples=2, n_phases=3,
    ...                         size=(2, 2), grain_size=(2, 2), seed=99)
    >>> prim_basis = PrimitiveBasis(n_states=3, domain=[0, 2])
    >>> X_ = prim_basis.discretize(X)
    >>> correlations = [(l, l) for l in range(3)]
    >>> X_corr = _correlate(X_, X_.shape[1:-1], correlations=correlations)
    >>> X_result = np.array([[[[0, 0, 0],
    ...                        [0, 0, 2]],
    ...                       [[0, 0, 0],
    ...                        [1, 1, 2]]],
    ...                      [[[0, 0, 0],
    ...                        [0, 0, 0]],
    ...                       [[2, 0, 2],
    ...                        [2, 0, 2]]]])
    >>> assert np.allclose(X_result, X_corr)
    """

    l_0, l_1 = [l[0] for l in correlations], [l[1] for l in correlations]
    corr = Correlation(X_[..., l_0], Fkernel_shape=s).convolve(X_[..., l_1])
    return _truncate(corr, X_.shape[:-1])

    Helper function used to calculate the unnormalized correlation counts.

    Args:
        X_ (ND array): The discretized microstructure function, an
            `(n_samples, n_x, ..., n_states)` shaped array
            where `n_samples` is the number of samples, `n_x` is thes
            patial discretization, and n_states is the number of local states.
        s (tuple): shape of the Fkernel used for the convolution

    Returns:
        correlation counts for a given microstructure function

    Example

    >>> from pymks.datasets import make_microstructure
    >>> from pymks.bases import PrimitiveBasis
    >>> X = make_microstructure(n_samples=2, n_phases=3,
    ...                         size=(2, 2), grain_size=(2, 2), seed=99)
    >>> prim_basis = PrimitiveBasis(n_states=3, domain=[0, 2])
    >>> X_ = prim_basis.discretize(X)
    >>> correlations = [(l, l) for l in range(3)]
    >>> X_corr = _correlate(X_, X_.shape[1:-1], correlations=correlations)
    >>> X_result = np.array([[[[0, 0, 0],
    ...                        [0, 0, 2]],
    ...                       [[0, 0, 0],
    ...                        [1, 1, 2]]],
    ...                      [[[0, 0, 0],
    ...                        [0, 0, 0]],
    ...                       [[2, 0, 2],
    ...                        [2, 0, 2]]]])
    >>> assert np.allclose(X_result, X_corr)
    
Helper function used to calculate the unnormalized correlation counts.
Helper function used to calculate the unnormalized correlation counts .
def _correlate(X_, s, correlations):
    l_0, l_1 = [l[0] for l in correlations], [l[1] for l in correlations]
    corr = Correlation(X_[..., l_0], Fkernel_shape=s).convolve(X_[..., l_1])
    return _truncate(corr, X_.shape[:-1])
def _correlate ( X_ , s , correlations ) : l_0 , l_1 = [ l [ 0 ] for l in correlations ] , [ l [ 1 ] for l in correlations ] corr = Correlation ( X_ [ ... , l_0 ] , Fkernel_shape = s ) . convolve ( X_ [ ... , l_1 ] ) return _truncate ( corr , X_ . shape [ : - 1 ] )
Helper function used to calculate the unnormalized correlation counts.
Helper function used to calculate the unnormalized correlation counts .
"""
    Helper function used to calculate the unnormalized correlation counts.

    Args:
        X_ (ND array): The discretized microstructure function, an
            `(n_samples, n_x, ..., n_states)` shaped array
            where `n_samples` is the number of samples, `n_x` is thes
            patial discretization, and n_states is the number of local states.
        s (tuple): shape of the Fkernel used for the convolution

    Returns:
        correlation counts for a given microstructure function

    Example

    >>> from pymks.datasets import make_microstructure
    >>> from pymks.bases import PrimitiveBasis
    >>> X = make_microstructure(n_samples=2, n_phases=3,
    ...                         size=(2, 2), grain_size=(2, 2), seed=99)
    >>> prim_basis = PrimitiveBasis(n_states=3, domain=[0, 2])
    >>> X_ = prim_basis.discretize(X)
    >>> correlations = [(l, l) for l in range(3)]
    >>> X_corr = _correlate(X_, X_.shape[1:-1], correlations=correlations)
    >>> X_result = np.array([[[[0, 0, 0],
    ...                        [0, 0, 2]],
    ...                       [[0, 0, 0],
    ...                        [1, 1, 2]]],
    ...                      [[[0, 0, 0],
    ...                        [0, 0, 0]],
    ...                       [[2, 0, 2],
    ...                        [2, 0, 2]]]])
    >>> assert np.allclose(X_result, X_corr)
    """
correlation counts for a given microstructure function
correlation counts for a given microstructure function
X_
The discretized microstructure function, an
`(n_samples, n_x, ..., n_states)` shaped array
where `n_samples` is the number of samples, `n_x` is thes
patial discretization, and n_states is the number of local states.
The discretized microstructure function an ` ( n_samples n_x ... n_states ) ` shaped array where ` n_samples ` is the number of samples ` n_x ` is thes patial discretization and n_states is the number of local states .
s
shape of the Fkernel used for the convolution
shape of the Fkernel used for the convolution
correlations