diff --git a/scikits/learn/base.py b/scikits/learn/base.py index a8e2e4e342882fa54abbf724a07bf7a43ce92406..30123179e360ea2de459315fa94d145225258657 100644 --- a/scikits/learn/base.py +++ b/scikits/learn/base.py @@ -70,7 +70,10 @@ def _pprint(params, offset=0, printer=repr): this_line_length += len(this_repr) np.set_printoptions(**options) - return ''.join(params_list) + lines = ''.join(params_list) + # Strip trailing space to avoid nightmare in doctests + lines = '\n'.join(l.rstrip(' ') for l in lines.split('\n')) + return lines ################################################################################ diff --git a/scikits/learn/datasets/base.py b/scikits/learn/datasets/base.py index 290dc8dd2a6feb1d2c006322478fad16e6da96bf..370e6cf5844d6c6df595d7d87598667871e6f100 100644 --- a/scikits/learn/datasets/base.py +++ b/scikits/learn/datasets/base.py @@ -45,7 +45,7 @@ def load_iris(): >>> data.target[[10, 25, 50]] array([0, 0, 1]) >>> data.target_names - array(['setosa', 'versicolor', 'virginica'], + array(['setosa', 'versicolor', 'virginica'], dtype='|S10') """ diff --git a/scikits/learn/gmm.py b/scikits/learn/gmm.py index 9011387b2cc7968f85c31cb8ddb0408fd370c7d1..54235de0602e32b00977e5f15ba69f56a2a462e7 100644 --- a/scikits/learn/gmm.py +++ b/scikits/learn/gmm.py @@ -196,19 +196,19 @@ class GMM(BaseEstimator): >>> np.round(g.covars, 2) array([[[ 1.]], <BLANKLINE> - [[ 1.]]]) + [[ 1.]]]) >>> # Generate random observations with two modes centered on 0 >>> # and 10 to use for training. >>> np.random.seed(0) >>> obs = np.concatenate((np.random.randn(100, 1), ... 10 + np.random.randn(300, 1))) - >>> g.fit(obs) + >>> g.fit(obs) #doctest: +ELLIPSIS GMM(n_dim=1, cvtype='diag', - means=array([[ 9.94199], - [ 0.05981]]), - covars=[array([[ 0.96081]]), array([[ 1.01683]])], n_states=2, - weights=array([ 0.75, 0.25])) + means=array([[ ...], + [ ...]]), + covars=[array([[ ...]]), array([[ ...]])], n_states=2, + weights=array([ 0.75, 0.25])) >>> np.round(g.weights, 2) array([ 0.75, 0.25]) @@ -228,10 +228,10 @@ class GMM(BaseEstimator): >>> #same), this time with an even split between the two modes. >>> g.fit(20 * [[0]] + 20 * [[10]]) GMM(n_dim=1, cvtype='diag', - means=array([[ 10.], - [ 0.]]), - covars=[array([[ 0.001]]), array([[ 0.001]])], n_states=2, - weights=array([ 0.5, 0.5])) + means=array([[ 10.], + [ 0.]]), + covars=[array([[ 0.001]]), array([[ 0.001]])], n_states=2, + weights=array([ 0.5, 0.5])) >>> np.round(g.weights, 2) array([ 0.5, 0.5]) diff --git a/scikits/learn/hmm.py b/scikits/learn/hmm.py index ca5e60b03f57e01f1f375dc3b458a3909edaef1a..46b273b6a769e3a85ec06f6ed8edf45e2897ec63 100644 --- a/scikits/learn/hmm.py +++ b/scikits/learn/hmm.py @@ -820,15 +820,15 @@ class MultinomialHMM(_BaseHMM): Examples -------- >>> from scikits.learn.hmm import MultinomialHMM - >>> MultinomialHMM(n_states=2, nsymbols=3) + >>> MultinomialHMM(n_states=2, nsymbols=3) #doctest: +ELLIPSIS +REPORT_NDIFF MultinomialHMM(n_states=2, - emissionprob=array([[ 0.3663 , 0.12783, 0.50587], - [ 0.35851, 0.21559, 0.42589]]), - labels=[None, None], startprob_prior=1.0, - startprob=array([ 0.5, 0.5]), - transmat=array([[ 0.5, 0.5], - [ 0.5, 0.5]]), nsymbols=3, - transmat_prior=1.0) + emissionprob=array([[ ...], + [ ...]]), + labels=[None, None], startprob_prior=1.0, + startprob=array([ 0.5, 0.5]), + transmat=array([[ 0.5, 0.5], + [ 0.5, 0.5]]), nsymbols=3, + transmat_prior=1.0) See Also -------- @@ -952,8 +952,8 @@ class GMMHMM(_BaseHMM): Examples -------- >>> from scikits.learn.hmm import GMMHMM - >>> GMMHMM(n_states=2, n_mix=10, n_dim=3) # doctest: +ELLIPSIS - GMMHMM(n_dim=3, n_mix=10, n_states=2, cvtype=None, labels=[None, None], ...) + >>> GMMHMM(n_states=2, n_mix=10, n_dim=3) #doctest: +SKIP + GMMHMM(n_dim=3, n_mix=10, n_states=2, cvtype=None, labels=[None, None], ... See Also -------- diff --git a/scikits/learn/pipeline.py b/scikits/learn/pipeline.py index ea4ce2ea72a026cc96366868bd1c4c31dff9f0f7..74a3996a5f478c01d800771ef9cbac5711c54c84 100644 --- a/scikits/learn/pipeline.py +++ b/scikits/learn/pipeline.py @@ -64,7 +64,7 @@ class Pipeline(BaseEstimator): >>> # and a parameter 'C' of the svn >>> anova_svm.fit(X, y, anova__k=10, svc__C=.1) #doctest: +ELLIPSIS Pipeline(steps=[('anova', SelectKBest(k=10, score_func=<function f_regression at ...>)), ('svc', SVC(kernel='linear', C=0.1, probability=False, degree=3, coef0=0.0, eps=0.001, - cache_size=100.0, shrinking=True, gamma=0.01))]) + cache_size=100.0, shrinking=True, gamma=0.01))]) >>> prediction = anova_svm.predict(X) >>> score = anova_svm.score(X)