@ignore_warnings(category=DeprecationWarning)
def check_positive_definite_covars(covariance_type):
 rng = np.random.RandomState(1)
 X = rng.randn(100, 2)
 X[(-10):] += (3, 3)
 gmm = mixture.GMM(2, params='wc', covariance_type=covariance_type, min_covar=0.001)
 gmm.fit(X)
 if ((covariance_type == 'diag') or (covariance_type == 'spherical')):
  assert_greater(gmm.covars_.min(), 0)
 else:
  if (covariance_type == 'tied'):
   covs = [gmm.covars_]
  else:
   covs = gmm.covars_
  for c in covs:
   assert_greater(np.linalg.det(c), 0)

@ ignore_warnings ( category = DeprecationWarning ) def check_positive_definite_covars ( covariance_type ) : rng = np . random . RandomState ( 1 ) X = rng . randn ( 100 , 2 ) X [ ( - 10 ) : ] += ( 3 , 3 ) gmm = mixture . GMM ( 2 , params = 'wc' , covariance_type = covariance_type , min_covar = 0.001 ) gmm . fit ( X ) if ( ( covariance_type == 'diag' ) or ( covariance_type == 'spherical' ) ) : assert_greater ( gmm . covars_ . min ( ) , 0 ) else : if ( covariance_type == 'tied' ) : covs = [ gmm . covars_ ] else : covs = gmm . covars_ for c in covs : assert_greater ( np . linalg . det ( c ) , 0 )
test that covariance matrices do not become non positive definite due to the accumulation of round-off errors .