#NEWLINE# def drop_disjoint( train , test ) : #NEWLINE# #INDENT# '\n    Removes all features from train and test that are strictly all 0 in either the train\n    set or test set\n    \n    train, and test are scipy.sparse CSR matricies \n    ' #NEWLINE# in_training = find ( ( train . sum ( 0 ) . A . flatten ( ) != 0 ) ) #NEWLINE# train = train [ : , in_training ] #NEWLINE# test = test [ : , in_training ] #NEWLINE# in_test = find ( ( test . sum ( 0 ) . A . flatten ( ) != 0 ) ) #NEWLINE# train = train [ : , in_test ] #NEWLINE# test = in_training [ : , in_test ] #NEWLINE# return sparse . vstack ( ( train , test ) ) . tocsr ( )