# Path: jubakit/wrapper/clustering.py
# class KMeans(BaseKFixedClustering):
# 
#   def _method(self):
#     return 'kmeans'
# 
# class GMM(BaseKFixedClustering):
# 
#   def _method(self):
#     return 'gmm'
# 
# class DBSCAN(BaseJubatusClustering):
# 
#   def __init__(self, eps=0.2, min_core_point=3,
#                bucket_size=100, compressed_bucket_size=100,
#                bicriteria_base_size=10, bucket_length=2,
#                forgetting_factor=0.0, forgetting_threshold=0.5,
#                seed=0, embedded=True, distance='euclidean'):
#     super(DBSCAN, self).__init__('simple', bucket_size,
#                                  compressed_bucket_size, bicriteria_base_size,
#                                  bucket_length, forgetting_factor,
#                                  forgetting_threshold, seed, embedded,
#                                  distance)
#     self.eps = eps
#     self.min_core_point = min_core_point
# 
#   def _launch_clustering(self):
#     self.method = 'dbscan'
#     self.parameter = {
#       'eps': self.eps,
#       'min_core_point': self.min_core_point
#     }
#     self.config_ = Config(method=self.method, parameter=self.parameter,
#                           compressor_method=self.compressor_method,
#                           compressor_parameter=self.compressor_parameter,
#                           distance=self.distance)
#     self.clustering_ = Clustering.run(config=self.config_,
#                                       embedded=self.embedded)


from unittest import TestCase
from jubakit.wrapper.clustering import KMeans, GMM, DBSCAN
from . import requireEmbedded
  import numpy as np
    X = np.array([[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]])
    clustering = KMeans(k=10, embedded=False)
    self.assertRaises(RuntimeWarning, clustering.fit(X))
    clustering.stop()

    clustering = KMeans(k=5, embedded=False)
    self.assertTrue(not clustering.fitted)
    clustering.fit(X)
    self.assertTrue(clustering.fitted)

  def test_predict(self):
    X = np.array([[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]])
    clustering = KMeans(k=5, embedded=False)
    self.assertRaises(RuntimeError, clustering.predict(X))
    clustering.fit(X)
    y_pred = clustering.predict(X)
    self.assertEqual(len(y_pred), X.shape[0])

  def test_fit_predict(self):
    X = np.array([[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]])
    clustering = KMeans(k=5, embedded=False)
    self.assertTrue(not clustering.fitted)
    y_pred = clustering.fit_predict(X)
    self.assertTrue(clustering.fitted)
    self.assertEqual(len(y_pred), X.shape[0])


class GMMTest(TestCase):

  def test_simple(self):

# Path: jubakit/wrapper/clustering.py
# class KMeans(BaseKFixedClustering):
# 
#   def _method(self):
#     return 'kmeans'
# 
# class GMM(BaseKFixedClustering):
# 
#   def _method(self):
#     return 'gmm'
# 
# class DBSCAN(BaseJubatusClustering):
# 
#   def __init__(self, eps=0.2, min_core_point=3,
#                bucket_size=100, compressed_bucket_size=100,
#                bicriteria_base_size=10, bucket_length=2,
#                forgetting_factor=0.0, forgetting_threshold=0.5,
#                seed=0, embedded=True, distance='euclidean'):
#     super(DBSCAN, self).__init__('simple', bucket_size,
#                                  compressed_bucket_size, bicriteria_base_size,
#                                  bucket_length, forgetting_factor,
#                                  forgetting_threshold, seed, embedded,
#                                  distance)
#     self.eps = eps
#     self.min_core_point = min_core_point
# 
#   def _launch_clustering(self):
#     self.method = 'dbscan'
#     self.parameter = {
#       'eps': self.eps,
#       'min_core_point': self.min_core_point
#     }
#     self.config_ = Config(method=self.method, parameter=self.parameter,
#                           compressor_method=self.compressor_method,
#                           compressor_parameter=self.compressor_parameter,
#                           distance=self.distance)
#     self.clustering_ = Clustering.run(config=self.config_,
#                                       embedded=self.embedded)


# Path: jubakit/test/wrapper/test_clustering.py
from unittest import TestCase
from jubakit.wrapper.clustering import KMeans, GMM, DBSCAN
from . import requireEmbedded
  import numpy as np

    X = np.array([[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]])
    clustering = KMeans(k=10, embedded=False)
    self.assertRaises(RuntimeWarning, clustering.fit(X))
    clustering.stop()

    clustering = KMeans(k=5, embedded=False)
    self.assertTrue(not clustering.fitted)
    clustering.fit(X)
    self.assertTrue(clustering.fitted)

  def test_predict(self):
    X = np.array([[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]])
    clustering = KMeans(k=5, embedded=False)
    self.assertRaises(RuntimeError, clustering.predict(X))
    clustering.fit(X)
    y_pred = clustering.predict(X)
    self.assertEqual(len(y_pred), X.shape[0])

  def test_fit_predict(self):
    X = np.array([[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]])
    clustering = KMeans(k=5, embedded=False)
    self.assertTrue(not clustering.fitted)
    y_pred = clustering.fit_predict(X)
    self.assertTrue(clustering.fitted)
    self.assertEqual(len(y_pred), X.shape[0])


class GMMTest(TestCase):

  def test_simple(self):

    clustering = GMM(embedded=False)