<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> import numpy as np <EOL> from openmdao . api import Group , ParallelGroup , Problem , IndepVarComp , LinearGaussSeidel <EOL> from openmdao . core . mpi_wrap import MPI <EOL> from openmdao . test . mpi_util import MPITestCase <EOL> from openmdao . test . simple_comps import FanOutGrouped , FanInGrouped , FanOut3Grouped <EOL> from openmdao . test . exec_comp_for_test import ExecComp4Test <EOL> from openmdao . test . util import assert_rel_error <EOL> if MPI : <EOL> from openmdao . core . petsc_impl import PetscImpl as impl <EOL> else : <EOL> from openmdao . core . basic_impl import BasicImpl as impl <EOL> class MatMatTestCase ( MPITestCase ) : <EOL> N_PROCS = <NUM_LIT:2> <EOL> def test_fan_in_serial_sets_rev ( self ) : <EOL> prob = Problem ( impl = impl ) <EOL> prob . root = FanInGrouped ( ) <EOL> prob . root . ln_solver = LinearGaussSeidel ( ) <EOL> prob . root . sub . ln_solver = LinearGaussSeidel ( ) <EOL> prob . root . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> prob . root . sub . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> prob . driver . add_desvar ( '<STR_LIT>' ) <EOL> prob . driver . add_desvar ( '<STR_LIT>' ) <EOL> prob . driver . add_objective ( '<STR_LIT>' ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> indep_list = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> unknown_list = [ '<STR_LIT>' ] <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_fan_in_serial_sets_fwd ( self ) : <EOL> prob = Problem ( impl = impl ) <EOL> prob . root = FanInGrouped ( ) <EOL> prob . root . ln_solver = LinearGaussSeidel ( ) <EOL> prob . root . sub . ln_solver = LinearGaussSeidel ( ) <EOL> prob . root . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> prob . root . sub . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> prob . driver . add_desvar ( '<STR_LIT>' ) <EOL> prob . driver . add_desvar ( '<STR_LIT>' ) <EOL> prob . driver . add_objective ( '<STR_LIT>' ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> indep_list = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> unknown_list = [ '<STR_LIT>' ] <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_fan_out_serial_sets_fwd ( self ) : <EOL> prob = Problem ( impl = impl ) <EOL> prob . root = FanOutGrouped ( ) <EOL> prob . root . ln_solver = LinearGaussSeidel ( ) <EOL> prob . root . sub . ln_solver = LinearGaussSeidel ( ) <EOL> prob . root . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> prob . root . sub . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> prob . driver . add_desvar ( '<STR_LIT>' ) <EOL> prob . driver . add_constraint ( '<STR_LIT>' , upper = <NUM_LIT:0.0> ) <EOL> prob . driver . add_constraint ( '<STR_LIT>' , upper = <NUM_LIT:0.0> ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> unknown_list = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> indep_list = [ '<STR_LIT>' ] <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_fan_out_serial_sets_rev ( self ) : <EOL> prob = Problem ( impl = impl ) <EOL> prob . root = FanOutGrouped ( ) <EOL> prob . root . ln_solver = LinearGaussSeidel ( ) <EOL> prob . root . sub . ln_solver = LinearGaussSeidel ( ) <EOL> prob . root . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> prob . root . sub . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> prob . driver . add_desvar ( '<STR_LIT>' ) <EOL> prob . driver . add_constraint ( '<STR_LIT>' , upper = <NUM_LIT:0.0> ) <EOL> prob . driver . add_constraint ( '<STR_LIT>' , upper = <NUM_LIT:0.0> ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> unknown_list = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> indep_list = [ '<STR_LIT>' ] <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_fan_in_parallel_sets_fwd ( self ) : <EOL> prob = Problem ( impl = impl ) <EOL> prob . root = FanInGrouped ( ) <EOL> prob . root . ln_solver = LinearGaussSeidel ( ) <EOL> prob . root . sub . ln_solver = LinearGaussSeidel ( ) <EOL> prob . root . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> prob . root . sub . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> prob . driver . add_desvar ( '<STR_LIT>' ) <EOL> prob . driver . add_desvar ( '<STR_LIT>' ) <EOL> prob . driver . add_desvar ( '<STR_LIT>' ) <EOL> prob . driver . add_objective ( '<STR_LIT>' ) <EOL> try : <EOL> prob . driver . parallel_derivs ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> except Exception as err : <EOL> self . assertEqual ( str ( err ) , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> else : <EOL> self . fail ( "<STR_LIT>" ) <EOL> prob . driver . parallel_derivs ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> if MPI : <EOL> expected = [ ( '<STR_LIT>' , '<STR_LIT>' ) , ( '<STR_LIT>' , ) ] <EOL> else : <EOL> expected = [ ( '<STR_LIT>' , ) , ( '<STR_LIT>' , ) , ( '<STR_LIT>' , ) ] <EOL> self . assertEqual ( prob . driver . desvars_of_interest ( ) , <EOL> expected ) <EOL> if MPI : <EOL> try : <EOL> prob . driver . parallel_derivs ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> except Exception as err : <EOL> self . assertEqual ( str ( err ) , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> else : <EOL> self . fail ( "<STR_LIT>" ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> indep_list = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> unknown_list = [ '<STR_LIT>' ] <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_fan_in_parallel_sets_rev ( self ) : <EOL> prob = Problem ( impl = impl ) <EOL> prob . root = FanInGrouped ( ) <EOL> prob . root . ln_solver = LinearGaussSeidel ( ) <EOL> prob . root . sub . ln_solver = LinearGaussSeidel ( ) <EOL> prob . root . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> prob . root . sub . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> prob . driver . add_desvar ( '<STR_LIT>' ) <EOL> prob . driver . add_desvar ( '<STR_LIT>' ) <EOL> prob . driver . add_desvar ( '<STR_LIT>' ) <EOL> prob . driver . add_objective ( '<STR_LIT>' ) <EOL> prob . driver . parallel_derivs ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> if MPI : <EOL> expected = [ ( '<STR_LIT>' , '<STR_LIT>' ) , ( '<STR_LIT>' , ) ] <EOL> else : <EOL> expected = [ ( '<STR_LIT>' , ) , ( '<STR_LIT>' , ) , ( '<STR_LIT>' , ) ] <EOL> self . assertEqual ( prob . driver . desvars_of_interest ( ) , <EOL> expected ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> indep_list = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> unknown_list = [ '<STR_LIT>' ] <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_fan_out_parallel_sets_fwd ( self ) : <EOL> prob = Problem ( impl = impl ) <EOL> prob . root = FanOutGrouped ( ) <EOL> prob . root . ln_solver = LinearGaussSeidel ( ) <EOL> prob . root . sub . ln_solver = LinearGaussSeidel ( ) <EOL> prob . root . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> prob . root . sub . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> prob . driver . add_desvar ( '<STR_LIT>' ) <EOL> prob . driver . add_constraint ( '<STR_LIT>' , upper = <NUM_LIT:0.0> ) <EOL> prob . driver . add_constraint ( '<STR_LIT>' , upper = <NUM_LIT:0.0> ) <EOL> prob . driver . parallel_derivs ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> if MPI : <EOL> expected = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> else : <EOL> expected = [ ( '<STR_LIT>' , ) , ( '<STR_LIT>' , ) ] <EOL> self . assertEqual ( prob . driver . outputs_of_interest ( ) , <EOL> expected ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> unknown_list = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> indep_list = [ '<STR_LIT>' ] <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_fan_out_parallel_sets_rev ( self ) : <EOL> prob = Problem ( impl = impl ) <EOL> prob . root = FanOutGrouped ( ) <EOL> prob . root . ln_solver = LinearGaussSeidel ( ) <EOL> prob . root . sub . ln_solver = LinearGaussSeidel ( ) <EOL> prob . root . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> prob . root . sub . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> prob . driver . add_desvar ( '<STR_LIT>' ) <EOL> prob . driver . add_constraint ( '<STR_LIT>' , upper = <NUM_LIT:0.0> ) <EOL> prob . driver . add_constraint ( '<STR_LIT>' , upper = <NUM_LIT:0.0> ) <EOL> prob . driver . parallel_derivs ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> if MPI : <EOL> expected = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> else : <EOL> expected = [ ( '<STR_LIT>' , ) , ( '<STR_LIT>' , ) ] <EOL> self . assertEqual ( prob . driver . outputs_of_interest ( ) , <EOL> expected ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> unknown_list = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> indep_list = [ '<STR_LIT>' ] <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> class ParDeriv3TestCase ( MPITestCase ) : <EOL> N_PROCS = <NUM_LIT:3> <EOL> def test_fan_out_parallel_sets ( self ) : <EOL> prob = Problem ( impl = impl ) <EOL> prob . root = FanOut3Grouped ( ) <EOL> prob . root . ln_solver = LinearGaussSeidel ( ) <EOL> prob . root . sub . ln_solver = LinearGaussSeidel ( ) <EOL> prob . root . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> prob . root . sub . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> prob . driver . add_desvar ( '<STR_LIT>' ) <EOL> prob . driver . add_constraint ( '<STR_LIT>' , upper = <NUM_LIT:0.0> ) <EOL> prob . driver . add_constraint ( '<STR_LIT>' , upper = <NUM_LIT:0.0> ) <EOL> prob . driver . add_constraint ( '<STR_LIT>' , upper = <NUM_LIT:0.0> ) <EOL> prob . driver . parallel_derivs ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> if MPI : <EOL> expected = [ ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> else : <EOL> expected = [ ( '<STR_LIT>' , ) , ( '<STR_LIT>' , ) , ( '<STR_LIT>' , ) ] <EOL> self . assertEqual ( prob . driver . outputs_of_interest ( ) , <EOL> expected ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> unknown_list = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> indep_list = [ '<STR_LIT>' ] <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> class MatMatIndicesTestCase ( MPITestCase ) : <EOL> N_PROCS = <NUM_LIT:2> <EOL> def setup_model ( self , mode ) : <EOL> asize = <NUM_LIT:3> <EOL> prob = Problem ( root = Group ( ) , impl = impl ) <EOL> root = prob . root <EOL> root . ln_solver = LinearGaussSeidel ( ) <EOL> root . ln_solver . options [ '<STR_LIT>' ] = mode <EOL> p = root . add ( '<STR_LIT:p>' , IndepVarComp ( '<STR_LIT:x>' , np . arange ( asize , dtype = float ) + <NUM_LIT:1.0> ) ) <EOL> G1 = root . add ( '<STR_LIT>' , ParallelGroup ( ) ) <EOL> G1 . ln_solver = LinearGaussSeidel ( ) <EOL> G1 . ln_solver . options [ '<STR_LIT>' ] = mode <EOL> c2 = G1 . add ( '<STR_LIT>' , ExecComp4Test ( '<STR_LIT>' , lin_delay = <NUM_LIT:1.0> , <EOL> x = np . zeros ( asize ) , y = np . zeros ( asize ) ) ) <EOL> c3 = G1 . add ( '<STR_LIT>' , ExecComp4Test ( '<STR_LIT>' , <EOL> lin_delay = <NUM_LIT:1.0> , <EOL> x = np . zeros ( asize ) , y = np . zeros ( asize ) ) ) <EOL> c4 = root . add ( '<STR_LIT>' , ExecComp4Test ( '<STR_LIT>' , <EOL> x = np . zeros ( asize ) , y = np . zeros ( asize ) ) ) <EOL> c5 = root . add ( '<STR_LIT>' , ExecComp4Test ( '<STR_LIT>' , <EOL> x = np . zeros ( asize ) , y = np . zeros ( asize ) ) ) <EOL> prob . driver . add_desvar ( '<STR_LIT>' , indices = [ <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> prob . driver . add_constraint ( '<STR_LIT>' , upper = <NUM_LIT:0.0> , indices = [ <NUM_LIT:1> ] ) <EOL> prob . driver . add_constraint ( '<STR_LIT>' , upper = <NUM_LIT:0.0> , indices = [ <NUM_LIT:2> ] ) <EOL> prob . driver . parallel_derivs ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> return prob <EOL> def test_indices_fwd ( self ) : <EOL> prob = self . setup_model ( '<STR_LIT>' ) <EOL> J = prob . calc_gradient ( [ '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] , np . array ( [ <NUM_LIT> , <NUM_LIT> ] ) , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] , np . array ( [ <NUM_LIT> , <NUM_LIT:0.> ] ) , <NUM_LIT> ) <EOL> def test_indices_rev ( self ) : <EOL> prob = self . setup_model ( '<STR_LIT>' ) <EOL> J = prob . calc_gradient ( [ '<STR_LIT>' ] , [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] , np . array ( [ <NUM_LIT> , <NUM_LIT> ] ) , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] , np . array ( [ <NUM_LIT> , <NUM_LIT:0.> ] ) , <NUM_LIT> ) <EOL> class IndicesTestCase2 ( MPITestCase ) : <EOL> N_PROCS = <NUM_LIT:2> <EOL> def setup_model ( self , mode ) : <EOL> asize = <NUM_LIT:3> <EOL> prob = Problem ( root = Group ( ) , impl = impl ) <EOL> root = prob . root <EOL> root . ln_solver = LinearGaussSeidel ( ) <EOL> root . ln_solver . options [ '<STR_LIT>' ] = mode <EOL> G1 = root . add ( '<STR_LIT>' , ParallelGroup ( ) ) <EOL> G1 . ln_solver . options [ '<STR_LIT>' ] = mode <EOL> par1 = G1 . add ( '<STR_LIT>' , Group ( ) ) <EOL> par2 = G1 . add ( '<STR_LIT>' , Group ( ) ) <EOL> p1 = par1 . add ( '<STR_LIT:p>' , IndepVarComp ( '<STR_LIT:x>' , np . arange ( asize , dtype = float ) + <NUM_LIT:1.0> ) ) <EOL> p2 = par2 . add ( '<STR_LIT:p>' , IndepVarComp ( '<STR_LIT:x>' , np . arange ( asize , dtype = float ) + <NUM_LIT> ) ) <EOL> c2 = par1 . add ( '<STR_LIT>' , ExecComp4Test ( '<STR_LIT>' , lin_delay = <NUM_LIT:1.0> , <EOL> x = np . zeros ( asize ) , y = np . zeros ( asize ) ) ) <EOL> c3 = par2 . add ( '<STR_LIT>' , ExecComp4Test ( '<STR_LIT>' , <EOL> lin_delay = <NUM_LIT:1.0> , <EOL> x = np . zeros ( asize ) , y = np . zeros ( asize ) ) ) <EOL> c4 = par1 . add ( '<STR_LIT>' , ExecComp4Test ( '<STR_LIT>' , <EOL> x = np . zeros ( asize ) , y = np . zeros ( asize ) ) ) <EOL> c5 = par2 . add ( '<STR_LIT>' , ExecComp4Test ( '<STR_LIT>' , <EOL> x = np . zeros ( asize ) , y = np . zeros ( asize ) ) ) <EOL> prob . driver . add_desvar ( '<STR_LIT>' , indices = [ <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> prob . driver . add_desvar ( '<STR_LIT>' , indices = [ <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> prob . driver . add_constraint ( '<STR_LIT>' , upper = <NUM_LIT:0.0> , indices = [ <NUM_LIT:1> ] ) <EOL> prob . driver . add_constraint ( '<STR_LIT>' , upper = <NUM_LIT:0.0> , indices = [ <NUM_LIT:2> ] ) <EOL> prob . driver . parallel_derivs ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> return prob <EOL> def test_indices_fwd ( self ) : <EOL> prob = self . setup_model ( '<STR_LIT>' ) <EOL> J = prob . calc_gradient ( [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] , np . array ( [ <NUM_LIT> , <NUM_LIT> ] ) , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] , np . array ( [ <NUM_LIT> , <NUM_LIT:0.> ] ) , <NUM_LIT> ) <EOL> def test_indices_rev ( self ) : <EOL> prob = self . setup_model ( '<STR_LIT>' ) <EOL> J = prob . calc_gradient ( [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] , np . array ( [ <NUM_LIT> , <NUM_LIT> ] ) , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] , np . array ( [ <NUM_LIT> , <NUM_LIT:0.> ] ) , <NUM_LIT> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from openmdao . test . mpi_util import mpirun_tests <EOL> mpirun_tests ( ) </s>
