<s> """<STR_LIT>""" <EOL> import unittest <EOL> import numpy as np <EOL> from __init__ import mgSolve <EOL> from solvers import smooth , smoothToThreshold , gaussSeidel <EOL> import operators <EOL> import tools <EOL> from sys import _getframe , exc_info <EOL> def whoami ( level = <NUM_LIT:1> ) : <EOL> '''<STR_LIT>''' <EOL> return _getframe ( level ) . f_code . co_name <EOL> def mpl_test_data ( delta = <NUM_LIT> ) : <EOL> '''<STR_LIT>''' <EOL> from matplotlib . mlab import bivariate_normal <EOL> x = y = np . arange ( - <NUM_LIT> , <NUM_LIT> , delta ) <EOL> X , Y = np . meshgrid ( x , y ) <EOL> Z1 = bivariate_normal ( X , Y , <NUM_LIT:1.0> , <NUM_LIT:1.0> , <NUM_LIT:0.0> , <NUM_LIT:0.0> ) <EOL> Z2 = bivariate_normal ( X , Y , <NUM_LIT> , <NUM_LIT:0.5> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> Z = Z2 - Z1 <EOL> X = X * <NUM_LIT:16> <EOL> Y = Y * <NUM_LIT:16> <EOL> Z = Z * <NUM_LIT> <EOL> return X , Y , Z <EOL> class TestOpenMG ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . verbose = False <EOL> self . saveFig = False <EOL> self . parameters = { <EOL> '<STR_LIT>' : ( <NUM_LIT> , ) , <EOL> '<STR_LIT>' : <NUM_LIT:3> , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : <NUM_LIT:4> , <EOL> '<STR_LIT>' : True , <EOL> } <EOL> def test_a ( self ) : <EOL> '''<STR_LIT>''' <EOL> problemscale = <NUM_LIT:12> <EOL> size = problemscale ** <NUM_LIT:3> <EOL> gridLevels = <NUM_LIT:4> <EOL> u_zeros = np . zeros ( ( size , ) ) <EOL> u_actual = np . sin ( np . array ( range ( int ( size ) ) ) * <NUM_LIT> / size ) . T <EOL> A = operators . poisson ( ( size , ) ) <EOL> b = tools . flexibleMmult ( A , u_actual ) <EOL> uSmoothed = smooth ( A , b , u_zeros , iterations = <NUM_LIT:1> ) <EOL> parameters = { '<STR_LIT>' : gridLevels - <NUM_LIT:1> , <EOL> '<STR_LIT>' : ( problemscale , problemscale , problemscale ) , <EOL> '<STR_LIT>' : gridLevels , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } <EOL> u_mmg = mgSolve ( A , b , parameters ) <EOL> if self . verbose : <EOL> print '<STR_LIT>' , ( np . linalg . norm ( tools . getresidual ( b , A , uSmoothed . reshape ( ( size , <NUM_LIT:1> ) ) , size ) ) ) <EOL> residual_norm = np . linalg . norm ( tools . flexibleMmult ( A , u_mmg ) - b ) <EOL> assert parameters [ '<STR_LIT>' ] > residual_norm <EOL> def test_b ( self ) : <EOL> '''<STR_LIT>''' <EOL> N = <NUM_LIT> <EOL> shape = ( <NUM_LIT:16> , <NUM_LIT:16> , <NUM_LIT:16> , ) <EOL> if self . verbose : <EOL> print '<STR_LIT>' % N , '<STR_LIT>' , operators . restriction ( N , shape ) . shape <EOL> def test_c ( self ) : <EOL> '''<STR_LIT>''' <EOL> thousands = [ <NUM_LIT:1> , <NUM_LIT:3> , ] <EOL> frames = <NUM_LIT:5> <EOL> multifreq_Ns = map ( lambda x : int ( x * <NUM_LIT:10> ** <NUM_LIT:3> ) , thousands ) <EOL> for N in multifreq_Ns : <EOL> self . multifreq_1d ( N , frames ) <EOL> def test_d ( self ) : <EOL> '''<STR_LIT>''' <EOL> tens = [ <NUM_LIT:1> , <NUM_LIT:2> ] <EOL> multifreq_problemscales = map ( lambda x : int ( x * <NUM_LIT:10> ** <NUM_LIT:1> ) , tens ) <EOL> frames = <NUM_LIT:5> <EOL> for NX in multifreq_problemscales : <EOL> self . multifreq_2d ( NX , frames ) <EOL> def multifreq_1d ( self , N , finaliterations , spectralxscale = '<STR_LIT>' , <EOL> solutionname = '<STR_LIT>' , save = False ) : <EOL> '''<STR_LIT>''' <EOL> if solutionname == '<STR_LIT>' : <EOL> data = np . zeros ( ( N , ) ) <EOL> domainwidthsexponents = range ( <NUM_LIT:10> ) <EOL> domainwidths = range ( <NUM_LIT:10> ) <EOL> for i in range ( <NUM_LIT:10> ) : <EOL> domainwidths [ i ] = float ( N ) / ( <NUM_LIT> ** domainwidthsexponents [ i ] ) <EOL> for domainwidth in domainwidths : <EOL> sininput = np . arange ( <NUM_LIT:0.0> , domainwidth , domainwidth / N ) <EOL> xdata = ( np . sin ( sininput ) / domainwidth * <NUM_LIT> ) [ <NUM_LIT:0> : N : ] <EOL> data = data + xdata <EOL> else : <EOL> solutionname = '<STR_LIT>' <EOL> data = np . random . random ( ( N , ) ) <EOL> gif_output_name = '<STR_LIT>' % ( N , spectralxscale , solutionname ) <EOL> A = operators . poisson ( ( N , ) ) <EOL> b = tools . flexibleMmult ( A , data ) <EOL> if self . saveFig : <EOL> from scipy import fftpack <EOL> import matplotlib . pyplot as plt <EOL> fig = plt . figure ( figsize = ( <NUM_LIT> , <NUM_LIT:7> ) ) <EOL> fig . suptitle ( gif_output_name ) <EOL> fig . subplots_adjust ( wspace = <NUM_LIT> ) <EOL> fig . subplots_adjust ( hspace = <NUM_LIT> ) <EOL> solnax = fig . add_subplot ( <NUM_LIT> ) <EOL> solnaxylim = [ <NUM_LIT:0> , <NUM_LIT:1> ] <EOL> specax = fig . add_subplot ( <NUM_LIT> ) <EOL> specaxylim = [ <NUM_LIT> ** ( - <NUM_LIT> ) , <NUM_LIT> ** <NUM_LIT:3> ] <EOL> solutions = [ ] <EOL> spectra = [ ] <EOL> filenames = [ ] <EOL> loop = <NUM_LIT:1> <EOL> iterationslist = range ( finaliterations ) <EOL> if save : <EOL> iterations_to_save = range ( <NUM_LIT:1> , finaliterations + <NUM_LIT:1> ) <EOL> str_tosave = [ ] <EOL> for x in iterations_to_save : <EOL> str_tosave . append ( str ( x ) ) <EOL> from os import system ; system ( "<STR_LIT>" ) <EOL> csvfilelabel = '<STR_LIT>' % N <EOL> csvfile = open ( '<STR_LIT>' % csvfilelabel , '<STR_LIT:a>' ) <EOL> csvfile . write ( '<STR_LIT>' + '<STR_LIT:U+002C>' . join ( str_tosave ) + '<STR_LIT:\n>' ) <EOL> csvfile . flush ( ) <EOL> for iterations in iterationslist : <EOL> solutions . append ( smooth ( A , <EOL> b , <EOL> np . zeros ( ( N , ) ) , <EOL> iterations ) <EOL> ) <EOL> if self . saveFig : <EOL> spectra . append ( fftpack . fft ( b - tools . flexibleMmult ( A , <EOL> solutions [ iterations ] <EOL> ) <EOL> ) <EOL> ) <EOL> if self . saveFig : <EOL> filebasename = '<STR_LIT>' % ( N , iterations ) <EOL> filename = filebasename + '<STR_LIT>' <EOL> solnax . set_ylim ( solnaxylim ) <EOL> solnax . set_autoscaley_on ( False ) <EOL> solnax . set_title ( filebasename + '<STR_LIT>' ) <EOL> solnax . plot ( solutions [ iterations ] ) <EOL> specax . set_yscale ( '<STR_LIT>' ) <EOL> specax . set_xscale ( spectralxscale ) <EOL> specax . set_ylim ( specaxylim ) <EOL> specax . set_autoscaley_on ( False ) <EOL> specax . set_title ( filebasename + '<STR_LIT>' ) <EOL> specax . plot ( spectra [ iterations ] ) <EOL> filename = '<STR_LIT>' + filebasename + '<STR_LIT>' <EOL> filenames . append ( filename ) <EOL> if self . saveFig : <EOL> print "<STR_LIT>" % ( loop , finaliterations ) + "<STR_LIT>" + filename <EOL> fig . savefig ( filename , dpi = <NUM_LIT> ) <EOL> solnax . cla ( ) <EOL> specax . cla ( ) <EOL> loop += <NUM_LIT:1> <EOL> frequencies = range ( len ( solutions [ <NUM_LIT:0> ] ) ) <EOL> for i in frequencies : <EOL> towrite = '<STR_LIT>' % frequencies [ i ] <EOL> for spectrum in spectra : <EOL> towrite += '<STR_LIT>' % abs ( spectrum [ i ] ) <EOL> if save : <EOL> csvfile . write ( towrite + '<STR_LIT:\n>' ) <EOL> csvfile . flush ( ) <EOL> if save : <EOL> csvfile . close ( ) <EOL> if self . saveFig : <EOL> torun = [ ] <EOL> torun . extend ( [ <EOL> '<STR_LIT>' + '<STR_LIT:U+0020>' . join ( filenames ) + '<STR_LIT>' % gif_output_name , <EOL> '<STR_LIT>' + '<STR_LIT:U+0020>' . join ( filenames ) , <EOL> '<STR_LIT>' % ( '<STR_LIT>' + gif_output_name ) , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' % gif_output_name , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' % ( gif_output_name , gif_output_name , gif_output_name ) , <EOL> ] ) <EOL> for command in torun : <EOL> system ( command ) <EOL> def multifreq_2d ( self , problemscale , finaliterations ) : <EOL> '''<STR_LIT>''' <EOL> if self . saveFig : <EOL> from scipy import fftpack <EOL> import matplotlib . pyplot as plt <EOL> from matplotlib import cm <EOL> from mpl_toolkits . mplot3d import Axes3D <EOL> NX = problemscale <EOL> floatNX = float ( NX ) <EOL> data = np . zeros ( ( NX , NX ) ) <EOL> domainwidths = [ floatNX , floatNX / <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> for domainwidth in domainwidths : <EOL> sininput = np . arange ( <NUM_LIT:0.0> , domainwidth , domainwidth / NX ) <EOL> xdata = ( np . sin ( sininput ) / domainwidth * <NUM_LIT> ) [ <NUM_LIT:0> : NX : ] <EOL> data = data + xdata [ : , np . newaxis ] + xdata [ : , np . newaxis ] . T <EOL> X = np . tile ( np . array ( range ( NX ) ) , ( NX , <NUM_LIT:1> ) ) <EOL> Y = X . T <EOL> if self . saveFig : <EOL> fig = plt . figure ( ) <EOL> ax = Axes3D ( fig ) <EOL> ax . set_zlim3d ( [ - <NUM_LIT:1> , <NUM_LIT:6> ] ) <EOL> specfig = plt . figure ( ) <EOL> specax = specfig . add_subplot ( <NUM_LIT> ) <EOL> specax . set_ylim ( [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> specax . set_autoscaley_on ( False ) <EOL> specax . set_xscale ( '<STR_LIT>' ) <EOL> A = operators . poisson ( ( NX , NX ) ) <EOL> solnforb = data . ravel ( ) . reshape ( ( NX ** <NUM_LIT:2> , <NUM_LIT:1> ) ) <EOL> b = tools . flexibleMmult ( A , solnforb ) <EOL> solutions = range ( finaliterations ) <EOL> spectra = range ( finaliterations ) <EOL> iterations = <NUM_LIT:0> <EOL> solutions [ iterations ] = np . zeros ( ( NX , NX ) ) . ravel ( ) <EOL> spectra [ iterations ] = b - tools . flexibleMmult ( A , solutions [ iterations ] ) <EOL> if self . saveFig : <EOL> filebasename = '<STR_LIT>' % ( NX ** <NUM_LIT:2> , iterations ) <EOL> filename = filebasename + '<STR_LIT>' <EOL> ax . set_title ( filebasename ) <EOL> surf = ax . plot_surface ( X , Y , data , cmap = cm . jet ) <EOL> if self . saveFig : fig . savefig ( filename ) <EOL> surf . remove ( ) <EOL> ax . cla ( ) <EOL> specax . plot ( spectra [ iterations ] ) <EOL> specax . set_title ( filebasename + '<STR_LIT>' ) <EOL> filename = filebasename + '<STR_LIT>' <EOL> if self . saveFig : specfig . savefig ( filename ) <EOL> del specax . lines [ <NUM_LIT:0> ] <EOL> specax . cla ( ) <EOL> verbose = False <EOL> for iterations in range ( <NUM_LIT:1> , finaliterations ) : <EOL> solutions [ iterations ] = smooth ( A , <EOL> b , <EOL> np . zeros ( NX ** <NUM_LIT:2> ) , <EOL> iterations , <EOL> verbose = verbose <EOL> ) . reshape ( NX , NX ) <EOL> if self . saveFig : <EOL> spectra [ iterations ] = fftpack . fft2 ( solutions [ iterations ] ) <EOL> if self . saveFig : <EOL> filebasename = '<STR_LIT>' % ( NX ** <NUM_LIT:2> , iterations ) <EOL> filename = filebasename + '<STR_LIT>' <EOL> ax . set_zlim3d ( [ - <NUM_LIT:1> , <NUM_LIT:6> ] ) <EOL> surf = ax . plot_surface ( X , Y , solutions [ iterations ] , cmap = cm . jet ) <EOL> ax . set_title ( filebasename ) <EOL> surf = ax . plot_wireframe ( X , Y , solutions [ iterations ] ) <EOL> if self . saveFig : fig . savefig ( filename ) <EOL> surf . remove ( ) <EOL> ax . cla ( ) <EOL> specax . set_yscale ( '<STR_LIT>' ) <EOL> specax . set_ylim ( [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> specax . set_autoscaley_on ( False ) <EOL> specax . set_xscale ( '<STR_LIT>' ) <EOL> specax . plot ( spectra [ iterations ] ) <EOL> specax . set_title ( filebasename + '<STR_LIT>' ) <EOL> filename = filebasename + '<STR_LIT>' <EOL> if self . saveFig : specfig . savefig ( filename ) <EOL> del specax . lines [ <NUM_LIT:0> ] <EOL> specax . cla ( ) <EOL> def test_gs_thresh ( self ) : <EOL> '''<STR_LIT>''' <EOL> NX = <NUM_LIT:12> <EOL> NY = NX <EOL> N = NX * NY <EOL> A = operators . poisson ( ( NX , NY , ) ) <EOL> b = np . random . random ( ( N , ) ) <EOL> x_init = np . zeros ( ( N , ) ) <EOL> threshold = <NUM_LIT> <EOL> verbose = False <EOL> x = smoothToThreshold ( A , b , x_init , <EOL> threshold , <EOL> verbose = verbose ) <EOL> if self . verbose : <EOL> print '<STR_LIT>' , ( np . linalg . norm ( tools . getresidual ( b , A , x , N ) ) ) <EOL> def test_gs_nothresh ( self ) : <EOL> '''<STR_LIT>''' <EOL> NX = N = <NUM_LIT:12> <EOL> A = operators . poisson ( ( NX , ) ) <EOL> b = np . random . random ( ( N , ) ) <EOL> x_init = np . zeros ( ( N , ) ) <EOL> x = gaussSeidel ( A , b , x_init , ) <EOL> def test_1d_noise_mg ( self , parameters = None ) : <EOL> '''<STR_LIT>''' <EOL> if parameters is None : <EOL> parameters = self . parameters <EOL> N = NX = parameters [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> u_actual = np . random . random ( ( NX , ) ) . reshape ( ( N , <NUM_LIT:1> ) ) <EOL> A_in = operators . poisson ( ( NX , ) ) <EOL> b = tools . flexibleMmult ( A_in , u_actual ) <EOL> u_mg , info_dict = mgSolve ( A_in , b , parameters ) <EOL> if self . verbose : <EOL> print '<STR_LIT>' , info_dict [ '<STR_LIT>' ] <EOL> def test_3d_noise_mg ( self ) : <EOL> '''<STR_LIT>''' <EOL> NX = NY = NZ = <NUM_LIT:8> <EOL> N = NX * NY * NZ <EOL> shape = NX , NY , NZ <EOL> u_actual = np . random . random ( shape ) . reshape ( ( N , <NUM_LIT:1> ) ) <EOL> A_in = operators . poisson ( shape ) <EOL> b = tools . flexibleMmult ( A_in , u_actual ) <EOL> u_mg , info_dict = mgSolve ( A_in , b , { <EOL> '<STR_LIT>' : shape , <EOL> '<STR_LIT>' : <NUM_LIT:3> , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : <NUM_LIT:4> , <EOL> '<STR_LIT>' : True , <EOL> } <EOL> ) <EOL> if self . verbose : <EOL> print '<STR_LIT>' , info_dict [ '<STR_LIT>' ] <EOL> def test_2d_noise_mg ( self ) : <EOL> '''<STR_LIT>''' <EOL> NX = <NUM_LIT:32> <EOL> NY = NX <EOL> N = NX * NY <EOL> u_actual = np . random . random ( ( NX , NY ) ) . reshape ( ( N , <NUM_LIT:1> ) ) <EOL> A_in = operators . poisson ( ( NX , NY ) ) <EOL> b = tools . flexibleMmult ( A_in , u_actual ) <EOL> u_mg , info_dict = mgSolve ( A_in , b , { <EOL> '<STR_LIT>' : ( NX , NY ) , <EOL> '<STR_LIT>' : <NUM_LIT:3> , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : <NUM_LIT:4> , <EOL> '<STR_LIT>' : True , <EOL> } <EOL> ) <EOL> if self . verbose : <EOL> print '<STR_LIT>' , info_dict [ '<STR_LIT>' ] <EOL> def test_2d_mpl_demo ( self ) : <EOL> '''<STR_LIT>''' <EOL> from mpl_toolkits . mplot3d import Axes3D <EOL> import matplotlib . pyplot as plt <EOL> sizemultiplier = <NUM_LIT:2> <EOL> NX = <NUM_LIT:8> * sizemultiplier <EOL> cycles = <NUM_LIT:3> <EOL> actualtraces = <NUM_LIT:8> <EOL> mgtraces = <NUM_LIT:16> <EOL> NY = NX <EOL> N = NX * NY <EOL> ( X , Y , u_actual ) = mpl_test_data ( delta = <NUM_LIT:1> / float ( sizemultiplier ) ) <EOL> A_in = operators . poisson ( ( NX , NY ) ) <EOL> b = tools . flexibleMmult ( A_in , u_actual . ravel ( ) ) <EOL> u_mg = mgSolve ( A_in , b , { <EOL> '<STR_LIT>' : ( NX , NY ) , <EOL> '<STR_LIT>' : <NUM_LIT:2> , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : True <EOL> } <EOL> ) <EOL> fig = plt . figure ( ) <EOL> ax = Axes3D ( fig ) <EOL> fig . suptitle ( '<STR_LIT>' % ( cycles , N ) ) <EOL> ax . plot_wireframe ( X , Y , u_actual , <EOL> rstride = NX / actualtraces , <EOL> cstride = NY / actualtraces , <EOL> color = ( ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1.0> ) , ) <EOL> ) <EOL> ax . plot_wireframe ( X , Y , u_mg . reshape ( ( NX , NY ) ) , <EOL> rstride = NX / mgtraces , <EOL> cstride = NY / mgtraces , <EOL> color = ( ( <NUM_LIT:1.0> , <NUM_LIT:0> , <NUM_LIT:0> ) , ) <EOL> ) <EOL> filename = '<STR_LIT>' % ( cycles , N ) <EOL> if self . saveFig : fig . savefig ( filename ) <EOL> if self . verbose : <EOL> print '<STR_LIT>' , ( np . linalg . norm ( openmg . tools . getresidual ( b , A_in , u_mg [ <NUM_LIT:0> ] , N ) ) ) <EOL> def test_threshStop ( self ) : <EOL> size = <NUM_LIT> <EOL> u_actual = np . sin ( np . array ( range ( int ( size ) ) ) * <NUM_LIT> / size ) . T <EOL> A = operators . poisson ( ( size , ) ) <EOL> b = tools . flexibleMmult ( A , u_actual ) <EOL> parameters = { <EOL> '<STR_LIT>' : ( size , ) , <EOL> '<STR_LIT>' : <NUM_LIT:2> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : True , <EOL> } <EOL> u_mmg , info_dict = mgSolve ( A , b , parameters ) <EOL> residual_norm = np . linalg . norm ( tools . flexibleMmult ( A , u_mmg ) - b ) <EOL> assert parameters [ '<STR_LIT>' ] > residual_norm <EOL> def test_cycleStop ( self ) : <EOL> size = <NUM_LIT> <EOL> u_actual = np . sin ( np . array ( range ( int ( size ) ) ) * <NUM_LIT> / size ) . T <EOL> A = operators . poisson ( ( size , ) ) <EOL> b = tools . flexibleMmult ( A , u_actual ) <EOL> parameters = { <EOL> '<STR_LIT>' : ( size , ) , <EOL> '<STR_LIT>' : <NUM_LIT:2> , <EOL> '<STR_LIT>' : <NUM_LIT:3> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : True , <EOL> } <EOL> u_mmg , info_dict = mgSolve ( A , b , parameters ) <EOL> residual_norm = np . linalg . norm ( tools . flexibleMmult ( A , u_mmg ) - b ) <EOL> assert info_dict [ '<STR_LIT>' ] == parameters [ '<STR_LIT>' ] <EOL> def test_poisson4d ( self ) : <EOL> def testor ( ) : <EOL> operators . poisson ( ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ) ) <EOL> self . assertRaises ( ValueError , testor ) <EOL> def test_123DRestriction ( self ) : <EOL> for dense in True , False : <EOL> R = [ operators . restriction ( tuple ( <EOL> [ <NUM_LIT:4> for i in range ( alpha ) ] <EOL> ) , dense = dense ) for alpha in range ( <NUM_LIT:1> , <NUM_LIT:4> ) ] <EOL> def test_4DRestriction ( self ) : <EOL> for dense in True , False : <EOL> def testor ( ) : <EOL> R = operators . restriction ( ( <NUM_LIT:4> , <NUM_LIT:4> , <NUM_LIT:4> , <NUM_LIT:4> ) , dense = dense ) <EOL> self . assertRaises ( ValueError , testor ) <EOL> def test_neitherStopValueError ( self ) : <EOL> parameters = self . parameters . copy ( ) <EOL> parameters [ "<STR_LIT>" ] = <NUM_LIT:0> <EOL> parameters [ "<STR_LIT>" ] = <NUM_LIT:0> <EOL> def testor ( ) : <EOL> self . test_1d_noise_mg ( parameters = parameters ) <EOL> self . assertRaises ( ValueError , testor ) <EOL> def test_minSize ( self ) : <EOL> parameters = self . parameters . copy ( ) <EOL> shape = parameters [ "<STR_LIT>" ] = ( <NUM_LIT> , ) <EOL> parameters [ "<STR_LIT>" ] = <NUM_LIT> <EOL> parameters [ "<STR_LIT>" ] = <NUM_LIT> <EOL> u_actual = np . random . random ( shape ) . ravel ( ) <EOL> A_in = operators . poisson ( shape ) <EOL> b = tools . flexibleMmult ( A_in , u_actual ) <EOL> soln , info_dict = mgSolve ( A_in , b , parameters ) <EOL> if self . verbose : <EOL> print "<STR_LIT>" , [ r . shape for r in info_dict [ '<STR_LIT:R>' ] ] <EOL> print "<STR_LIT>" , parameters [ '<STR_LIT>' ] <EOL> assert min ( info_dict [ '<STR_LIT:R>' ] [ - <NUM_LIT:1> ] . shape ) > parameters [ "<STR_LIT>" ] <EOL> def doTests ( ) : <EOL> suite = unittest . TestLoader ( ) . loadTestsFromTestCase ( TestOpenMG ) <EOL> unittest . TextTestRunner ( verbosity = <NUM_LIT:2> ) . run ( suite ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> doTests ( ) </s>
