<s> import unittest <EOL> import pydsm . composition as composition <EOL> from pydsm import IndexMatrix <EOL> import scipy . sparse as sp <EOL> __author__ = '<STR_LIT>' <EOL> class TestLinear_additive ( unittest . TestCase ) : <EOL> def create_mat ( self , list_ , row2word = None , col2word = None ) : <EOL> if row2word is None : <EOL> row2word = self . row2word <EOL> if col2word is None : <EOL> col2word = self . col2word <EOL> return IndexMatrix ( sp . coo_matrix ( list_ ) , row2word , col2word ) <EOL> def setUp ( self ) : <EOL> self . spmat = sp . coo_matrix ( [ [ <NUM_LIT:2> , <NUM_LIT:5> , <NUM_LIT:3> ] , [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:9> ] ] ) <EOL> self . row2word = [ '<STR_LIT:a>' , '<STR_LIT:b>' ] <EOL> self . col2word = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . mat = IndexMatrix ( self . spmat , self . row2word , self . col2word ) <EOL> def test_linear_additive ( self ) : <EOL> res = self . create_mat ( [ [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ] , row2word = [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( res , composition . linear_additive ( self . mat [ <NUM_LIT:0> ] , self . mat [ <NUM_LIT:1> ] , alpha = <NUM_LIT:0.1> , beta = <NUM_LIT> ) ) <EOL> def multiplicative ( self ) : <EOL> res = self . create_mat ( [ [ <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> ] ] , row2word = [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( res , composition . multiplicative ( self . mat [ <NUM_LIT:0> ] , self . mat [ <NUM_LIT:1> ] , alpha = <NUM_LIT:0.1> , beta = <NUM_LIT> ) ) </s>
