<commit_before>import numpy as np


def test_n_componets_from_reducer():
    from pymks import MKSHomogenizationModel, DiscreteIndicatorBasis
    from sklearn.manifold import LocallyLinearEmbedding
    reducer = LocallyLinearEmbedding(n_components=7)
    dbasis = DiscreteIndicatorBasis(n_states=3, domain=[0, 2])
    model = MKSHomogenizationModel(dimension_reducer=reducer, basis=dbasis)
    assert model.n_components == 7


def test_n_components_with_reducer():
    from pymks import MKSHomogenizationModel, DiscreteIndicatorBasis
    from sklearn.manifold import SpectralEmbedding
    reducer = SpectralEmbedding(n_components=7)
    dbasis = DiscreteIndicatorBasis(n_states=3, domain=[0, 2])
    model = MKSHomogenizationModel(dimension_reducer=reducer, basis=dbasis,
                                   n_components=9)
    assert model.n_components == 9


def test_stress():
    from pymks.datasets import make_elastic_stress_random
    from pymks import MKSHomogenizationModel, DiscreteIndicatorBasis
    sample_size = 200
    grain_size = [(7, 7), (8, 3), (3, 9), (2, 2)]
    n_samples = [sample_size] * len(grain_size)
    elastic_modulus = (410, 200)
    poissons_ratio = (0.28, 0.3)
    macro_strain = 0.001
    size = (21, 21)
    X, y = make_elastic_stress_random(n_samples=n_samples, size=size,
                                      grain_size=grain_size,
                                      elastic_modulus=elastic_modulus,
                                      poissons_ratio=poissons_ratio,
                                      macro_strain=macro_strain, seed=0)
    dbasis = DiscreteIndicatorBasis(n_states=2, domain=[0, 1])
    model = MKSHomogenizationModel(basis=dbasis, n_components=3, degree=3)
    model.fit(X, y)
    test_sample_size = 1
    n_samples = [test_sample_size] * len(grain_size)
    X_new, y_new = make_elastic_stress_random(n_samples=n_samples,
                                              size=size, grain_size=grain_size,
                                              elastic_modulus=elastic_modulus,
                                              poissons_ratio=poissons_ratio,
                                              macro_strain=macro_strain,
                                              seed=8)
    y_result = model.predict(X_new)
    print np.round(y_result, decimals=2)<commit_msg>Update make_elastic_FE_stress_random function name in tests<commit_after>import numpy as np


def test_n_componets_from_reducer():
    from pymks import MKSHomogenizationModel, DiscreteIndicatorBasis
    from sklearn.manifold import LocallyLinearEmbedding
    reducer = LocallyLinearEmbedding(n_components=7)
    dbasis = DiscreteIndicatorBasis(n_states=3, domain=[0, 2])
    model = MKSHomogenizationModel(dimension_reducer=reducer, basis=dbasis)
    assert model.n_components == 7


def test_n_components_with_reducer():
    from pymks import MKSHomogenizationModel, DiscreteIndicatorBasis
    from sklearn.manifold import SpectralEmbedding
    reducer = SpectralEmbedding(n_components=7)
    dbasis = DiscreteIndicatorBasis(n_states=3, domain=[0, 2])
    model = MKSHomogenizationModel(dimension_reducer=reducer, basis=dbasis,
                                   n_components=9)
    assert model.n_components == 9


def test_stress():
    from pymks.datasets import make_elastic_FE_stress_random
    from pymks import MKSHomogenizationModel, DiscreteIndicatorBasis
    sample_size = 200
    grain_size = [(7, 7), (8, 3), (3, 9), (2, 2)]
    n_samples = [sample_size] * len(grain_size)
    elastic_modulus = (410, 200)
    poissons_ratio = (0.28, 0.3)
    macro_strain = 0.001
    size = (21, 21)
    X, y = make_elastic_FE_stress_random(n_samples=n_samples, size=size,
                                         grain_size=grain_size,
                                         elastic_modulus=elastic_modulus,
                                         poissons_ratio=poissons_ratio,
                                         macro_strain=macro_strain, seed=0)
    dbasis = DiscreteIndicatorBasis(n_states=2, domain=[0, 1])
    model = MKSHomogenizationModel(basis=dbasis, n_components=3, degree=3)
    model.fit(X, y)
    test_sample_size = 1
    n_samples = [test_sample_size] * len(grain_size)
    X_new, y_new = make_elastic_FE_stress_random(
        n_samples=n_samples, size=size, grain_size=grain_size,
        elastic_modulus=elastic_modulus, poissons_ratio=poissons_ratio,
        macro_strain=macro_strain, seed=8)
    y_result = model.predict(X_new)
    print np.round(y_result, decimals=2)
{'fraction_non_alphanumeric': 0.07766990291262135, 'fraction_numerical': 0.02206531332744925, 'mean_word_length': 2.724732949876746, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1346311', 'n_tokens_mistral': 1517, 'n_tokens_neox': 1388, 'n_words': 255}