pymks/mks_homogenization_model.py
def _reduce_shape(self, X_stats):
        """
        Helper function used to reshape 2-point statistics appropriately for
        fit and predict methods.

        Args:
            `X_stats`: 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.

        Returns:
            Spatial correlations for each sample formated with dimensions
            (n_samples, n_features).

        Example
        >>> X_stats = np.zeros((2, 2, 2, 2))
        >>> X_stats[1] = 3.
        >>> X_stats[..., 1] = 1.
        >>> X_results = np.array([[-.5, .5, -.5, .5, -.5, .5, -.5,  0.5],
        ...                       [1., -1., 1., -1., 1., -1., 1., -1.]])
        >>> from pymks import PrimitiveBasis
        >>> prim_basis = PrimitiveBasis(2)
        >>> model = MKSHomogenizationModel(prim_basis)
        >>> assert np.allclose(X_results, model._reduce_shape(X_stats))
        """
        X_reshaped = X_stats.reshape((X_stats.shape[0], X_stats[0].size))
        return X_reshaped - np.mean(X_reshaped, axis=1)[:, None]

        Helper function used to reshape 2-point statistics appropriately for
        fit and predict methods.

        Args:
            `X_stats`: 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.

        Returns:
            Spatial correlations for each sample formated with dimensions
            (n_samples, n_features).

        Example
        >>> X_stats = np.zeros((2, 2, 2, 2))
        >>> X_stats[1] = 3.
        >>> X_stats[..., 1] = 1.
        >>> X_results = np.array([[-.5, .5, -.5, .5, -.5, .5, -.5,  0.5],
        ...                       [1., -1., 1., -1., 1., -1., 1., -1.]])
        >>> from pymks import PrimitiveBasis
        >>> prim_basis = PrimitiveBasis(2)
        >>> model = MKSHomogenizationModel(prim_basis)
        >>> assert np.allclose(X_results, model._reduce_shape(X_stats))
        
Helper function used to reshape 2-point statistics appropriately for
fit and predict methods.
Helper function used to reshape 2 - point statistics appropriately for fit and predict methods .
def _reduce_shape(self, X_stats):
        X_reshaped = X_stats.reshape((X_stats.shape[0], X_stats[0].size))
        return X_reshaped - np.mean(X_reshaped, axis=1)[:, None]
def _reduce_shape ( self , X_stats ) : X_reshaped = X_stats . reshape ( ( X_stats . shape [ 0 ] , X_stats [ 0 ] . size ) ) return X_reshaped - np . mean ( X_reshaped , axis = 1 ) [ : , None ]
Helper function used to reshape 2-point statistics appropriately for
fit and predict methods.
Helper function used to reshape 2 - point statistics appropriately for fit and predict methods .
"""
        Helper function used to reshape 2-point statistics appropriately for
        fit and predict methods.

        Args:
            `X_stats`: 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.

        Returns:
            Spatial correlations for each sample formated with dimensions
            (n_samples, n_features).

        Example
        >>> X_stats = np.zeros((2, 2, 2, 2))
        >>> X_stats[1] = 3.
        >>> X_stats[..., 1] = 1.
        >>> X_results = np.array([[-.5, .5, -.5, .5, -.5, .5, -.5,  0.5],
        ...                       [1., -1., 1., -1., 1., -1., 1., -1.]])
        >>> from pymks import PrimitiveBasis
        >>> prim_basis = PrimitiveBasis(2)
        >>> model = MKSHomogenizationModel(prim_basis)
        >>> assert np.allclose(X_results, model._reduce_shape(X_stats))
        """
Spatial correlations for each sample formated with dimensions
(n_samples, n_features).
Spatial correlations for each sample formated with dimensions ( n_samples n_features ) .
self
X_stats
`X_stats`
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 .