openturns / otmixmod

MixMod module
http://openturns.github.io/otmixmod/master/
GNU General Public License v3.0
2 stars 3 forks source link

otmixmod crashes #23

Closed mbaudin47 closed 3 months ago

mbaudin47 commented 3 months ago

In the next script, I make a loop over the different covariance models in Mixmod. This makes the kernel crash.

# %%
import openturns as ot
import otmixmod

# %%
print(ot.__version__)
print(otmixmod.__version__)

# %%
ot.RandomGenerator.SetSeed(0)

# %%
def generateData(sampleSize):
    # Gaussian 1
    mu1 = ot.Point([-2.0, 2.0])
    sigma1 = ot.Point(2, 1.0)
    correlation1 = ot.CorrelationMatrix(2)
    correlation1[0, 1] = 0.2
    gaussian1 = ot.Normal(mu1, sigma1, correlation1)

    # Gaussian 2
    mu2 = ot.Point([2.0, -2.0])
    sigma2 = ot.Point(2, 0.5)
    correlation2 = ot.CorrelationMatrix(2)
    correlation2[0, 1] = -0.5
    gaussian2 = ot.Normal(mu2, sigma2, correlation2)

    # Mixture
    w1 = 1.0 / 3.0
    w2 = 1.0 - w1
    mixture = ot.Mixture([gaussian1, gaussian2], [w1, w2])
    #
    sample = mixture.getSample(sampleSize)
    return mixture, sample

# %%
sampleSize = 200
mixture, sample = generateData(sampleSize)
print("True mixture:")
print(mixture)

# %%
listOfValidModels = [
        "Gaussian_p_L_I"
        "Gaussian_p_Lk_I"
    ]
numberOfClasses = 2

# %%
for covarianceModel in listOfValidModels:
    factory = otmixmod.MixtureFactory(numberOfClasses, covarianceModel)
    print(f"Build with covariance model = {covarianceModel}")
    mixture, labels, logLikelihood = factory.buildAsMixture(sample)
    print(mixture)

The message is:

The Kernel crashed while executing code in the the current cell or a previous cell. 
Please review the code in the cell(s) to identify a possible cause of the failure. 
Click [here](https://aka.ms/vscodeJupyterKernelCrash) for more info. 
View Jupyter [log](command:jupyter.viewOutput) for further details.

This is with OT 1.21 and otmixmod 0.14. The test is on Linux. otmixmod was installed with Conda.

jschueller commented 3 months ago

you forgot a comma between covmodel names current mixmod does not crash though, raises a correct exception