<s> """<STR_LIT>""" <EOL> from cStringIO import StringIO <EOL> from nose import SkipTest <EOL> import re <EOL> import unittest <EOL> from mock import Mock <EOL> from numpy import zeros , array , random <EOL> import numpy as np <EOL> from openmdao . lib . architectures . api import MDF , CO <EOL> from openmdao . lib . optproblems . api import UnitScalableProblem <EOL> import openmdao . main . derivatives <EOL> from openmdao . main . api import Component , VariableTree , ImplicitComponent , Assembly , set_as_top <EOL> from openmdao . main . datatypes . api import Array , Float , VarTree , Int <EOL> from openmdao . main . depgraph import simple_node_iter <EOL> from openmdao . main . test . simpledriver import SimpleDriver <EOL> from openmdao . test . execcomp import ExecCompWithDerivatives , ExecComp <EOL> from openmdao . util . testutil import assert_rel_error <EOL> class Tree2 ( VariableTree ) : <EOL> d1 = Array ( zeros ( ( <NUM_LIT:1> , <NUM_LIT:2> ) ) ) <EOL> class Tree1 ( VariableTree ) : <EOL> a1 = Float ( <NUM_LIT> ) <EOL> vt1 = VarTree ( Tree2 ( ) ) <EOL> class MyComp ( Component ) : <EOL> x1 = Float ( <NUM_LIT:0.0> , iotype = '<STR_LIT>' ) <EOL> x2 = Float ( <NUM_LIT:0.0> , iotype = '<STR_LIT>' ) <EOL> x3 = Array ( zeros ( ( <NUM_LIT:2> , <NUM_LIT:1> ) ) , iotype = '<STR_LIT>' ) <EOL> x4 = Array ( zeros ( ( <NUM_LIT:2> , <NUM_LIT:2> ) ) , iotype = '<STR_LIT>' ) <EOL> vt = VarTree ( Tree1 ( ) , iotype = '<STR_LIT>' ) <EOL> xx1 = Float ( <NUM_LIT:0.0> , iotype = '<STR_LIT>' ) <EOL> xx2 = Float ( <NUM_LIT:0.0> , iotype = '<STR_LIT>' ) <EOL> xx3 = Array ( zeros ( ( <NUM_LIT:2> , <NUM_LIT:1> ) ) , iotype = '<STR_LIT>' ) <EOL> xx4 = Array ( zeros ( ( <NUM_LIT:2> , <NUM_LIT:2> ) ) , iotype = '<STR_LIT>' ) <EOL> vvt = VarTree ( Tree1 ( ) , iotype = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def provideJ ( self ) : <EOL> """<STR_LIT>""" <EOL> self . J = array ( [ [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ] ) <EOL> return self . J <EOL> def list_deriv_vars ( self ) : <EOL> input_keys = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> output_keys = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> return input_keys , output_keys <EOL> class IntComp ( Component ) : <EOL> x = Float ( <NUM_LIT:0.0> , iotype = '<STR_LIT>' ) <EOL> x_ignore = Float ( <NUM_LIT:0.0> , iotype = '<STR_LIT>' , deriv_ignore = True ) <EOL> int_in = Int ( <NUM_LIT:0> , iotype = '<STR_LIT>' , deriv_ignore = True ) <EOL> int_out = Int ( <NUM_LIT:0> , iotype = '<STR_LIT>' , deriv_ignore = True ) <EOL> y = Float ( <NUM_LIT:0.0> , iotype = '<STR_LIT>' ) <EOL> y_ignore = Float ( <NUM_LIT:0.0> , iotype = '<STR_LIT>' , deriv_ignore = True ) <EOL> def execute ( self ) : <EOL> self . y = <NUM_LIT> * self . x <EOL> self . int_out = self . int_in <EOL> def list_deriv_vars ( self ) : <EOL> return ( '<STR_LIT:x>' , ) , ( '<STR_LIT:y>' , ) <EOL> def provideJ ( self ) : <EOL> return array ( [ [ <NUM_LIT> ] ] ) <EOL> class BadListDerivsComp ( Component ) : <EOL> x = Float ( iotype = '<STR_LIT>' ) <EOL> y = Float ( iotype = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> self . y = self . x * <NUM_LIT> <EOL> def list_deriv_vars ( self ) : <EOL> return [ '<STR_LIT:x>' , '<STR_LIT:y>' ] <EOL> def provideJ ( self ) : <EOL> return array ( [ [ <NUM_LIT> ] ] ) <EOL> class VarTreeDerivVarComp ( Component ) : <EOL> x = VarTree ( VariableTree ( ) , iotype = '<STR_LIT>' ) <EOL> y = Float ( iotype = '<STR_LIT>' ) <EOL> z = Float ( iotype = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> pass <EOL> def list_deriv_vars ( self ) : <EOL> return ( '<STR_LIT:x>' , '<STR_LIT:y>' ) , ( '<STR_LIT:z>' ) <EOL> def provideJ ( self ) : <EOL> return array ( [ [ <NUM_LIT> ] ] ) <EOL> class UndefinedDerivVarComp ( Component ) : <EOL> x = Float ( iotype = '<STR_LIT>' ) <EOL> y = Float ( iotype = '<STR_LIT>' ) <EOL> z = Float ( iotype = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> pass <EOL> def list_deriv_vars ( self ) : <EOL> return ( '<STR_LIT:x>' , '<STR_LIT:y>' , '<STR_LIT:w>' ) , ( '<STR_LIT:z>' ) <EOL> def provideJ ( self ) : <EOL> return array ( [ [ <NUM_LIT> ] ] ) <EOL> class UnflattenableDerivVarComp ( Component ) : <EOL> x = Int ( iotype = '<STR_LIT>' ) <EOL> y = Float ( iotype = '<STR_LIT>' ) <EOL> z = Float ( iotype = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> pass <EOL> def list_deriv_vars ( self ) : <EOL> return ( '<STR_LIT:x>' , '<STR_LIT:y>' ) , ( '<STR_LIT:z>' ) <EOL> def provideJ ( self ) : <EOL> return array ( [ [ <NUM_LIT> ] ] ) <EOL> class Paraboloid ( Component ) : <EOL> """<STR_LIT>""" <EOL> x = Float ( <NUM_LIT:0.0> , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> y = Float ( <NUM_LIT:0.0> , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> f_xy = Float ( iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> x = self . x <EOL> y = self . y <EOL> self . f_xy = ( x - <NUM_LIT> ) ** <NUM_LIT:2> + x * y + ( y + <NUM_LIT> ) ** <NUM_LIT:2> - <NUM_LIT> <EOL> def provideJ ( self ) : <EOL> """<STR_LIT>""" <EOL> df_dx = <NUM_LIT> * self . x - <NUM_LIT> + self . y <EOL> df_dy = <NUM_LIT> * self . y + <NUM_LIT> + self . x <EOL> self . J = array ( [ [ df_dx , df_dy ] ] ) <EOL> return self . J <EOL> def list_deriv_vars ( self ) : <EOL> input_keys = ( '<STR_LIT:x>' , '<STR_LIT:y>' ) <EOL> output_keys = ( '<STR_LIT>' , ) <EOL> return input_keys , output_keys <EOL> class ParaboloidNoDeriv ( Component ) : <EOL> """<STR_LIT>""" <EOL> x = Float ( <NUM_LIT:0.0> , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> y = Float ( <NUM_LIT:0.0> , iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> f_xy = Float ( iotype = '<STR_LIT>' , desc = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> x = self . x <EOL> y = self . y <EOL> self . f_xy = ( x - <NUM_LIT> ) ** <NUM_LIT:2> + x * y + ( y + <NUM_LIT> ) ** <NUM_LIT:2> - <NUM_LIT> <EOL> class SimpleComp ( Component ) : <EOL> x = Float ( <NUM_LIT> , iotype = '<STR_LIT>' ) <EOL> y = Float ( <NUM_LIT> , iotype = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> self . y = <NUM_LIT> * self . x <EOL> def provideJ ( self ) : <EOL> return array ( [ [ <NUM_LIT> ] ] ) <EOL> def list_deriv_vars ( self ) : <EOL> return ( '<STR_LIT:x>' , ) , ( '<STR_LIT:y>' , ) <EOL> class SimpleCompMissingDeriv ( Component ) : <EOL> x = Float ( <NUM_LIT> , iotype = '<STR_LIT>' ) <EOL> miss_in = Float ( <NUM_LIT> , iotype = '<STR_LIT>' ) <EOL> y = Float ( <NUM_LIT> , iotype = '<STR_LIT>' ) <EOL> miss_out = Float ( <NUM_LIT> , iotype = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> self . y = <NUM_LIT> * self . x <EOL> def provideJ ( self ) : <EOL> return array ( [ [ <NUM_LIT> ] ] ) <EOL> def list_deriv_vars ( self ) : <EOL> return ( '<STR_LIT:x>' , ) , ( '<STR_LIT:y>' , ) <EOL> class CompFoot ( Component ) : <EOL> """<STR_LIT>""" <EOL> x = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' , units = '<STR_LIT>' ) <EOL> y = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' , units = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> self . y = <NUM_LIT> * self . x <EOL> def provideJ ( self ) : <EOL> """<STR_LIT>""" <EOL> dy_dx = <NUM_LIT> <EOL> self . J = array ( [ [ dy_dx ] ] ) <EOL> return self . J <EOL> def list_deriv_vars ( self ) : <EOL> input_keys = ( '<STR_LIT:x>' , ) <EOL> output_keys = ( '<STR_LIT:y>' , ) <EOL> return input_keys , output_keys <EOL> class CompInch ( Component ) : <EOL> """<STR_LIT>""" <EOL> x = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' , units = '<STR_LIT>' ) <EOL> y = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' , units = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> self . y = <NUM_LIT> * self . x <EOL> def provideJ ( self ) : <EOL> """<STR_LIT>""" <EOL> dy_dx = <NUM_LIT> <EOL> self . J = array ( [ [ dy_dx ] ] ) <EOL> return self . J <EOL> def list_deriv_vars ( self ) : <EOL> input_keys = ( '<STR_LIT:x>' , ) <EOL> output_keys = ( '<STR_LIT:y>' , ) <EOL> return input_keys , output_keys <EOL> class CompDegC ( Component ) : <EOL> """<STR_LIT>""" <EOL> x = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' ) <EOL> y = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' , units = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> self . y = self . x <EOL> def provideJ ( self ) : <EOL> """<STR_LIT>""" <EOL> dy_dx = <NUM_LIT:1.0> <EOL> self . J = array ( [ [ dy_dx ] ] ) <EOL> return self . J <EOL> def list_deriv_vars ( self ) : <EOL> input_keys = ( '<STR_LIT:x>' , ) <EOL> output_keys = ( '<STR_LIT:y>' , ) <EOL> return input_keys , output_keys <EOL> class CompDegF ( Component ) : <EOL> """<STR_LIT>""" <EOL> x = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' , units = '<STR_LIT>' ) <EOL> y = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> self . y = self . x <EOL> def provideJ ( self ) : <EOL> """<STR_LIT>""" <EOL> dy_dx = <NUM_LIT:1.0> <EOL> self . J = array ( [ [ dy_dx ] ] ) <EOL> return self . J <EOL> def list_deriv_vars ( self ) : <EOL> input_keys = ( '<STR_LIT:x>' , ) <EOL> output_keys = ( '<STR_LIT:y>' , ) <EOL> return input_keys , output_keys <EOL> class ArrayComp1 ( Component ) : <EOL> '''<STR_LIT>''' <EOL> x = Array ( zeros ( [ <NUM_LIT:2> ] ) , iotype = '<STR_LIT>' ) <EOL> y = Array ( zeros ( [ <NUM_LIT:2> ] ) , iotype = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> self . y [ <NUM_LIT:0> ] = <NUM_LIT> * self . x [ <NUM_LIT:0> ] + <NUM_LIT> * self . x [ <NUM_LIT:1> ] <EOL> self . y [ <NUM_LIT:1> ] = <NUM_LIT> * self . x [ <NUM_LIT:0> ] - <NUM_LIT> * self . x [ <NUM_LIT:1> ] <EOL> def provideJ ( self ) : <EOL> """<STR_LIT>""" <EOL> dy1_dx1 = <NUM_LIT> <EOL> dy1_dx2 = <NUM_LIT> <EOL> dy2_dx1 = <NUM_LIT> <EOL> dy2_dx2 = - <NUM_LIT> <EOL> self . J = array ( [ [ dy1_dx1 , dy1_dx2 ] , [ dy2_dx1 , dy2_dx2 ] ] ) <EOL> return self . J <EOL> def list_deriv_vars ( self ) : <EOL> input_keys = ( '<STR_LIT:x>' , ) <EOL> output_keys = ( '<STR_LIT:y>' , ) <EOL> return input_keys , output_keys <EOL> class ArrayComp1_inch ( Component ) : <EOL> '''<STR_LIT>''' <EOL> x = Array ( zeros ( [ <NUM_LIT:2> ] ) , iotype = '<STR_LIT>' , units = "<STR_LIT>" ) <EOL> y = Array ( zeros ( [ <NUM_LIT:2> ] ) , iotype = '<STR_LIT>' , units = "<STR_LIT>" ) <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> self . y [ <NUM_LIT:0> ] = <NUM_LIT> * self . x [ <NUM_LIT:0> ] + <NUM_LIT> * self . x [ <NUM_LIT:1> ] <EOL> self . y [ <NUM_LIT:1> ] = <NUM_LIT> * self . x [ <NUM_LIT:0> ] - <NUM_LIT> * self . x [ <NUM_LIT:1> ] <EOL> def provideJ ( self ) : <EOL> """<STR_LIT>""" <EOL> dy1_dx1 = <NUM_LIT> <EOL> dy1_dx2 = <NUM_LIT> <EOL> dy2_dx1 = <NUM_LIT> <EOL> dy2_dx2 = - <NUM_LIT> <EOL> self . J = array ( [ [ dy1_dx1 , dy1_dx2 ] , [ dy2_dx1 , dy2_dx2 ] ] ) <EOL> return self . J <EOL> def list_deriv_vars ( self ) : <EOL> input_keys = ( '<STR_LIT:x>' , ) <EOL> output_keys = ( '<STR_LIT:y>' , ) <EOL> return input_keys , output_keys <EOL> class ArrayComp1_ft ( Component ) : <EOL> '''<STR_LIT>''' <EOL> x = Array ( zeros ( [ <NUM_LIT:2> ] ) , iotype = '<STR_LIT>' , units = "<STR_LIT>" ) <EOL> y = Array ( zeros ( [ <NUM_LIT:2> ] ) , iotype = '<STR_LIT>' , units = "<STR_LIT>" ) <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> self . y [ <NUM_LIT:0> ] = <NUM_LIT> * self . x [ <NUM_LIT:0> ] + <NUM_LIT> * self . x [ <NUM_LIT:1> ] <EOL> self . y [ <NUM_LIT:1> ] = <NUM_LIT> * self . x [ <NUM_LIT:0> ] - <NUM_LIT> * self . x [ <NUM_LIT:1> ] <EOL> def provideJ ( self ) : <EOL> """<STR_LIT>""" <EOL> dy1_dx1 = <NUM_LIT> <EOL> dy1_dx2 = <NUM_LIT> <EOL> dy2_dx1 = <NUM_LIT> <EOL> dy2_dx2 = - <NUM_LIT> <EOL> self . J = array ( [ [ dy1_dx1 , dy1_dx2 ] , [ dy2_dx1 , dy2_dx2 ] ] ) <EOL> return self . J <EOL> def list_deriv_vars ( self ) : <EOL> input_keys = ( '<STR_LIT:x>' , ) <EOL> output_keys = ( '<STR_LIT:y>' , ) <EOL> return input_keys , output_keys <EOL> class ArrayComp1_noderiv ( Component ) : <EOL> '''<STR_LIT>''' <EOL> x = Array ( zeros ( [ <NUM_LIT:2> ] ) , iotype = '<STR_LIT>' , low = - <NUM_LIT:100> , high = <NUM_LIT:100> ) <EOL> y = Array ( zeros ( [ <NUM_LIT:2> ] ) , iotype = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> self . y [ <NUM_LIT:0> ] = <NUM_LIT> * self . x [ <NUM_LIT:0> ] + <NUM_LIT> * self . x [ <NUM_LIT:1> ] <EOL> self . y [ <NUM_LIT:1> ] = <NUM_LIT> * self . x [ <NUM_LIT:0> ] - <NUM_LIT> * self . x [ <NUM_LIT:1> ] <EOL> class ArrayComp2D ( Component ) : <EOL> '''<STR_LIT>''' <EOL> x = Array ( zeros ( ( <NUM_LIT:2> , <NUM_LIT:2> ) ) , iotype = '<STR_LIT>' ) <EOL> y = Array ( zeros ( ( <NUM_LIT:2> , <NUM_LIT:2> ) ) , iotype = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> self . y [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] = <NUM_LIT> * self . x [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] + <NUM_LIT:1.0> * self . x [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] + <NUM_LIT> * self . x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] + <NUM_LIT> * self . x [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] <EOL> self . y [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] = <NUM_LIT> * self . x [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] + <NUM_LIT> * self . x [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] + <NUM_LIT> * self . x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] + <NUM_LIT> * self . x [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] <EOL> self . y [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] = <NUM_LIT> * self . x [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] + <NUM_LIT> * self . x [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] + <NUM_LIT> * self . x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] + <NUM_LIT> * self . x [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] <EOL> self . y [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] = <NUM_LIT:1.0> * self . x [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] + <NUM_LIT> * self . x [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] + <NUM_LIT> * self . x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] + <NUM_LIT> * self . x [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] <EOL> def provideJ ( self ) : <EOL> """<STR_LIT>""" <EOL> self . J = array ( [ [ <NUM_LIT> , <NUM_LIT:1.0> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:1.0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ] ) <EOL> return self . J <EOL> def list_deriv_vars ( self ) : <EOL> input_keys = ( '<STR_LIT:x>' , ) <EOL> output_keys = ( '<STR_LIT:y>' , ) <EOL> return input_keys , output_keys <EOL> class Array_Slice_1D ( Component ) : <EOL> '''<STR_LIT>''' <EOL> x = Array ( zeros ( ( <NUM_LIT:4> ) ) , iotype = '<STR_LIT>' ) <EOL> y = Array ( zeros ( ( <NUM_LIT:4> ) ) , iotype = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> self . y [ <NUM_LIT:0> ] = <NUM_LIT> * self . x [ <NUM_LIT:0> ] + <NUM_LIT:1.0> * self . x [ <NUM_LIT:1> ] + <NUM_LIT> * self . x [ <NUM_LIT:2> ] + <NUM_LIT> * self . x [ <NUM_LIT:3> ] <EOL> self . y [ <NUM_LIT:1> ] = <NUM_LIT> * self . x [ <NUM_LIT:0> ] + <NUM_LIT> * self . x [ <NUM_LIT:1> ] + <NUM_LIT> * self . x [ <NUM_LIT:2> ] + <NUM_LIT> * self . x [ <NUM_LIT:3> ] <EOL> self . y [ <NUM_LIT:2> ] = <NUM_LIT> * self . x [ <NUM_LIT:0> ] + <NUM_LIT> * self . x [ <NUM_LIT:1> ] + <NUM_LIT> * self . x [ <NUM_LIT:2> ] + <NUM_LIT> * self . x [ <NUM_LIT:3> ] <EOL> self . y [ <NUM_LIT:3> ] = <NUM_LIT:1.0> * self . x [ <NUM_LIT:0> ] + <NUM_LIT> * self . x [ <NUM_LIT:1> ] + <NUM_LIT> * self . x [ <NUM_LIT:2> ] + <NUM_LIT> * self . x [ <NUM_LIT:3> ] <EOL> def provideJ ( self ) : <EOL> """<STR_LIT>""" <EOL> self . J = array ( [ [ <NUM_LIT> , <NUM_LIT:1.0> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:1.0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ] ) <EOL> return self . J <EOL> def list_deriv_vars ( self ) : <EOL> input_keys = ( '<STR_LIT:x>' , ) <EOL> output_keys = ( '<STR_LIT:y>' , ) <EOL> return input_keys , output_keys <EOL> class ArrayComp2D_der ( Component ) : <EOL> '''<STR_LIT>''' <EOL> x = Array ( zeros ( ( <NUM_LIT:2> , <NUM_LIT:2> ) ) , iotype = '<STR_LIT>' ) <EOL> y = Array ( zeros ( ( <NUM_LIT:2> , <NUM_LIT:2> ) ) , iotype = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> self . y [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] = <NUM_LIT> * self . x [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] + <NUM_LIT:1.0> * self . x [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] + <NUM_LIT> * self . x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] + <NUM_LIT> * self . x [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] <EOL> self . y [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] = <NUM_LIT> * self . x [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] + <NUM_LIT> * self . x [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] + <NUM_LIT> * self . x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] + <NUM_LIT> * self . x [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] <EOL> self . y [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] = <NUM_LIT> * self . x [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] + <NUM_LIT> * self . x [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] + <NUM_LIT> * self . x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] + <NUM_LIT> * self . x [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] <EOL> self . y [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] = <NUM_LIT:1.0> * self . x [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] + <NUM_LIT> * self . x [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] + <NUM_LIT> * self . x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] + <NUM_LIT> * self . x [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] <EOL> def provideJ ( self ) : <EOL> """<STR_LIT>""" <EOL> self . J = array ( [ [ <NUM_LIT> , <NUM_LIT:1.0> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:1.0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ] ) <EOL> def list_deriv_vars ( self ) : <EOL> return ( '<STR_LIT:x>' , ) , ( '<STR_LIT:y>' , ) <EOL> def apply_deriv ( self , arg , result ) : <EOL> if '<STR_LIT:x>' in arg and '<STR_LIT:y>' in result : <EOL> dy = self . J . dot ( arg [ '<STR_LIT:x>' ] . flatten ( ) ) . reshape ( <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> result [ '<STR_LIT:y>' ] [ : ] += dy <EOL> def apply_derivT ( self , arg , result ) : <EOL> if '<STR_LIT:y>' in arg and '<STR_LIT:x>' in result : <EOL> dx = self . J . T . dot ( arg [ '<STR_LIT:y>' ] . flatten ( ) ) . reshape ( <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> result [ '<STR_LIT:x>' ] [ : ] = dx <EOL> class GComp_noD ( Component ) : <EOL> x1 = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' ) <EOL> x2 = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' ) <EOL> x3 = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' ) <EOL> y1 = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> self . y1 = <NUM_LIT> * self . x1 + <NUM_LIT> * self . x2 - <NUM_LIT> * self . x3 <EOL> class ABCDComp ( Component ) : <EOL> a = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' ) <EOL> b = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' , deriv_ignore = True ) <EOL> c = Float ( <NUM_LIT> , iotype = '<STR_LIT>' ) <EOL> d = Float ( <NUM_LIT:0.0> , iotype = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> self . c = self . a + self . b <EOL> self . d = self . a - self . b <EOL> def provideJ ( self ) : <EOL> return array ( [ [ <NUM_LIT:1.> , <NUM_LIT:1.> ] ] ) . transpose ( ) <EOL> def list_deriv_vars ( self ) : <EOL> return ( ( '<STR_LIT:a>' , ) , ( '<STR_LIT:c>' , '<STR_LIT:d>' ) ) <EOL> class ABCDintComp ( Component ) : <EOL> a = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' ) <EOL> b = Int ( <NUM_LIT:1> , iotype = '<STR_LIT>' ) <EOL> c = Float ( <NUM_LIT> , iotype = '<STR_LIT>' ) <EOL> d = Float ( <NUM_LIT:0.0> , iotype = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> self . c = self . a + self . b <EOL> self . d = self . a - self . b <EOL> def provideJ ( self ) : <EOL> return array ( [ [ <NUM_LIT:1.> , <NUM_LIT:1.> ] ] ) . transpose ( ) <EOL> def list_deriv_vars ( self ) : <EOL> return ( ( '<STR_LIT:a>' , ) , ( '<STR_LIT:c>' , '<STR_LIT:d>' ) ) <EOL> class Testcase_derivatives ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_bad_list_deriv_vars ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , BadListDerivsComp ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . comp1 . x = <NUM_LIT:1.0> <EOL> top . run ( ) <EOL> self . assertEqual ( top . comp1 . y , <NUM_LIT> ) <EOL> try : <EOL> J = top . driver . calc_gradient ( [ '<STR_LIT>' ] , [ '<STR_LIT>' ] ) <EOL> except Exception as err : <EOL> self . assertEqual ( str ( err ) , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def test_unflattenable_deriv_var ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , UnflattenableDerivVarComp ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . comp . x = <NUM_LIT:1> <EOL> top . comp . y = <NUM_LIT:1.0> <EOL> try : <EOL> top . run ( ) <EOL> except Exception as err : <EOL> msg = "<STR_LIT>" "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , msg ) <EOL> def test_vartree_deriv_var ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , VarTreeDerivVarComp ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> try : <EOL> top . run ( ) <EOL> except Exception as err : <EOL> msg = "<STR_LIT>" "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , msg ) <EOL> def test_undefined_deriv_var ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , UndefinedDerivVarComp ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . comp . x = <NUM_LIT:1.0> <EOL> top . comp . y = <NUM_LIT:1.0> <EOL> try : <EOL> top . run ( ) <EOL> except Exception as err : <EOL> msg = "<STR_LIT>" "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , msg ) <EOL> def test_int_ignore ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , IntComp ( ) ) <EOL> top . add ( '<STR_LIT>' , IntComp ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . comp1 . x = <NUM_LIT:1.0> <EOL> top . run ( ) <EOL> self . assertEqual ( top . comp2 . y , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( [ '<STR_LIT>' ] , [ '<STR_LIT>' ] ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_error_logging1 ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , Paraboloid ( ) ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:1000> , high = <NUM_LIT:1000> ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:1000> , high = <NUM_LIT:1000> ) <EOL> top . driver . add_objective ( '<STR_LIT>' ) <EOL> top . comp . x = <NUM_LIT:3> <EOL> top . comp . y = <NUM_LIT:5> <EOL> top . run ( ) <EOL> orig_gmres = openmdao . main . linearsolver . gmres <EOL> orig_logger = openmdao . main . linearsolver . logger <EOL> def my_gmres ( A , b , x0 = None , tol = <NUM_LIT> , restart = None , <EOL> maxiter = None , xtype = None , M = None , callback = None , restrt = None ) : <EOL> dx , info = orig_gmres ( A , b , x0 , tol , restart , maxiter , <EOL> xtype , M , callback , restrt ) <EOL> return dx , <NUM_LIT> <EOL> openmdao . main . linearsolver . gmres = my_gmres <EOL> openmdao . main . linearsolver . logger = mocklogger = Mock ( ) <EOL> try : <EOL> top . driver . calc_gradient ( outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> mocklogger . error . assert_called_with ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <NUM_LIT> ) <EOL> top . driver . calc_gradient ( outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> mocklogger . error . assert_called_with ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <NUM_LIT> ) <EOL> finally : <EOL> openmdao . main . linearsolver . gmres = orig_gmres <EOL> openmdao . main . linearsolver . logger = orig_logger <EOL> def test_provideJ ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , SimpleComp ( ) ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:1000> , high = <NUM_LIT:1000> ) <EOL> top . comp . x = <NUM_LIT> <EOL> top . comp . run ( ) <EOL> top . comp . x = <NUM_LIT> <EOL> top . comp . run ( ) <EOL> top . driver . calc_gradient ( outputs = [ '<STR_LIT>' ] ) <EOL> def test_non_2d_jacobian ( self ) : <EOL> comp = SimpleComp ( ) <EOL> comp . provideJ = lambda : np . array ( [ <NUM_LIT> ] ) <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , comp ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:1000> , high = <NUM_LIT:1000> ) <EOL> top . comp . x = <NUM_LIT> <EOL> try : <EOL> top . comp . run ( ) <EOL> top . driver . calc_gradient ( outputs = [ '<STR_LIT>' ] ) <EOL> except ValueError as err : <EOL> expected = "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , expected ) <EOL> else : <EOL> self . fail ( "<STR_LIT>" ) <EOL> def test_bad_sized_jacobian ( self ) : <EOL> comp = SimpleComp ( ) <EOL> comp . provideJ = lambda : np . array ( [ [ <NUM_LIT> , <NUM_LIT> ] ] ) <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , comp ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:1000> , high = <NUM_LIT:1000> ) <EOL> top . comp . x = <NUM_LIT> <EOL> try : <EOL> top . comp . run ( ) <EOL> top . driver . calc_gradient ( outputs = [ '<STR_LIT>' ] ) <EOL> except RuntimeError as err : <EOL> expected = "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , expected ) <EOL> else : <EOL> self . fail ( "<STR_LIT>" ) <EOL> def test_error_logging2 ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , Paraboloid ( ) ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:1000> , high = <NUM_LIT:1000> ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:1000> , high = <NUM_LIT:1000> ) <EOL> top . comp . x = <NUM_LIT:3> <EOL> top . comp . y = <NUM_LIT:5> <EOL> top . comp . run ( ) <EOL> orig_gmres = openmdao . main . linearsolver . gmres <EOL> orig_logger = openmdao . main . linearsolver . logger <EOL> def my_gmres ( A , b , x0 = None , tol = <NUM_LIT> , restart = None , <EOL> maxiter = None , xtype = None , M = None , callback = None , restrt = None ) : <EOL> dx , info = orig_gmres ( A , b , x0 , tol , restart , maxiter , <EOL> xtype , M , callback , restrt ) <EOL> return dx , - <NUM_LIT> <EOL> openmdao . main . linearsolver . gmres = my_gmres <EOL> openmdao . main . linearsolver . logger = mocklogger = Mock ( ) <EOL> try : <EOL> top . driver . calc_gradient ( outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> mocklogger . error . assert_called_with ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> top . driver . calc_gradient ( outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> mocklogger . error . assert_called_with ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> finally : <EOL> openmdao . main . derivatives . gmres = orig_gmres <EOL> openmdao . main . derivatives . logger = orig_logger <EOL> def test_single_comp ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , Paraboloid ( ) ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:1000> , high = <NUM_LIT:1000> ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:1000> , high = <NUM_LIT:1000> ) <EOL> top . driver . add_objective ( '<STR_LIT>' ) <EOL> top . comp . x = <NUM_LIT:3> <EOL> top . comp . y = <NUM_LIT:5> <EOL> top . run ( ) <EOL> self . assertEqual ( top . comp . f_xy , <NUM_LIT> ) <EOL> self . assertEqual ( top . _pseudo_0 . out0 , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_multi_non_relevant_path ( self ) : <EOL> self . top = set_as_top ( Assembly ( ) ) <EOL> exp1 = [ '<STR_LIT>' ] <EOL> deriv1 = [ '<STR_LIT>' ] <EOL> exp2 = [ '<STR_LIT>' ] <EOL> deriv2 = [ '<STR_LIT>' ] <EOL> exp3 = [ '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> deriv3 = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> exp4 = [ '<STR_LIT>' ] <EOL> deriv4 = [ '<STR_LIT>' ] <EOL> exp5 = [ '<STR_LIT>' ] <EOL> deriv5 = [ '<STR_LIT>' ] <EOL> self . top . add ( '<STR_LIT>' , ExecCompWithDerivatives ( exp1 , deriv1 ) ) <EOL> self . top . add ( '<STR_LIT>' , ExecCompWithDerivatives ( exp2 , deriv2 ) ) <EOL> self . top . add ( '<STR_LIT>' , ExecCompWithDerivatives ( exp3 , deriv3 ) ) <EOL> self . top . add ( '<STR_LIT>' , ExecCompWithDerivatives ( exp4 , deriv4 ) ) <EOL> self . top . add ( '<STR_LIT>' , ExecCompWithDerivatives ( exp5 , deriv5 ) ) <EOL> self . top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> self . top . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:100> , high = <NUM_LIT:100> ) <EOL> self . top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:100> , high = <NUM_LIT:100> ) <EOL> self . top . driver . add_constraint ( '<STR_LIT>' ) <EOL> self . top . driver . add_constraint ( '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . comp1 . x1 = <NUM_LIT> <EOL> self . top . comp2 . x1 = <NUM_LIT:1.0> <EOL> self . top . run ( ) <EOL> J = self . top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = self . top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = self . top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_multi_non_relevant_path_no_params_cnsts ( self ) : <EOL> self . top = set_as_top ( Assembly ( ) ) <EOL> exp1 = [ '<STR_LIT>' ] <EOL> deriv1 = [ '<STR_LIT>' ] <EOL> exp2 = [ '<STR_LIT>' ] <EOL> deriv2 = [ '<STR_LIT>' ] <EOL> exp3 = [ '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> deriv3 = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> exp4 = [ '<STR_LIT>' ] <EOL> deriv4 = [ '<STR_LIT>' ] <EOL> exp5 = [ '<STR_LIT>' ] <EOL> deriv5 = [ '<STR_LIT>' ] <EOL> self . top . add ( '<STR_LIT>' , ExecCompWithDerivatives ( exp1 , deriv1 ) ) <EOL> self . top . add ( '<STR_LIT>' , ExecCompWithDerivatives ( exp2 , deriv2 ) ) <EOL> self . top . add ( '<STR_LIT>' , ExecCompWithDerivatives ( exp3 , deriv3 ) ) <EOL> self . top . add ( '<STR_LIT>' , ExecCompWithDerivatives ( exp4 , deriv4 ) ) <EOL> self . top . add ( '<STR_LIT>' , ExecCompWithDerivatives ( exp5 , deriv5 ) ) <EOL> self . top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> self . top . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . comp1 . x1 = <NUM_LIT> <EOL> self . top . comp2 . x1 = <NUM_LIT:1.0> <EOL> self . top . run ( ) <EOL> J = self . top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = self . top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = self . top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_first_derivative ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , Paraboloid ( ) ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:1000> , high = <NUM_LIT:1000> ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:1000> , high = <NUM_LIT:1000> ) <EOL> top . driver . add_objective ( '<STR_LIT>' ) <EOL> top . comp . x = <NUM_LIT:3> <EOL> top . comp . y = <NUM_LIT:5> <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> expected = """<STR_LIT>""" <EOL> stream = StringIO ( ) <EOL> top . driver . check_gradient ( outputs = ( '<STR_LIT>' , ) , stream = stream ) <EOL> actual = stream . getvalue ( ) <EOL> if re . match ( expected , actual ) is None : <EOL> print '<STR_LIT>' % expected <EOL> print '<STR_LIT>' % actual <EOL> self . fail ( "<STR_LIT>" ) <EOL> stream = StringIO ( ) <EOL> top . check_gradient ( outputs = [ '<STR_LIT>' ] , stream = stream , <EOL> inputs = [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> actual = stream . getvalue ( ) <EOL> if re . match ( expected , actual ) is None : <EOL> print '<STR_LIT>' % expected <EOL> print '<STR_LIT>' % actual <EOL> self . fail ( "<STR_LIT>" ) <EOL> stream = StringIO ( ) <EOL> top . check_gradient ( inputs = ( '<STR_LIT>' , '<STR_LIT>' ) , outputs = ( '<STR_LIT>' , ) , <EOL> stream = stream ) <EOL> actual = stream . getvalue ( ) <EOL> if re . match ( expected , actual ) is None : <EOL> print '<STR_LIT>' % expected <EOL> print '<STR_LIT>' % actual <EOL> self . fail ( "<STR_LIT>" ) <EOL> stream = StringIO ( ) <EOL> top . check_gradient ( name = '<STR_LIT>' , outputs = [ '<STR_LIT>' ] , stream = stream , <EOL> inputs = [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> actual = stream . getvalue ( ) <EOL> if re . match ( expected , actual ) is None : <EOL> print '<STR_LIT>' % expected <EOL> print '<STR_LIT>' % actual <EOL> self . fail ( "<STR_LIT>" ) <EOL> stream = StringIO ( ) <EOL> top . check_gradient ( name = '<STR_LIT>' , stream = stream ) <EOL> actual = stream . getvalue ( ) <EOL> if re . match ( expected , actual ) is None : <EOL> print '<STR_LIT>' % expected <EOL> print '<STR_LIT>' % actual <EOL> self . fail ( "<STR_LIT>" ) <EOL> stream = StringIO ( ) <EOL> top . comp . check_gradient ( stream = stream ) <EOL> actual = stream . getvalue ( ) <EOL> if re . match ( expected , actual ) is None : <EOL> print '<STR_LIT>' % expected <EOL> print '<STR_LIT>' % actual <EOL> self . fail ( "<STR_LIT>" ) <EOL> stream = StringIO ( ) <EOL> comp = Paraboloid ( ) <EOL> comp . x = <NUM_LIT:3> <EOL> comp . y = <NUM_LIT:5> <EOL> Jbase , J , io_pairs , suspects = comp . check_gradient ( stream = stream ) <EOL> actual = stream . getvalue ( ) <EOL> if re . match ( expected , actual ) is None : <EOL> print '<STR_LIT>' % expected <EOL> print '<STR_LIT>' % actual <EOL> self . fail ( "<STR_LIT>" ) <EOL> Jbase , J , io_pairs , suspects = comp . check_gradient ( stream = stream ) <EOL> actual = stream . getvalue ( ) <EOL> if re . match ( expected , actual ) is None : <EOL> print '<STR_LIT>' % expected <EOL> print '<STR_LIT>' % actual <EOL> self . fail ( "<STR_LIT>" ) <EOL> def test_input_as_output ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , ExecCompWithDerivatives ( [ '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] ) ) <EOL> top . add ( '<STR_LIT>' , ExecCompWithDerivatives ( [ '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' ] ) ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> top . driver . add_objective ( '<STR_LIT>' ) <EOL> objs = top . driver . get_objectives ( ) . values ( ) <EOL> obj = '<STR_LIT>' % objs [ <NUM_LIT:0> ] . pcomp_name <EOL> top . comp1 . x = <NUM_LIT:1.0> <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ obj ] , mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ obj ] , mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> top . driver . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ obj ] , mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> outputs = [ obj ] , mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> outputs = [ obj ] , mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' , ) , ( '<STR_LIT>' , ) ] , <EOL> outputs = [ obj ] , mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' , ) , ( '<STR_LIT>' , ) ] , <EOL> outputs = [ obj ] , mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_input_as_output_nondiff ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> top . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> top . driver . add_objective ( '<STR_LIT>' ) <EOL> top . comp1 . x = <NUM_LIT:1.0> <EOL> top . run ( ) <EOL> objs = top . driver . get_objectives ( ) . values ( ) <EOL> obj = '<STR_LIT>' % objs [ <NUM_LIT:0> ] . pcomp_name <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ obj ] , mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ obj ] , mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> top . driver . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ obj ] , mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> outputs = [ obj ] , mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> outputs = [ obj ] , mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' ) , ( '<STR_LIT>' ) ] , <EOL> outputs = [ obj ] , mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' ) , ( '<STR_LIT>' ) ] , <EOL> outputs = [ obj ] , mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_input_as_output2 ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> sub = top . add ( '<STR_LIT>' , Assembly ( ) ) <EOL> sub . add ( '<STR_LIT>' , ABCDComp ( ) ) <EOL> sub . add ( '<STR_LIT>' , ABCDComp ( ) ) <EOL> sub . add ( '<STR_LIT>' , ABCDComp ( ) ) <EOL> sub . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> sub . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> sub . create_passthrough ( '<STR_LIT>' ) <EOL> sub . create_passthrough ( '<STR_LIT>' ) <EOL> sub . create_passthrough ( '<STR_LIT>' ) <EOL> sub . create_passthrough ( '<STR_LIT>' ) <EOL> sub . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> top . driver . workflow . add ( '<STR_LIT>' ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = ( '<STR_LIT>' , ) , <EOL> outputs = ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertEqual ( J . shape , ( <NUM_LIT:2> , <NUM_LIT:1> ) ) <EOL> self . assertEqual ( J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:1.> ) <EOL> self . assertEqual ( J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT:0.> ) <EOL> def test_input_as_output3 ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> sub = top . add ( '<STR_LIT>' , Assembly ( ) ) <EOL> sub . add ( '<STR_LIT>' , ABCDintComp ( ) ) <EOL> sub . add ( '<STR_LIT>' , ABCDintComp ( ) ) <EOL> sub . add ( '<STR_LIT>' , ABCDintComp ( ) ) <EOL> sub . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> sub . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> sub . create_passthrough ( '<STR_LIT>' ) <EOL> sub . create_passthrough ( '<STR_LIT>' ) <EOL> sub . create_passthrough ( '<STR_LIT>' ) <EOL> sub . create_passthrough ( '<STR_LIT>' ) <EOL> sub . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> top . driver . workflow . add ( '<STR_LIT>' ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( ( '<STR_LIT>' , ) , ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertEqual ( J . shape , ( <NUM_LIT:2> , <NUM_LIT:1> ) ) <EOL> self . assertEqual ( J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:1.> ) <EOL> self . assertEqual ( J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT:0.> ) <EOL> def test_input_as_output_nondiff_array ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , ArrayComp1_noderiv ( ) ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . driver . add_parameter ( '<STR_LIT>' ) <EOL> top . driver . add_objective ( '<STR_LIT>' ) <EOL> top . driver . add_constraint ( '<STR_LIT>' ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT:1.> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , <NUM_LIT:0.> , <NUM_LIT> ) <EOL> def test_nested ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , Assembly ( ) ) <EOL> top . nest . add ( '<STR_LIT>' , Paraboloid ( ) ) <EOL> top . nest . comp . add ( '<STR_LIT>' , Float ( <NUM_LIT> , iotype = '<STR_LIT>' ) ) <EOL> top . nest . comp . add ( '<STR_LIT>' , Float ( <NUM_LIT> , iotype = '<STR_LIT>' ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . nest . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . nest . create_passthrough ( '<STR_LIT>' ) <EOL> top . nest . create_passthrough ( '<STR_LIT>' ) <EOL> top . nest . create_passthrough ( '<STR_LIT>' ) <EOL> top . nest . create_passthrough ( '<STR_LIT>' ) <EOL> top . nest . x = <NUM_LIT:3> <EOL> top . nest . y = <NUM_LIT:5> <EOL> top . run ( ) <EOL> top . nest . comp . missing_deriv_policy = '<STR_LIT>' <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> top . nest . add ( '<STR_LIT>' , Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' ) ) <EOL> top . nest . add ( '<STR_LIT>' , Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' ) ) <EOL> top . add ( '<STR_LIT>' , Paraboloid ( ) ) <EOL> top . add ( '<STR_LIT>' , Paraboloid ( ) ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . driver . workflow . clear ( ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> top . nest . comp . missing_deriv_policy = '<STR_LIT>' <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> top . nest . missing_deriv_policy = '<STR_LIT>' <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> top . nest . missing_deriv_policy = '<STR_LIT:error>' <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> top . nest . missing_deriv_policy = '<STR_LIT>' <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' , ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' , ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> top . nest . missing_deriv_policy = '<STR_LIT:error>' <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> def test_broadcast_graph ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> equation = [ '<STR_LIT>' ] <EOL> top . add ( '<STR_LIT>' , ExecComp ( equation ) ) <EOL> top . add ( '<STR_LIT>' , ExecComp ( equation ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_5in_1out ( self ) : <EOL> self . top = set_as_top ( Assembly ( ) ) <EOL> exp1 = [ '<STR_LIT>' ] <EOL> deriv1 = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> self . top . add ( '<STR_LIT>' , ExecCompWithDerivatives ( exp1 , deriv1 ) ) <EOL> self . top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> self . top . run ( ) <EOL> J = self . top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:1.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:2> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:3> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:4> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = self . top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:1.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:2> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:3> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:4> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_1in_5out ( self ) : <EOL> self . top = set_as_top ( Assembly ( ) ) <EOL> exp1 = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> deriv1 = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> self . top . add ( '<STR_LIT>' , ExecCompWithDerivatives ( exp1 , deriv1 ) ) <EOL> self . top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> self . top . run ( ) <EOL> J = self . top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:1.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:3> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:4> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = self . top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:1.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:3> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:4> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_one_array_comp_fd ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , ArrayComp1_noderiv ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> def test_arrays ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , ArrayComp1 ( ) ) <EOL> top . add ( '<STR_LIT>' , ArrayComp1 ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_arrays_units ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , ArrayComp1_ft ( ) ) <EOL> top . add ( '<STR_LIT>' , ArrayComp1_inch ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , - <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , - <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , - <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , - <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:0> ] , - <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:1> ] , <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , - <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:0> ] , - <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:1> ] , <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , - <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:0> ] , - <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:1> ] , <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , - <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:0> ] , - <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:1> ] , <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , - <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:0> ] , - <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:1> ] , <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , - <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:0> ] , - <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:1> ] , <NUM_LIT> * <NUM_LIT:12> , <NUM_LIT> ) <EOL> def test_arrays_mixed ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , ArrayComp1 ( ) ) <EOL> top . add ( '<STR_LIT>' , ArrayComp1_noderiv ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_arrays_broadcast_fd ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , MyComp ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . comp1 . x3 = zeros ( ( <NUM_LIT:4> , <NUM_LIT:1> ) ) <EOL> top . comp1 . x4 = zeros ( ( <NUM_LIT:4> , <NUM_LIT:1> ) ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , '<STR_LIT>' , ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> self . assertEqual ( <NUM_LIT:0.0> , abs ( J ) . max ( ) ) <EOL> def test_array2D ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , ArrayComp2D ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = J - top . comp1 . J <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = J - top . comp1 . J <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = J - top . comp1 . J <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' , <EOL> return_format = '<STR_LIT>' ) <EOL> diff = J [ '<STR_LIT>' ] [ '<STR_LIT>' ] - top . comp1 . J <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> top . run ( ) <EOL> Jsub = top . comp1 . J [ <NUM_LIT:2> : <NUM_LIT:3> , <NUM_LIT:2> : <NUM_LIT:3> ] <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = J - Jsub <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = J - Jsub <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = J - Jsub <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> def test_array2D_with_apply_deriv ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , ArrayComp2D_der ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . run ( ) <EOL> inputs = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> J = top . driver . calc_gradient ( inputs = inputs , <EOL> outputs = outputs , <EOL> mode = '<STR_LIT>' ) <EOL> Jsub = top . comp1 . J [ <NUM_LIT:2> : <NUM_LIT:4> , <NUM_LIT:0> : <NUM_LIT:2> ] <EOL> diff = J - Jsub <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = inputs , <EOL> outputs = outputs , <EOL> mode = '<STR_LIT>' ) <EOL> diff = J - Jsub <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = inputs , <EOL> outputs = outputs , <EOL> mode = '<STR_LIT>' ) <EOL> diff = J - Jsub <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> def test_array_slice_1D ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , Array_Slice_1D ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = J - top . comp1 . J [ <NUM_LIT:0> : : <NUM_LIT:2> , <NUM_LIT:0> : : <NUM_LIT:2> ] <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = J - top . comp1 . J [ <NUM_LIT:0> : : <NUM_LIT:2> , <NUM_LIT:0> : : <NUM_LIT:2> ] <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = J - top . comp1 . J [ <NUM_LIT:0> : : <NUM_LIT:2> , <NUM_LIT:0> : : <NUM_LIT:2> ] <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> def test_nested_2Darray ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , Assembly ( ) ) <EOL> top . nest . add ( '<STR_LIT>' , ArrayComp2D ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . nest . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . nest . create_passthrough ( '<STR_LIT>' ) <EOL> top . nest . create_passthrough ( '<STR_LIT>' ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = J - top . nest . comp . J <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = J - top . nest . comp . J <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = J - top . nest . comp . J [ <NUM_LIT:0> , <NUM_LIT:0> ] <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = J - top . nest . comp . J [ <NUM_LIT:0> , <NUM_LIT:0> ] <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = J - top . nest . comp . J [ <NUM_LIT:1> , <NUM_LIT:2> ] <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = J - top . nest . comp . J [ <NUM_LIT:1> , <NUM_LIT:2> ] <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = J - top . nest . comp . J [ <NUM_LIT:1> , <NUM_LIT:2> ] <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = J - top . nest . comp . J [ <NUM_LIT:1> , <NUM_LIT:2> ] <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = J - top . nest . comp . J [ <NUM_LIT:1> , <NUM_LIT:2> ] <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = J - top . nest . comp . J [ <NUM_LIT:1> , <NUM_LIT:2> ] <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> Jsub = top . nest . comp . J [ <NUM_LIT:2> : <NUM_LIT:3> , <NUM_LIT:2> : <NUM_LIT:3> ] <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = J - Jsub <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = J - Jsub <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = J - Jsub <EOL> def test_nested_2Darray_gradient_sub ( self ) : <EOL> top = Assembly ( ) <EOL> top . add ( '<STR_LIT>' , Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . nest . add ( '<STR_LIT>' , ArrayComp2D ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . nest . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . nest . create_passthrough ( '<STR_LIT>' ) <EOL> top . nest . create_passthrough ( '<STR_LIT>' ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:100> , high = <NUM_LIT:100> ) <EOL> top . driver . add_objective ( '<STR_LIT>' ) <EOL> options = top . nest . driver . gradient_options <EOL> options . force_fd = True <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( ) <EOL> self . assertTrue ( '<STR_LIT>' in top . nest . _system . vec [ '<STR_LIT:u>' ] . _info ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_nested_2Darray_simul_element_and_full_connection ( self ) : <EOL> top = Assembly ( ) <EOL> top . add ( '<STR_LIT>' , ArrayComp2D ( ) ) <EOL> top . add ( '<STR_LIT>' , Assembly ( ) ) <EOL> top . nest . add ( '<STR_LIT>' , ArrayComp2D ( ) ) <EOL> top . nest . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . nest . create_passthrough ( '<STR_LIT>' ) <EOL> top . nest . create_passthrough ( '<STR_LIT>' ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:10> , high = <NUM_LIT:10> ) <EOL> top . driver . add_objective ( '<STR_LIT>' ) <EOL> top . driver . add_constraint ( '<STR_LIT>' ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_nested_2Darray_simul_element_and_full_connection2 ( self ) : <EOL> top = Assembly ( ) <EOL> top . add ( '<STR_LIT>' , Assembly ( ) ) <EOL> top . nest . add ( '<STR_LIT>' , ArrayComp2D ( ) ) <EOL> top . nest . add ( '<STR_LIT>' , ArrayComp2D ( ) ) <EOL> top . nest . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> top . nest . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . nest . create_passthrough ( '<STR_LIT>' ) <EOL> top . nest . create_passthrough ( '<STR_LIT>' ) <EOL> top . nest . add ( '<STR_LIT>' , Array ( iotype = '<STR_LIT>' ) ) <EOL> top . nest . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:10> , high = <NUM_LIT:10> ) <EOL> top . driver . add_objective ( '<STR_LIT>' ) <EOL> top . driver . add_constraint ( '<STR_LIT>' ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_nested_2Darray_simul_element_and_full_connection_apply_derivs ( self ) : <EOL> top = Assembly ( ) <EOL> top . add ( '<STR_LIT>' , ArrayComp2D_der ( ) ) <EOL> top . add ( '<STR_LIT>' , Assembly ( ) ) <EOL> top . nest . add ( '<STR_LIT>' , ArrayComp2D_der ( ) ) <EOL> top . nest . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . nest . create_passthrough ( '<STR_LIT>' ) <EOL> top . nest . create_passthrough ( '<STR_LIT>' ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:10> , high = <NUM_LIT:10> ) <EOL> top . driver . add_objective ( '<STR_LIT>' ) <EOL> top . driver . add_constraint ( '<STR_LIT>' ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_nested_2Darray_simul_element_and_full_connection_apply_derivs2 ( self ) : <EOL> top = Assembly ( ) <EOL> top . add ( '<STR_LIT>' , Assembly ( ) ) <EOL> top . nest . add ( '<STR_LIT>' , ArrayComp2D_der ( ) ) <EOL> top . nest . add ( '<STR_LIT>' , ArrayComp2D_der ( ) ) <EOL> top . nest . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> top . nest . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . nest . create_passthrough ( '<STR_LIT>' ) <EOL> top . nest . create_passthrough ( '<STR_LIT>' ) <EOL> top . nest . add ( '<STR_LIT>' , Array ( iotype = '<STR_LIT>' ) ) <EOL> top . nest . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:10> , high = <NUM_LIT:10> ) <EOL> top . driver . add_objective ( '<STR_LIT>' ) <EOL> top . driver . add_constraint ( '<STR_LIT>' ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_nested_2Darray_simul_element_and_full_connection_multi_param ( self ) : <EOL> top = Assembly ( ) <EOL> top . add ( '<STR_LIT>' , ArrayComp2D_der ( ) ) <EOL> top . add ( '<STR_LIT>' , Assembly ( ) ) <EOL> top . nest . add ( '<STR_LIT>' , ArrayComp2D_der ( ) ) <EOL> top . nest . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . nest . create_passthrough ( '<STR_LIT>' ) <EOL> top . nest . create_passthrough ( '<STR_LIT>' ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:10> , high = <NUM_LIT:10> ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:10> , high = <NUM_LIT:10> ) <EOL> top . driver . add_objective ( '<STR_LIT>' ) <EOL> top . driver . add_constraint ( '<STR_LIT>' ) <EOL> top . driver . add_constraint ( '<STR_LIT>' ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:2> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_nested_array_full_and_partial_passthrough ( self ) : <EOL> top = Assembly ( ) <EOL> top . add ( '<STR_LIT>' , Assembly ( ) ) <EOL> top . nest . add ( '<STR_LIT>' , ArrayComp2D ( ) ) <EOL> top . nest . add ( '<STR_LIT>' , ArrayComp2D ( ) ) <EOL> top . nest . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> top . nest . create_passthrough ( '<STR_LIT>' , '<STR_LIT:x>' ) <EOL> top . nest . create_passthrough ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . nest . create_passthrough ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . nest . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . run ( ) <EOL> Jbase = top . nest . comp1 . provideJ ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = abs ( J [ <NUM_LIT:0> : <NUM_LIT:4> , : ] - Jbase ) <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> diff = abs ( J [ <NUM_LIT:0> : <NUM_LIT:4> , - <NUM_LIT:1> ] - Jbase [ : , - <NUM_LIT:1> ] ) <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> diff = abs ( J [ <NUM_LIT:4> : , : - <NUM_LIT:1> ] ) <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = abs ( J [ <NUM_LIT:0> : <NUM_LIT:4> , : ] - Jbase ) <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> diff = abs ( J [ <NUM_LIT:0> : <NUM_LIT:4> , - <NUM_LIT:1> ] - Jbase [ : , - <NUM_LIT:1> ] ) <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> diff = abs ( J [ <NUM_LIT:4> : , : - <NUM_LIT:1> ] ) <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> Jdict = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' , <EOL> return_format = '<STR_LIT>' ) <EOL> diff = Jdict [ '<STR_LIT>' ] [ '<STR_LIT>' ] - Jbase <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> diff = Jdict [ '<STR_LIT>' ] [ '<STR_LIT>' ] - J [ <NUM_LIT:4> : , : ] <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = abs ( J [ <NUM_LIT:0> : <NUM_LIT:4> , : ] - Jbase ) <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> diff = abs ( J [ <NUM_LIT:0> : <NUM_LIT:4> , - <NUM_LIT:1> ] - Jbase [ : , - <NUM_LIT:1> ] ) <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> diff = abs ( J [ <NUM_LIT:4> : , : - <NUM_LIT:1> ] ) <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> Jdict = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' , <EOL> return_format = '<STR_LIT>' ) <EOL> diff = Jdict [ '<STR_LIT>' ] [ '<STR_LIT>' ] - Jbase <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> diff = Jdict [ '<STR_LIT>' ] [ '<STR_LIT>' ] - J [ <NUM_LIT:4> : , : ] <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> def test_large_dataflow ( self ) : <EOL> self . top = set_as_top ( Assembly ( ) ) <EOL> exp1 = [ '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> deriv1 = [ '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> exp2 = [ '<STR_LIT>' ] <EOL> deriv2 = [ '<STR_LIT>' ] <EOL> exp3 = [ '<STR_LIT>' ] <EOL> deriv3 = [ '<STR_LIT>' ] <EOL> exp4 = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> deriv4 = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> exp5 = [ '<STR_LIT>' ] <EOL> deriv5 = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> self . top . add ( '<STR_LIT>' , ExecCompWithDerivatives ( exp1 , deriv1 ) ) <EOL> self . top . add ( '<STR_LIT>' , ExecCompWithDerivatives ( exp2 , deriv2 ) ) <EOL> self . top . add ( '<STR_LIT>' , ExecCompWithDerivatives ( exp3 , deriv3 ) ) <EOL> self . top . add ( '<STR_LIT>' , ExecCompWithDerivatives ( exp4 , deriv4 ) ) <EOL> self . top . add ( '<STR_LIT>' , ExecCompWithDerivatives ( exp5 , deriv5 ) ) <EOL> self . top . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . comp1 . x1 = <NUM_LIT> <EOL> self . top . run ( ) <EOL> J = self . top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = self . top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_bug ( self ) : <EOL> self . top = set_as_top ( Assembly ( ) ) <EOL> self . top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> self . top . add ( '<STR_LIT>' , SimpleComp ( ) ) <EOL> self . top . driver . add_objective ( '<STR_LIT>' ) <EOL> self . top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT> , high = <NUM_LIT> ) <EOL> self . top . driver . add_constraint ( '<STR_LIT>' ) <EOL> self . top . run ( ) <EOL> J = self . top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = self . top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_equality_constraint ( self ) : <EOL> self . top = set_as_top ( Assembly ( ) ) <EOL> self . top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> self . top . add ( '<STR_LIT>' , ArrayComp1 ( ) ) <EOL> self . top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT> , high = <NUM_LIT> ) <EOL> self . top . driver . add_constraint ( '<STR_LIT>' ) <EOL> self . top . run ( ) <EOL> J = self . top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> J = self . top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> J = self . top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> def test_three_way ( self ) : <EOL> self . top = set_as_top ( Assembly ( ) ) <EOL> exp1 = [ '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> deriv1 = [ '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> exp2 = [ '<STR_LIT>' ] <EOL> deriv2 = [ '<STR_LIT>' ] <EOL> exp3 = [ '<STR_LIT>' ] <EOL> deriv3 = [ '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> self . top . add ( '<STR_LIT>' , ExecCompWithDerivatives ( exp1 , deriv1 ) ) <EOL> self . top . add ( '<STR_LIT>' , ExecCompWithDerivatives ( exp2 , deriv2 ) ) <EOL> self . top . add ( '<STR_LIT>' , ExecCompWithDerivatives ( exp3 , deriv3 ) ) <EOL> self . top . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . comp1 . x1 = <NUM_LIT> <EOL> self . top . run ( ) <EOL> J = self . top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> Jfd = self . top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> diff = Jfd - J <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT:0.1> ) <EOL> def test_nondifferentiable_blocks ( self ) : <EOL> self . top = set_as_top ( Assembly ( ) ) <EOL> exp1 = [ '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> deriv1 = [ '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> exp2 = [ '<STR_LIT>' ] <EOL> deriv2 = [ '<STR_LIT>' ] <EOL> exp3 = [ '<STR_LIT>' ] <EOL> deriv3 = [ '<STR_LIT>' ] <EOL> exp4 = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> deriv4 = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> exp5 = [ '<STR_LIT>' ] <EOL> deriv5 = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> self . top . add ( '<STR_LIT>' , ExecComp ( exp1 ) ) <EOL> self . top . add ( '<STR_LIT>' , ExecComp ( exp2 ) ) <EOL> self . top . add ( '<STR_LIT>' , ExecComp ( exp3 ) ) <EOL> self . top . add ( '<STR_LIT>' , ExecCompWithDerivatives ( exp4 , deriv4 ) ) <EOL> self . top . add ( '<STR_LIT>' , ExecComp ( exp5 ) ) <EOL> self . top . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . top . comp1 . x1 = <NUM_LIT> <EOL> self . top . run ( ) <EOL> J = self . top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = self . top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> comp_list = simple_node_iter ( self . top . driver . workflow . _system . subsystems ( ) [ <NUM_LIT:1> ] . _nodes ) <EOL> self . assertTrue ( len ( comp_list ) == <NUM_LIT:3> ) <EOL> self . assertTrue ( '<STR_LIT>' in comp_list ) <EOL> self . assertTrue ( '<STR_LIT>' in comp_list ) <EOL> self . assertTrue ( '<STR_LIT>' in comp_list ) <EOL> comp_list = simple_node_iter ( self . top . driver . workflow . _system . subsystems ( ) [ <NUM_LIT:3> ] . _nodes ) <EOL> self . assertTrue ( len ( comp_list ) == <NUM_LIT:1> ) <EOL> self . assertTrue ( '<STR_LIT>' in comp_list ) <EOL> self . top . replace ( '<STR_LIT>' , ExecComp ( exp4 ) ) <EOL> self . top . comp1 . x1 = <NUM_LIT> <EOL> self . top . run ( ) <EOL> J = self . top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = self . top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> comp_list = simple_node_iter ( self . top . driver . workflow . _system . subsystems ( ) [ <NUM_LIT:1> ] . _nodes ) <EOL> self . assertTrue ( len ( comp_list ) == <NUM_LIT:5> ) <EOL> self . assertTrue ( '<STR_LIT>' in comp_list ) <EOL> self . assertTrue ( '<STR_LIT>' in comp_list ) <EOL> self . assertTrue ( '<STR_LIT>' in comp_list ) <EOL> self . assertTrue ( '<STR_LIT>' in comp_list ) <EOL> self . assertTrue ( '<STR_LIT>' in comp_list ) <EOL> system = self . top . driver . workflow . _system <EOL> self . assertTrue ( system . is_variable_local ( '<STR_LIT>' ) is True ) <EOL> self . top . replace ( '<STR_LIT>' , ExecCompWithDerivatives ( exp5 , deriv5 ) ) <EOL> self . top . comp1 . x1 = <NUM_LIT> <EOL> self . top . run ( ) <EOL> J = self . top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = self . top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> comp_list = simple_node_iter ( self . top . driver . workflow . _system . subsystems ( ) [ <NUM_LIT:1> ] . _nodes ) <EOL> self . assertTrue ( len ( comp_list ) == <NUM_LIT:4> ) <EOL> self . assertTrue ( '<STR_LIT>' in comp_list ) <EOL> self . assertTrue ( '<STR_LIT>' in comp_list ) <EOL> self . assertTrue ( '<STR_LIT>' in comp_list ) <EOL> self . assertTrue ( '<STR_LIT>' in comp_list ) <EOL> self . top . replace ( '<STR_LIT>' , ExecCompWithDerivatives ( exp1 , deriv1 ) ) <EOL> self . top . replace ( '<STR_LIT>' , ExecCompWithDerivatives ( exp3 , deriv3 ) ) <EOL> self . top . comp1 . x1 = <NUM_LIT> <EOL> self . top . run ( ) <EOL> J = self . top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = self . top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> comp_list = simple_node_iter ( self . top . driver . workflow . _system . subsystems ( ) [ <NUM_LIT:3> ] . _nodes ) <EOL> self . assertTrue ( len ( comp_list ) == <NUM_LIT:2> ) <EOL> self . assertTrue ( '<STR_LIT>' in comp_list ) <EOL> self . assertTrue ( '<STR_LIT>' in comp_list ) <EOL> J = self . top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_boundary_variables ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , Paraboloid ( ) ) <EOL> top . add ( '<STR_LIT:target>' , Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' ) ) <EOL> top . add ( '<STR_LIT>' , Array ( [ <NUM_LIT> , <NUM_LIT> ] , iotype = '<STR_LIT>' ) ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( '<STR_LIT>' ) <EOL> top . driver . add_parameter ( '<STR_LIT:target>' , low = - <NUM_LIT> , high = <NUM_LIT> ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT> , high = <NUM_LIT> ) <EOL> top . driver . add_objective ( '<STR_LIT>' ) <EOL> top . driver . add_constraint ( '<STR_LIT>' ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT:1.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT:1.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT:1.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , ParaboloidNoDeriv ( ) ) <EOL> top . add ( '<STR_LIT:target>' , Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' ) ) <EOL> top . add ( '<STR_LIT>' , Array ( [ <NUM_LIT> , <NUM_LIT> ] , iotype = '<STR_LIT>' ) ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( '<STR_LIT>' ) <EOL> top . driver . add_parameter ( '<STR_LIT:target>' , low = - <NUM_LIT> , high = <NUM_LIT> ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT> , high = <NUM_LIT> ) <EOL> top . driver . add_objective ( '<STR_LIT>' ) <EOL> top . driver . add_constraint ( '<STR_LIT>' ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT:1.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT:1.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT:1.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( '<STR_LIT>' ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT> , high = <NUM_LIT> ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT> , high = <NUM_LIT> ) <EOL> top . driver . add_objective ( '<STR_LIT>' ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_first_derivative_with_units ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , CompFoot ( ) ) <EOL> top . add ( '<STR_LIT>' , CompInch ( ) ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT> , high = <NUM_LIT> , fd_step = <NUM_LIT> ) <EOL> top . driver . add_objective ( '<STR_LIT>' ) <EOL> top . comp1 . x = <NUM_LIT> <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_unit_with_offset ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , CompDegC ( ) ) <EOL> top . add ( '<STR_LIT>' , CompDegF ( ) ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT> , high = <NUM_LIT> , fd_step = <NUM_LIT> ) <EOL> top . driver . add_objective ( '<STR_LIT>' ) <EOL> top . comp1 . x = <NUM_LIT> <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_paramgroup ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , GComp_noD ( ) ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , ( '<STR_LIT>' , ) ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_paramgroup_deriv ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , Paraboloid ( ) ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_paramgroup_with_scaler ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , GComp_noD ( ) ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . driver . add_parameter ( [ '<STR_LIT>' , '<STR_LIT>' ] , low = - <NUM_LIT:100> , high = <NUM_LIT:100> , scaler = <NUM_LIT> ) <EOL> top . driver . add_objective ( '<STR_LIT>' ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> * <NUM_LIT> , <NUM_LIT> ) <EOL> system = top . driver . workflow . _system <EOL> self . assertTrue ( system . is_variable_local ( '<STR_LIT>' ) is True ) <EOL> self . assertTrue ( system . is_variable_local ( '<STR_LIT>' ) is True ) <EOL> def test_missing_derivs_error ( self ) : <EOL> self . top = set_as_top ( Assembly ( ) ) <EOL> self . top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> self . top . add ( '<STR_LIT>' , SimpleCompMissingDeriv ( ) ) <EOL> self . top . driver . add_objective ( '<STR_LIT>' ) <EOL> self . top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT> , high = <NUM_LIT> ) <EOL> self . top . driver . add_constraint ( '<STR_LIT>' ) <EOL> self . top . run ( ) <EOL> try : <EOL> J = self . top . driver . calc_gradient ( mode = '<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> self . top . driver . remove_constraint ( '<STR_LIT>' ) <EOL> self . top . driver . add_constraint ( '<STR_LIT>' ) <EOL> self . top . driver . remove_parameter ( '<STR_LIT>' ) <EOL> self . top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT> , high = <NUM_LIT> ) <EOL> try : <EOL> J = self . top . driver . calc_gradient ( mode = '<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> def test_missing_derivs_assume_zero ( self ) : <EOL> self . top = set_as_top ( Assembly ( ) ) <EOL> self . top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> self . top . add ( '<STR_LIT>' , SimpleCompMissingDeriv ( ) ) <EOL> self . top . dis2 . missing_deriv_policy = '<STR_LIT>' <EOL> self . top . driver . add_objective ( '<STR_LIT>' ) <EOL> self . top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT> , high = <NUM_LIT> ) <EOL> self . top . driver . add_constraint ( '<STR_LIT>' ) <EOL> self . top . run ( ) <EOL> J = self . top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> derivs = self . top . check_gradient ( name = '<STR_LIT>' , stream = None ) <EOL> self . assertTrue ( '<STR_LIT>' in derivs [ <NUM_LIT:2> ] ) <EOL> self . top . driver . run_iteration ( ) <EOL> J = self . top . driver . calc_gradient ( inputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> def test_fd_param_group_arrays_sharing_memory ( self ) : <EOL> class CompSource ( Component ) : <EOL> y = Array ( array ( [ <NUM_LIT:0.0> , <NUM_LIT:0.0> , <NUM_LIT:0.0> , <NUM_LIT:0.0> ] ) , iotype = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> self . y = array ( [ <NUM_LIT:1.0> , <NUM_LIT:1.0> , <NUM_LIT:1.0> , <NUM_LIT:1.0> ] ) <EOL> class CompSink ( Component ) : <EOL> a = Array ( array ( [ <NUM_LIT:0.0> , <NUM_LIT:0.0> , <NUM_LIT:0.0> , <NUM_LIT:0.0> ] ) , iotype = '<STR_LIT>' ) <EOL> b = Array ( array ( [ <NUM_LIT:0.0> , <NUM_LIT:0.0> , <NUM_LIT:0.0> , <NUM_LIT:0.0> ] ) , iotype = '<STR_LIT>' ) <EOL> y = Float ( <NUM_LIT:0.0> , iotype = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> self . y = <NUM_LIT> * sum ( self . a ) + <NUM_LIT> * sum ( self . b ) <EOL> print "<STR_LIT>" , self . a , self . b , self . y <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . add ( '<STR_LIT>' , CompSource ( ) ) <EOL> top . add ( '<STR_LIT>' , CompSink ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . run ( ) <EOL> top . driver . workflow . clear ( ) <EOL> top . driver . workflow . add ( '<STR_LIT>' ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> outputs = [ '<STR_LIT>' ] , mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> outputs = [ '<STR_LIT>' ] , mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> outputs = [ '<STR_LIT>' ] , mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> outputs = [ '<STR_LIT>' ] , mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> top . disconnect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . c2 . b = array ( [ <NUM_LIT:0.0> , <NUM_LIT:0.0> , <NUM_LIT:0.0> , <NUM_LIT:0.0> ] ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> outputs = [ '<STR_LIT>' ] , mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] , <EOL> outputs = [ '<STR_LIT>' ] , mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_jacobian_size_error ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , Array_Slice_1D ( ) ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . comp1 . x = zeros ( ( <NUM_LIT:3> , <NUM_LIT:2> ) ) <EOL> try : <EOL> J = top . driver . calc_gradient ( inputs = [ ( '<STR_LIT>' ) ] , <EOL> outputs = [ '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> except RuntimeError as err : <EOL> msg = '<STR_LIT>' <EOL> self . assertEqual ( str ( err ) , msg ) <EOL> else : <EOL> self . fail ( "<STR_LIT>" ) <EOL> class Comp2 ( Component ) : <EOL> """<STR_LIT>""" <EOL> x1 = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' , units = '<STR_LIT>' ) <EOL> x2 = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' , units = '<STR_LIT>' ) <EOL> y1 = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' , units = '<STR_LIT>' ) <EOL> y2 = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' , units = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def provideJ ( self ) : <EOL> """<STR_LIT>""" <EOL> self . J = array ( [ [ <NUM_LIT> , <NUM_LIT> ] , [ <NUM_LIT> , <NUM_LIT> ] ] ) <EOL> return self . J <EOL> def list_deriv_vars ( self ) : <EOL> input_keys = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> output_keys = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> return input_keys , output_keys <EOL> class Comp2_array ( Component ) : <EOL> """<STR_LIT>""" <EOL> x = Array ( zeros ( ( <NUM_LIT:2> , <NUM_LIT:2> ) ) , iotype = '<STR_LIT>' ) <EOL> y = Array ( zeros ( ( <NUM_LIT:2> , <NUM_LIT:2> ) ) , iotype = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def provideJ ( self ) : <EOL> """<STR_LIT>""" <EOL> self . J = array ( [ [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , - <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , - <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , - <NUM_LIT> , <NUM_LIT> ] ] ) <EOL> self . JT = self . J . T <EOL> def apply_deriv ( self , arg , result ) : <EOL> if '<STR_LIT:y>' in result and '<STR_LIT:x>' in arg : <EOL> dx = self . J . dot ( arg [ '<STR_LIT:x>' ] . flatten ( ) ) <EOL> result [ '<STR_LIT:y>' ] = dx . reshape ( ( <NUM_LIT:2> , <NUM_LIT:2> ) ) <EOL> def apply_derivT ( self , arg , result ) : <EOL> if '<STR_LIT:y>' in arg and '<STR_LIT:x>' in result : <EOL> dy = self . JT . dot ( arg [ '<STR_LIT:y>' ] . flatten ( ) ) <EOL> result [ '<STR_LIT:x>' ] = dy . reshape ( ( <NUM_LIT:2> , <NUM_LIT:2> ) ) <EOL> class Comp3_array ( Component ) : <EOL> """<STR_LIT>""" <EOL> x = Array ( zeros ( ( <NUM_LIT:3> , <NUM_LIT:3> ) ) , iotype = '<STR_LIT>' ) <EOL> y = Array ( zeros ( ( <NUM_LIT:3> , <NUM_LIT:3> ) ) , iotype = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def provideJ ( self ) : <EOL> """<STR_LIT>""" <EOL> self . J = random . random ( ( <NUM_LIT:9> , <NUM_LIT:9> ) ) <EOL> self . JT = self . J . T <EOL> def list_deriv_vars ( self ) : <EOL> return ( '<STR_LIT:x>' , ) , ( '<STR_LIT:y>' , ) <EOL> def apply_deriv ( self , arg , result ) : <EOL> if '<STR_LIT:y>' in result and '<STR_LIT:x>' in arg : <EOL> dx = self . J . dot ( arg [ '<STR_LIT:x>' ] . flatten ( ) ) <EOL> result [ '<STR_LIT:y>' ] += dx . reshape ( ( <NUM_LIT:3> , <NUM_LIT:3> ) ) <EOL> def apply_derivT ( self , arg , result ) : <EOL> if '<STR_LIT:y>' in arg and '<STR_LIT:x>' in result : <EOL> dy = self . JT . dot ( arg [ '<STR_LIT:y>' ] . flatten ( ) ) <EOL> result [ '<STR_LIT:x>' ] += dy . reshape ( ( <NUM_LIT:3> , <NUM_LIT:3> ) ) <EOL> class CompBase ( Component ) : <EOL> x = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' , units = '<STR_LIT>' ) <EOL> y = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' , units = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> self . y = self . x <EOL> pass <EOL> def provideJ ( self ) : <EOL> """<STR_LIT>""" <EOL> self . J = array ( [ [ <NUM_LIT:1.0> ] ] ) <EOL> def list_deriv_vars ( self ) : <EOL> '''<STR_LIT>''' <EOL> return ( '<STR_LIT:x>' , ) , ( '<STR_LIT:y>' , ) <EOL> class CompForward ( CompBase ) : <EOL> def apply_deriv ( self , arg , result ) : <EOL> if '<STR_LIT:y>' in result and '<STR_LIT:x>' in arg : <EOL> result [ '<STR_LIT:y>' ] += arg [ '<STR_LIT:x>' ] <EOL> class CompAdjoint ( CompBase ) : <EOL> def apply_derivT ( self , arg , result ) : <EOL> if '<STR_LIT:y>' in arg and '<STR_LIT:x>' in result : <EOL> result [ '<STR_LIT:x>' ] += arg [ '<STR_LIT:y>' ] <EOL> class Testcase_applyJT ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_forward_adjoint_error ( self ) : <EOL> model = set_as_top ( Assembly ( ) ) <EOL> model . add ( '<STR_LIT>' , CompForward ( ) ) <EOL> model . driver . workflow . add ( '<STR_LIT>' ) <EOL> try : <EOL> model . run ( ) <EOL> except Exception as err : <EOL> msg = "<STR_LIT>" + "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , msg ) <EOL> else : <EOL> self . fail ( "<STR_LIT>" ) <EOL> model = set_as_top ( Assembly ( ) ) <EOL> model . add ( '<STR_LIT>' , CompAdjoint ( ) ) <EOL> model . driver . workflow . add ( '<STR_LIT>' ) <EOL> try : <EOL> model . run ( ) <EOL> except Exception as err : <EOL> msg = "<STR_LIT>" + "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , msg ) <EOL> else : <EOL> self . fail ( "<STR_LIT>" ) <EOL> class PreComp ( Component ) : <EOL> '''<STR_LIT>''' <EOL> x1 = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' , units = '<STR_LIT>' ) <EOL> x2 = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' , units = '<STR_LIT>' ) <EOL> y1 = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' , units = '<STR_LIT>' ) <EOL> y2 = Float ( <NUM_LIT:1.0> , iotype = '<STR_LIT>' , units = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> self . y1 = <NUM_LIT> * self . x1 + <NUM_LIT> * self . x2 <EOL> self . y2 = <NUM_LIT> * self . x1 - <NUM_LIT> * self . x2 <EOL> def provideJ ( self ) : <EOL> """<STR_LIT>""" <EOL> dy1_dx1 = <NUM_LIT> <EOL> dy1_dx2 = <NUM_LIT> <EOL> dy2_dx1 = <NUM_LIT> <EOL> dy2_dx2 = - <NUM_LIT> <EOL> self . J = array ( [ [ dy1_dx1 , dy1_dx2 ] , [ dy2_dx1 , dy2_dx2 ] ] ) <EOL> return self . J <EOL> def list_deriv_vars ( self ) : <EOL> input_keys = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> output_keys = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> return input_keys , output_keys <EOL> def applyMinv ( self , arg , result ) : <EOL> result [ '<STR_LIT>' ] = <NUM_LIT> * arg [ '<STR_LIT>' ] + <NUM_LIT> * arg [ '<STR_LIT>' ] <EOL> result [ '<STR_LIT>' ] = <NUM_LIT> * arg [ '<STR_LIT>' ] - <NUM_LIT> * arg [ '<STR_LIT>' ] <EOL> return result <EOL> def applyMinvT ( self , arg , result ) : <EOL> result [ '<STR_LIT>' ] = <NUM_LIT> * arg [ '<STR_LIT>' ] + <NUM_LIT> * arg [ '<STR_LIT>' ] <EOL> result [ '<STR_LIT>' ] = <NUM_LIT> * arg [ '<STR_LIT>' ] - <NUM_LIT> * arg [ '<STR_LIT>' ] <EOL> return result <EOL> class PreCompArray ( Component ) : <EOL> '''<STR_LIT>''' <EOL> x = Array ( array ( [ <NUM_LIT:1.0> , <NUM_LIT:1.0> ] ) , iotype = '<STR_LIT>' ) <EOL> y = Array ( array ( [ <NUM_LIT:1.0> , <NUM_LIT:1.0> ] ) , iotype = '<STR_LIT>' ) <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> self . y [ <NUM_LIT:0> ] = <NUM_LIT> * self . x [ <NUM_LIT:0> ] + <NUM_LIT> * self . x [ <NUM_LIT:1> ] <EOL> self . y [ <NUM_LIT:1> ] = <NUM_LIT> * self . x [ <NUM_LIT:0> ] - <NUM_LIT> * self . x [ <NUM_LIT:1> ] <EOL> def provideJ ( self ) : <EOL> """<STR_LIT>""" <EOL> dy1_dx1 = <NUM_LIT> <EOL> dy1_dx2 = <NUM_LIT> <EOL> dy2_dx1 = <NUM_LIT> <EOL> dy2_dx2 = - <NUM_LIT> <EOL> self . J = array ( [ [ dy1_dx1 , dy1_dx2 ] , [ dy2_dx1 , dy2_dx2 ] ] ) <EOL> return self . J <EOL> def list_deriv_vars ( self ) : <EOL> input_keys = ( '<STR_LIT:x>' , ) <EOL> output_keys = ( '<STR_LIT:y>' , ) <EOL> return input_keys , output_keys <EOL> def applyMinv ( self , arg , result ) : <EOL> if '<STR_LIT:y>' in arg : <EOL> result [ '<STR_LIT:y>' ] [ <NUM_LIT:0> ] = <NUM_LIT> * arg [ '<STR_LIT:y>' ] [ <NUM_LIT:0> ] + <NUM_LIT> * arg [ '<STR_LIT:y>' ] [ <NUM_LIT:1> ] <EOL> result [ '<STR_LIT:y>' ] [ <NUM_LIT:1> ] = <NUM_LIT> * arg [ '<STR_LIT:y>' ] [ <NUM_LIT:0> ] - <NUM_LIT> * arg [ '<STR_LIT:y>' ] [ <NUM_LIT:1> ] <EOL> return result <EOL> def applyMinvT ( self , arg , result ) : <EOL> if '<STR_LIT:y>' in arg : <EOL> result [ '<STR_LIT:y>' ] [ <NUM_LIT:0> ] = <NUM_LIT> * arg [ '<STR_LIT:y>' ] [ <NUM_LIT:0> ] + <NUM_LIT> * arg [ '<STR_LIT:y>' ] [ <NUM_LIT:1> ] <EOL> result [ '<STR_LIT:y>' ] [ <NUM_LIT:1> ] = <NUM_LIT> * arg [ '<STR_LIT:y>' ] [ <NUM_LIT:0> ] - <NUM_LIT> * arg [ '<STR_LIT:y>' ] [ <NUM_LIT:1> ] <EOL> return result <EOL> class Testcase_preconditioning ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_simple ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , PreComp ( ) ) <EOL> top . driver . workflow . add ( '<STR_LIT>' ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> J = top . driver . calc_gradient ( inputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> outputs = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> def test_two_comp ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , PreComp ( ) ) <EOL> top . add ( '<STR_LIT>' , PreComp ( ) ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:10> , high = <NUM_LIT:10> ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:10> , high = <NUM_LIT:10> ) <EOL> top . driver . add_objective ( '<STR_LIT>' ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_two_comp_array ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , PreCompArray ( ) ) <EOL> top . add ( '<STR_LIT>' , PreCompArray ( ) ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:10> , high = <NUM_LIT:10> ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:10> , high = <NUM_LIT:10> ) <EOL> top . driver . add_objective ( '<STR_LIT>' ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> def test_nested_array_element ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , Assembly ( ) ) <EOL> top . nest . add ( '<STR_LIT>' , PreCompArray ( ) ) <EOL> top . nest . add ( '<STR_LIT>' , PreCompArray ( ) ) <EOL> top . nest . add ( '<STR_LIT>' , PreCompArray ( ) ) <EOL> top . nest . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . nest . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> top . nest . create_passthrough ( '<STR_LIT>' ) <EOL> top . nest . create_passthrough ( '<STR_LIT>' ) <EOL> top . nest . add ( '<STR_LIT>' , Array ( [ <NUM_LIT:0.0> , <NUM_LIT:0.0> ] , iotype = '<STR_LIT>' ) ) <EOL> top . nest . add ( '<STR_LIT>' , Array ( array ( [ <NUM_LIT> , <NUM_LIT> ] ) , iotype = '<STR_LIT>' ) ) <EOL> top . nest . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . nest . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' ] ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:10> , high = <NUM_LIT:10> ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:10> , high = <NUM_LIT:10> ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:10> , high = <NUM_LIT:10> ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:10> , high = <NUM_LIT:10> ) <EOL> top . driver . add_objective ( '<STR_LIT>' ) <EOL> top . driver . add_constraint ( '<STR_LIT>' ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:2> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:3> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:2> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:3> ] , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> def test_two_comp_bifurcation ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , PreComp ( ) ) <EOL> top . add ( '<STR_LIT>' , PreComp ( ) ) <EOL> top . add ( '<STR_LIT>' , PreComp ( ) ) <EOL> top . add ( '<STR_LIT>' , PreComp ( ) ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . driver . workflow . add ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:10> , high = <NUM_LIT:10> ) <EOL> top . driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:10> , high = <NUM_LIT:10> ) <EOL> top . driver . add_objective ( '<STR_LIT>' ) <EOL> top . driver . add_constraint ( '<STR_LIT>' ) <EOL> top . run ( ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> J = top . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:1> , <NUM_LIT:1> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> class TestMultiDriver ( unittest . TestCase ) : <EOL> def test_nested_driver ( self ) : <EOL> top = set_as_top ( Assembly ( ) ) <EOL> top . add ( '<STR_LIT>' , SimpleComp ( ) ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . add ( '<STR_LIT>' , SimpleDriver ( ) ) <EOL> top . add ( '<STR_LIT:target>' , Float ( <NUM_LIT> , iotype = '<STR_LIT>' ) ) <EOL> top . driver . workflow . add ( '<STR_LIT>' ) <EOL> top . driver . add_parameter ( '<STR_LIT:target>' , low = - <NUM_LIT:100> , high = <NUM_LIT:100> ) <EOL> top . driver . add_objective ( '<STR_LIT>' ) <EOL> top . inner_driver . workflow . add ( '<STR_LIT>' ) <EOL> top . inner_driver . add_parameter ( '<STR_LIT>' , low = - <NUM_LIT:100> , high = <NUM_LIT:100> ) <EOL> top . inner_driver . add_objective ( '<STR_LIT>' ) <EOL> top . run ( ) <EOL> self . assertEqual ( set ( top . _system . vec [ '<STR_LIT:u>' ] . keys ( ) ) , <EOL> set ( [ ( '<STR_LIT>' , ( '<STR_LIT>' , '<STR_LIT>' ) ) , <EOL> ( '<STR_LIT>' , ( '<STR_LIT>' , ) ) , <EOL> ( '<STR_LIT:target>' , ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:target>' ) ) , <EOL> ( '<STR_LIT>' , ( '<STR_LIT>' , ) ) , <EOL> ( '<STR_LIT>' , ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) , <EOL> ] ) ) <EOL> def test_PA_subvar_solver_edges ( self ) : <EOL> sp = set_as_top ( UnitScalableProblem ( ) ) <EOL> sp . architecture = MDF ( ) <EOL> sp . run ( ) <EOL> sp . solver . tol = <NUM_LIT> <EOL> sp . run ( ) <EOL> J = sp . driver . calc_gradient ( ) <EOL> Jfd = sp . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> diff = J - Jfd <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> def test_PA_subvar_driver_edges ( self ) : <EOL> raise SkipTest ( '<STR_LIT>' ) <EOL> sp = set_as_top ( UnitScalableProblem ( ) ) <EOL> sp . architecture = CO ( ) <EOL> sp . driver . maxiter = <NUM_LIT:1> <EOL> sp . run ( ) <EOL> sp . driver . gradient_options . fd_form = '<STR_LIT>' <EOL> J = sp . driver . calc_gradient ( ) <EOL> Jfd = sp . driver . calc_gradient ( mode = '<STR_LIT>' ) <EOL> diff = J - Jfd <EOL> assert_rel_error ( self , diff . max ( ) , <NUM_LIT:0.0> , <NUM_LIT> ) <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>
