<s> import pymatbridge as pymat <EOL> import numpy . testing as npt <EOL> import test_utils as tu <EOL> class TestGetVariable : <EOL> @ classmethod <EOL> def setup_class ( cls ) : <EOL> cls . mlab = tu . connect_to_matlab ( ) <EOL> @ classmethod <EOL> def teardown_class ( cls ) : <EOL> tu . stop_matlab ( cls . mlab ) <EOL> def test_get_float ( self ) : <EOL> self . mlab . run_code ( "<STR_LIT>" ) <EOL> self . mlab . run_code ( "<STR_LIT>" ) <EOL> npt . assert_equal ( self . mlab . get_variable ( '<STR_LIT:a>' ) , <NUM_LIT> ) <EOL> npt . assert_equal ( self . mlab . get_variable ( '<STR_LIT:b>' ) , <NUM_LIT> ) <EOL> def test_get_array ( self ) : <EOL> self . mlab . run_code ( "<STR_LIT>" ) <EOL> self . mlab . run_code ( "<STR_LIT>" ) <EOL> npt . assert_equal ( self . mlab . get_variable ( '<STR_LIT:a>' ) , [ [ <NUM_LIT:1.> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ] ) <EOL> npt . assert_equal ( self . mlab . get_variable ( '<STR_LIT:b>' ) , [ [ <NUM_LIT:1.> , <NUM_LIT> ] , [ <NUM_LIT> , <NUM_LIT> ] ] ) <EOL> def test_nonexistent_var ( self ) : <EOL> self . mlab . run_code ( "<STR_LIT>" ) <EOL> npt . assert_equal ( self . mlab . get_variable ( '<STR_LIT:a>' ) , None ) <EOL> def test_nonexistent_var_default ( self ) : <EOL> self . mlab . run_code ( "<STR_LIT>" ) <EOL> npt . assert_equal ( self . mlab . get_variable ( '<STR_LIT:a>' , '<STR_LIT>' ) , '<STR_LIT>' ) </s>
