<commit_before>"""
Test code for XDGMM class.
"""
import os
import unittest
import numpy as np
from sklearn.mixture import GaussianMixture as skl_GMM
from xdgmm import XDGMM

class XDGMMTestCase(unittest.TestCase):
    "TestCase class for XDGMM class."
    def setUp(self):
        """
        Set up each test with a new XDGMM object and some data.
        """
        self.xdgmm = XDGMM(n_components=3)
        self.files=[]
        
        """
        Use scikit-learn GaussianMixture for sampling some data points
        """
        weights = np.array([0.3,0.5,0.2])
        means = np.array([np.array([0,1]),np.array([5,4]),np.array([2,4])])
        covars = self.gmm.covars_=np.array([np.diag((2,1)),
                                            np.array([[1,0.2],[0.2,1]]),
                                            np.diag((0.3,0.5))])
                                            
        self.gmm = skl_GMM(n_components=3, max_iter=10,
                           covariance_type='full',
                           random_state=None,
                           weights_init=weights, means_init=means,
                           precisions_init=np.linalg.inv(covars))
        
        self.X=self.gmm.sample(1000)
        errs=0.2*np.random.random_sample((1000,2))
        self.Xerr = np.zeros(self.X.shape + self.X.shape[-1:])<commit_msg>Updated scikit-learn GMM to GaussianMixture to be compatible with future versions.<commit_after>"""
Test code for XDGMM class.
"""
import os
import unittest
import numpy as np
from sklearn.mixture import GaussianMixture as skl_GMM
from xdgmm import XDGMM

class XDGMMTestCase(unittest.TestCase):
    "TestCase class for XDGMM class."
    def setUp(self):
        """
        Set up each test with a new XDGMM object and some data.
        """
        self.xdgmm = XDGMM(n_components=3)
        self.files=[]
        
        """
        Use scikit-learn GaussianMixture for sampling some data points
        """
        weights = np.array([0.3,0.5,0.2])
        means = np.array([np.array([0,1]),np.array([5,4]),np.array([2,4])])
        covars = np.array([np.diag((2,1)), np.array([[1,0.2],[0.2,1]]),
                           np.diag((0.3,0.5))])
                                            
        self.gmm = skl_GMM(n_components=3, max_iter=10,
                           covariance_type='full',
                           random_state=None,
                           weights_init=weights, means_init=means,
                           precisions_init=np.linalg.inv(covars))
        
        self.X=self.gmm.sample(1000)
        errs=0.2*np.random.random_sample((1000,2))
        self.Xerr = np.zeros(self.X.shape + self.X.shape[-1:])
{'fraction_non_alphanumeric': 0.12830048345109707, 'fraction_numerical': 0.029750836742283376, 'mean_word_length': 1.7281947261663286, '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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '892197', 'n_tokens_mistral': 887, 'n_tokens_neox': 843, 'n_words': 163}