<s> import unittest2 as unittest <EOL> import numpy as np <EOL> class TestBeagleComposite ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> from vsm . corpus . util . corpusbuilders import random_corpus <EOL> from vsm . model . beaglecomposite import BeagleComposite <EOL> from vsm . model . beagleenvironment import BeagleEnvironment <EOL> from vsm . model . beaglecontext import BeagleContextSeq <EOL> from vsm . model . beagleorder import BeagleOrderSeq <EOL> self . ec = random_corpus ( <NUM_LIT:1000> , <NUM_LIT:50> , <NUM_LIT:0> , <NUM_LIT:20> , context_type = '<STR_LIT>' ) <EOL> self . cc = self . ec . apply_stoplist ( stoplist = [ str ( i ) for i in xrange ( <NUM_LIT:0> , <NUM_LIT:50> , <NUM_LIT:7> ) ] ) <EOL> self . e = BeagleEnvironment ( self . ec , n_cols = <NUM_LIT:5> ) <EOL> self . e . train ( ) <EOL> self . cm = BeagleContextSeq ( self . cc , self . ec , self . e . matrix ) <EOL> self . cm . train ( ) <EOL> self . om = BeagleOrderSeq ( self . ec , self . e . matrix ) <EOL> self . om . train ( ) <EOL> self . m = BeagleComposite ( self . cc , self . cm . matrix , self . ec , self . om . matrix ) <EOL> self . m . train ( ) <EOL> def test_BeagleCompositeIO ( self ) : <EOL> from tempfile import NamedTemporaryFile <EOL> from vsm . model . beaglecomposite import BeagleComposite <EOL> import os <EOL> try : <EOL> tmp = NamedTemporaryFile ( delete = False , suffix = '<STR_LIT>' ) <EOL> self . m . save ( tmp . name ) <EOL> tmp . close ( ) <EOL> m1 = BeagleComposite . load ( tmp . name ) <EOL> self . assertTrue ( ( self . m . matrix == m1 . matrix ) . all ( ) ) <EOL> finally : <EOL> os . remove ( tmp . name ) <EOL> suite = unittest . TestLoader ( ) . loadTestsFromTestCase ( TestBeagleComposite ) <EOL> unittest . TextTestRunner ( verbosity = <NUM_LIT:2> ) . run ( suite ) </s>
