<s> import numpy as np <EOL> from numpy . testing import assert_almost_equal <EOL> from nose . tools import raises <EOL> from mlxtend . feature_extraction import LinearDiscriminantAnalysis as LDA <EOL> from mlxtend . data import iris_data <EOL> from mlxtend . preprocessing import standardize <EOL> X , y = iris_data ( ) <EOL> X = standardize ( X ) <EOL> def test_default_components ( ) : <EOL> lda = LDA ( ) <EOL> lda . fit ( X , y ) <EOL> res = lda . fit ( X ) . transform ( X ) <EOL> assert res . shape [ <NUM_LIT:1> ] == <NUM_LIT:4> <EOL> def test_default_2components ( ) : <EOL> lda = LDA ( n_discriminants = <NUM_LIT:2> ) <EOL> lda . fit ( X , y ) <EOL> res = lda . fit ( X , y ) . transform ( X ) <EOL> assert res . shape [ <NUM_LIT:1> ] == <NUM_LIT:2> <EOL> @ raises ( AttributeError ) <EOL> def test_default_components ( ) : <EOL> lda = LDA ( n_discriminants = <NUM_LIT:0> ) <EOL> lda . fit ( X , y ) <EOL> res = lda . fit ( X ) . transform ( X ) <EOL> def test_evals ( ) : <EOL> lda = LDA ( n_discriminants = <NUM_LIT:2> ) <EOL> res = lda . fit ( X , y ) . transform ( X ) <EOL> np . set_printoptions ( suppress = True ) <EOL> print ( '<STR_LIT:%s>' % lda . e_vals_ ) <EOL> assert_almost_equal ( lda . e_vals_ , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0.0> , <NUM_LIT:0.0> ] , decimal = <NUM_LIT:2> ) <EOL> @ raises ( ValueError ) <EOL> def test_fail_array_fit ( ) : <EOL> lda = LDA ( ) <EOL> lda . fit ( X [ <NUM_LIT:1> ] , y [ <NUM_LIT:1> ] ) <EOL> @ raises ( ValueError ) <EOL> def test_fail_array_transform ( ) : <EOL> lda = LDA ( ) <EOL> lda . fit ( X , y ) <EOL> exp = lda . transform ( X [ <NUM_LIT:1> ] ) </s>
