# -*- coding: utf-8 -*-

from sklearn.datasets.samples_generator import make_classification,\
    make_regression
from malss import MALSS
import pandas as pd
from nose.plugins.attrib import attr
import numpy as np


def test_classification_2classes_small():
    X, y = make_classification(n_samples=1000,
                               n_features=10,
                               n_classes=2,
                               n_informative=2,
                               n_redundant=0,
                               n_repeated=0,
                               weights=[0.7, 0.3],
                               random_state=0)
    X = pd.DataFrame(X)
    y = pd.Series(y)
    cls = MALSS(X, y, 'classification', n_jobs=3)
    cls.execute()
    # cls.make_report('test_classification_2classes_small')

    assert cls.algorithms[0].best_score is not None


def test_classification_multiclass_small():
    X, y = make_classification(n_samples=1000,
                               n_features=20,
                               n_classes=3,
                               n_informative=10,
                               weights=[0.6, 0.2, 0.2],
                               random_state=0)
    X = pd.DataFrame(X)
    y = pd.Series(y)
    cls = MALSS(X, y, 'classification', n_jobs=3)
    cls.execute()
    # cls.make_report('test_classification_multiclass_small')

    assert cls.algorithms[0].best_score is not None


@attr(speed='slow')
def test_classification_2classes_medium():
    X, y = make_classification(n_samples=100000,
                               n_features=10,
                               n_classes=2,
                               n_informative=2,
                               n_redundant=0,
                               n_repeated=0,
                               weights=[0.7, 0.3],
                               random_state=0)
    X = pd.DataFrame(X)
    y = pd.Series(y)
    cls = MALSS(X, y, 'classification', n_jobs=3)
    cls.execute()
    # cls.make_report('test_classification_2classes_medium')

    assert cls.algorithms[0].best_score is not None


@attr(speed='slow')
def test_classification_2classes_big():
    X, y = make_classification(n_samples=200000,
                               n_features=20,
                               n_classes=2,
                               n_informative=3,
                               weights=[0.7, 0.3],
                               random_state=0)
    X = pd.DataFrame(X)
    y = pd.Series(y)
    cls = MALSS(X, y, 'classification', n_jobs=3)
    cls.execute()
    # cls.make_report('test_classification_2classes_big')

    assert cls.algorithms[0].best_score is not None


def test_regression_small():
    X, y = make_regression(n_samples=2000,
                           n_features=10,
                           n_informative=5,
                           noise=30.0,
                           random_state=0)
    X = pd.DataFrame(X)
    y = pd.Series(y)
    cls = MALSS(X, y, 'regression', n_jobs=3)
    cls.execute()
    # cls.make_report('test_regression_small')

    assert cls.algorithms[0].best_score is not None


@attr(speed='slow')
def test_regression_medium():
    X, y = make_regression(n_samples=20000,
                           n_features=10,
                           n_informative=5,
                           noise=30.0,
                           random_state=0)
    X = pd.DataFrame(X)
    y = pd.Series(y)
    cls = MALSS(X, y, 'regression', n_jobs=3)
    cls.execute()
    # cls.make_report('test_regression_medium')

    assert cls.algorithms[0].best_score is not None


@attr(speed='slow')
def test_regression_big():
    X, y = make_regression(n_samples=200000,
                           n_features=10,
                           n_informative=5,
                           noise=30.0,
                           random_state=0)
    X = pd.DataFrame(X)
    y = pd.Series(y)
    cls = MALSS(X, y, 'regression', n_jobs=3)
    cls.execute()
    # cls.make_report('test_regression_big')

    assert cls.algorithms[0].best_score is not None


def test_classification_categorical():
    data = pd.read_csv('http://www-bcf.usc.edu/~gareth/ISL/Heart.csv',
                       index_col=0, na_values=[''])

    y = data['AHD']
    del data['AHD']

    cls = MALSS(data, y, 'classification', n_jobs=3)
    cls.execute()
    # cls.make_report('test_classification_categorical')

    assert cls.algorithms[0].best_score is not None


def test_ndarray():
    data = pd.read_csv('http://www-bcf.usc.edu/~gareth/ISL/Heart.csv',
                       index_col=0, na_values=[''])

    y = data['AHD']
    del data['AHD']

    cls = MALSS(np.array(data), np.array(y), 'classification', n_jobs=3)
    cls.execute()
    # cls.make_report('test_ndarray')

    assert cls.algorithms[0].best_score is not None


if __name__ == "__main__":
    test_classification_2classes_small()

@@ -791,32 +791,68 @@
 lasses_small')%0A%0A
+    assert len(cls.algorithms) == 5%0A
     assert cls.a
@@ -879,32 +879,32 @@
 ore is not None%0A
-
 %0A%0Adef test_class
@@ -1390,32 +1390,68 @@
 iclass_small')%0A%0A
+    assert len(cls.algorithms) == 5%0A
     assert cls.a
@@ -2094,32 +2094,68 @@
 asses_medium')%0A%0A
+    assert len(cls.algorithms) == 4%0A
     assert cls.a
@@ -2701,32 +2701,68 @@
 2classes_big')%0A%0A
+    assert len(cls.algorithms) == 1%0A
     assert cls.a
@@ -3188,32 +3188,68 @@
 ession_small')%0A%0A
+    assert len(cls.algorithms) == 2%0A
     assert cls.a
@@ -3698,32 +3698,68 @@
 ssion_medium')%0A%0A
+    assert len(cls.algorithms) == 1%0A
     assert cls.a
@@ -4203,32 +4203,68 @@
 gression_big')%0A%0A
+    assert len(cls.algorithms) == 1%0A
     assert cls.a
@@ -4630,24 +4630,60 @@
 egorical')%0A%0A
+    assert len(cls.algorithms) == 5%0A
     assert c
@@ -5035,24 +5035,60 @@
 _ndarray')%0A%0A
+    assert len(cls.algorithms) == 5%0A
     assert c

add assert condition