<s> """<STR_LIT>""" <EOL> import logging <EOL> import os . path <EOL> import tempfile <EOL> import shutil <EOL> import unittest <EOL> from openmdao . lib . datatypes . domain import read_plot3d_q , write_plot3d_q , read_plot3d_f , write_plot3d_f , read_plot3d_shape , write_plot3d_grid <EOL> from openmdao . lib . datatypes . domain . test . wedge import create_wedge_2d , create_wedge_3d <EOL> from openmdao . util . testutil import assert_raises <EOL> class TestCase ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> self . startdir = os . getcwd ( ) <EOL> self . tempdir = tempfile . mkdtemp ( prefix = '<STR_LIT>' ) <EOL> os . chdir ( self . tempdir ) <EOL> def tearDown ( self ) : <EOL> """<STR_LIT>""" <EOL> os . chdir ( self . startdir ) <EOL> if not os . environ . get ( '<STR_LIT>' , False ) : <EOL> try : <EOL> shutil . rmtree ( self . tempdir ) <EOL> except OSError : <EOL> pass <EOL> def test_q_3d ( self ) : <EOL> logging . debug ( '<STR_LIT>' ) <EOL> logging . debug ( '<STR_LIT>' ) <EOL> logger = logging . getLogger ( ) <EOL> wedge = create_wedge_3d ( ( <NUM_LIT:30> , <NUM_LIT:20> , <NUM_LIT:10> ) , <NUM_LIT> , <NUM_LIT:0.5> , <NUM_LIT> , <NUM_LIT> ) <EOL> write_plot3d_q ( wedge , '<STR_LIT>' , '<STR_LIT>' , logger = logger , <EOL> big_endian = True , unformatted = False ) <EOL> domain = read_plot3d_q ( '<STR_LIT>' , '<STR_LIT>' , logger = logger , <EOL> multiblock = False , big_endian = True , <EOL> unformatted = False ) <EOL> self . assertFalse ( domain . is_equivalent ( wedge , logger = logger ) ) <EOL> domain . rename_zone ( '<STR_LIT>' , domain . zone_1 ) <EOL> self . assertTrue ( domain . is_equivalent ( wedge , logger = logger ) ) <EOL> write_plot3d_q ( domain , '<STR_LIT>' , '<STR_LIT>' , <EOL> logger = logger ) <EOL> domain = read_plot3d_q ( '<STR_LIT>' , '<STR_LIT>' , <EOL> logger = logger , multiblock = False ) <EOL> self . assertFalse ( domain . is_equivalent ( wedge , logger = logger ) ) <EOL> domain . rename_zone ( '<STR_LIT>' , domain . zone_1 ) <EOL> self . assertTrue ( domain . is_equivalent ( wedge , logger = logger ) ) <EOL> wedge2 = create_wedge_3d ( ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT:9> ) , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> domain . add_domain ( wedge2 ) <EOL> write_plot3d_q ( domain , '<STR_LIT>' , '<STR_LIT>' , <EOL> logger = logger ) <EOL> domain = read_plot3d_q ( '<STR_LIT>' , '<STR_LIT>' , <EOL> logger = logger ) <EOL> shape = read_plot3d_shape ( '<STR_LIT>' , logger = logger ) <EOL> self . assertEqual ( shape , [ ( <NUM_LIT:30> , <NUM_LIT:20> , <NUM_LIT:10> ) , ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT:9> ) ] ) <EOL> try : <EOL> read_plot3d_q ( '<STR_LIT>' , '<STR_LIT>' , blanking = True , <EOL> logger = logger , multiblock = False ) <EOL> except NotImplementedError as exc : <EOL> self . assertEqual ( str ( exc ) , '<STR_LIT>' ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> try : <EOL> read_plot3d_q ( '<STR_LIT>' , '<STR_LIT>' , planes = True , <EOL> logger = logger , multiblock = False ) <EOL> except NotImplementedError as exc : <EOL> self . assertEqual ( str ( exc ) , '<STR_LIT>' ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> assert_raises ( self , "<STR_LIT>" , <EOL> globals ( ) , locals ( ) , TypeError , <EOL> "<STR_LIT>" ) <EOL> assert_raises ( self , "<STR_LIT>" , <EOL> globals ( ) , locals ( ) , TypeError , <EOL> "<STR_LIT>" ) <EOL> assert_raises ( self , "<STR_LIT>" , <EOL> globals ( ) , locals ( ) , TypeError , <EOL> "<STR_LIT>" ) <EOL> wedge = create_wedge_3d ( ( <NUM_LIT:30> , <NUM_LIT:20> , <NUM_LIT:10> ) , <NUM_LIT> , <NUM_LIT:0.5> , <NUM_LIT> , <NUM_LIT> ) <EOL> delattr ( wedge . xyzzy . flow_solution , '<STR_LIT>' ) <EOL> assert_raises ( self , "<STR_LIT>" , <EOL> globals ( ) , locals ( ) , AttributeError , <EOL> "<STR_LIT>" ) <EOL> assert_raises ( self , "<STR_LIT>" , <EOL> globals ( ) , locals ( ) , AttributeError , <EOL> "<STR_LIT>" ) <EOL> def test_q_2d ( self ) : <EOL> logging . debug ( '<STR_LIT>' ) <EOL> logging . debug ( '<STR_LIT>' ) <EOL> logger = logging . getLogger ( ) <EOL> wedge = create_wedge_2d ( ( <NUM_LIT:20> , <NUM_LIT:10> ) , <NUM_LIT:0.5> , <NUM_LIT> , <NUM_LIT> ) <EOL> write_plot3d_q ( wedge , '<STR_LIT>' , '<STR_LIT>' , logger = logger , <EOL> big_endian = True , unformatted = False ) <EOL> domain = read_plot3d_q ( '<STR_LIT>' , '<STR_LIT>' , logger = logger , <EOL> dim = <NUM_LIT:2> , multiblock = False , big_endian = True , <EOL> unformatted = False ) <EOL> self . assertFalse ( domain . is_equivalent ( wedge , logger = logger ) ) <EOL> domain . rename_zone ( '<STR_LIT>' , domain . zone_1 ) <EOL> self . assertTrue ( domain . is_equivalent ( wedge , logger = logger ) ) <EOL> write_plot3d_q ( domain , '<STR_LIT>' , '<STR_LIT>' , <EOL> logger = logger ) <EOL> domain = read_plot3d_q ( '<STR_LIT>' , '<STR_LIT>' , <EOL> logger = logger , dim = <NUM_LIT:2> , multiblock = False ) <EOL> self . assertFalse ( domain . is_equivalent ( wedge , logger = logger ) ) <EOL> domain . rename_zone ( '<STR_LIT>' , domain . zone_1 ) <EOL> self . assertTrue ( domain . is_equivalent ( wedge , logger = logger ) ) <EOL> def test_f_3d ( self ) : <EOL> logging . debug ( '<STR_LIT>' ) <EOL> logging . debug ( '<STR_LIT>' ) <EOL> logger = logging . getLogger ( ) <EOL> wedge = create_wedge_3d ( ( <NUM_LIT:30> , <NUM_LIT:20> , <NUM_LIT:10> ) , <NUM_LIT> , <NUM_LIT:0.5> , <NUM_LIT> , <NUM_LIT> ) <EOL> wedge_flow = wedge . xyzzy . flow_solution <EOL> varnames = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> write_plot3d_f ( wedge , '<STR_LIT>' , '<STR_LIT>' , varnames , <EOL> logger = logger , big_endian = True , unformatted = False ) <EOL> domain = read_plot3d_f ( '<STR_LIT>' , '<STR_LIT>' , logger = logger , <EOL> multiblock = False , big_endian = True , <EOL> unformatted = False ) <EOL> test_flow = domain . zone_1 . flow_solution <EOL> self . assertTrue ( ( test_flow . f_1 == wedge_flow . density ) . all ( ) ) <EOL> self . assertTrue ( ( test_flow . f_2 == wedge_flow . momentum . x ) . all ( ) ) <EOL> self . assertTrue ( ( test_flow . f_3 == wedge_flow . momentum . y ) . all ( ) ) <EOL> self . assertTrue ( ( test_flow . f_4 == wedge_flow . momentum . z ) . all ( ) ) <EOL> self . assertTrue ( ( test_flow . f_5 == wedge_flow . energy_stagnation_density ) . all ( ) ) <EOL> write_plot3d_f ( domain , '<STR_LIT>' , '<STR_LIT>' , <EOL> logger = logger ) <EOL> domain = read_plot3d_f ( '<STR_LIT>' , '<STR_LIT>' , <EOL> logger = logger , multiblock = False ) <EOL> test_flow = domain . zone_1 . flow_solution <EOL> self . assertTrue ( ( test_flow . f_1 == wedge_flow . density ) . all ( ) ) <EOL> self . assertTrue ( ( test_flow . f_2 == wedge_flow . momentum . x ) . all ( ) ) <EOL> self . assertTrue ( ( test_flow . f_3 == wedge_flow . momentum . y ) . all ( ) ) <EOL> self . assertTrue ( ( test_flow . f_4 == wedge_flow . momentum . z ) . all ( ) ) <EOL> self . assertTrue ( ( test_flow . f_5 == wedge_flow . energy_stagnation_density ) . all ( ) ) <EOL> def test_f_2d ( self ) : <EOL> logging . debug ( '<STR_LIT>' ) <EOL> logging . debug ( '<STR_LIT>' ) <EOL> logger = logging . getLogger ( ) <EOL> wedge = create_wedge_2d ( ( <NUM_LIT:20> , <NUM_LIT:10> ) , <NUM_LIT:0.5> , <NUM_LIT> , <NUM_LIT> ) <EOL> wedge_flow = wedge . xyzzy . flow_solution <EOL> varnames = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> write_plot3d_f ( wedge , '<STR_LIT>' , '<STR_LIT>' , varnames , <EOL> logger = logger , big_endian = True , unformatted = False ) <EOL> domain = read_plot3d_f ( '<STR_LIT>' , '<STR_LIT>' , logger = logger , <EOL> dim = <NUM_LIT:2> , multiblock = False , big_endian = True , <EOL> unformatted = False ) <EOL> test_flow = domain . zone_1 . flow_solution <EOL> self . assertTrue ( ( test_flow . f_1 == wedge_flow . density ) . all ( ) ) <EOL> self . assertTrue ( ( test_flow . f_2 == wedge_flow . momentum . x ) . all ( ) ) <EOL> self . assertTrue ( ( test_flow . f_3 == wedge_flow . momentum . y ) . all ( ) ) <EOL> self . assertTrue ( ( test_flow . f_4 == wedge_flow . energy_stagnation_density ) . all ( ) ) <EOL> write_plot3d_f ( domain , '<STR_LIT>' , '<STR_LIT>' , <EOL> logger = logger ) <EOL> varnames = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> domain = read_plot3d_f ( '<STR_LIT>' , '<STR_LIT>' , varnames , <EOL> logger = logger , dim = <NUM_LIT:2> , multiblock = False ) <EOL> test_flow = domain . zone_1 . flow_solution <EOL> self . assertTrue ( ( test_flow . density == wedge_flow . density ) . all ( ) ) <EOL> self . assertTrue ( ( test_flow . momentum_x == wedge_flow . momentum . x ) . all ( ) ) <EOL> self . assertTrue ( ( test_flow . f_3 == wedge_flow . momentum . y ) . all ( ) ) <EOL> self . assertTrue ( ( test_flow . f_4 == wedge_flow . energy_stagnation_density ) . all ( ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> import nose <EOL> import sys <EOL> sys . argv . append ( '<STR_LIT>' ) <EOL> sys . argv . append ( '<STR_LIT>' ) <EOL> nose . runmodule ( ) </s>
