for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
import numpy as np
import numpy.random as rnd
from libtlda.suba import SubspaceAlignedClassifier
def test_init01():
"""Test for object type."""
clf = SubspaceAlignedClassifier()
assert type(clf) == SubspaceAlignedClassifier
def test_init02():
"""Test for is_trained model."""
assert not clf.is_trained
def test_fit():
"""Test for fitting the model."""
X = rnd.randn(10, 2)
y = np.hstack((-np.ones((5,)), np.ones((5,))))
Z = rnd.randn(10, 2) + 1
clf.fit(X, y, Z)
assert clf.is_trained
def test_predict():
"""Test for making predictions."""
u_pred = clf.predict(Z)
labels = np.unique(y)
assert len(np.setdiff1d(np.unique(u_pred), labels)) == 0