<s> import unittest <EOL> from SimPEG import * <EOL> from SimPEG import EM <EOL> import sys <EOL> from scipy . constants import mu_0 <EOL> from SimPEG . EM . Utils . testingUtils import getFDEMProblem <EOL> testE = True <EOL> testB = True <EOL> testH = True <EOL> testJ = True <EOL> verbose = False <EOL> TOL = <NUM_LIT> <EOL> FLR = <NUM_LIT> <EOL> CONDUCTIVITY = <NUM_LIT> <EOL> MU = mu_0 <EOL> freq = <NUM_LIT> <EOL> addrandoms = True <EOL> SrcType = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> def derivTest ( fdemType , comp ) : <EOL> prb = getFDEMProblem ( fdemType , comp , SrcType , freq ) <EOL> print '<STR_LIT>' % ( fdemType , comp ) <EOL> x0 = np . log ( np . ones ( prb . mapping . nP ) * CONDUCTIVITY ) <EOL> mu = np . log ( np . ones ( prb . mesh . nC ) * MU ) <EOL> if addrandoms is True : <EOL> x0 = x0 + np . random . randn ( prb . mapping . nP ) * np . log ( CONDUCTIVITY ) * <NUM_LIT> <EOL> mu = mu + np . random . randn ( prb . mapping . nP ) * MU * <NUM_LIT> <EOL> survey = prb . survey <EOL> def fun ( x ) : <EOL> return survey . dpred ( x ) , lambda x : prb . Jvec ( x0 , x ) <EOL> return Tests . checkDerivative ( fun , x0 , num = <NUM_LIT:2> , plotIt = False , eps = FLR ) <EOL> class FDEM_DerivTests ( unittest . TestCase ) : <EOL> if testE : <EOL> def test_Jvec_exr_Eform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:e>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_eyr_Eform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:e>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_ezr_Eform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:e>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_exi_Eform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:e>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_eyi_Eform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:e>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_ezi_Eform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:e>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_bxr_Eform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:e>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_byr_Eform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:e>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_bzr_Eform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:e>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_bxi_Eform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:e>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_byi_Eform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:e>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_bzi_Eform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:e>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_exr_Eform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:e>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_eyr_Eform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:e>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_ezr_Eform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:e>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_exi_Eform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:e>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_eyi_Eform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:e>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_ezi_Eform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:e>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_bxr_Eform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:e>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_byr_Eform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:e>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_bzr_Eform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:e>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_bxi_Eform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:e>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_byi_Eform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:e>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_bzi_Eform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:e>' , '<STR_LIT>' ) ) <EOL> if testB : <EOL> def test_Jvec_exr_Bform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:b>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_eyr_Bform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:b>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_ezr_Bform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:b>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_exi_Bform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:b>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_eyi_Bform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:b>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_ezi_Bform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:b>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_bxr_Bform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:b>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_byr_Bform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:b>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_bzr_Bform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:b>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_bxi_Bform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:b>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_byi_Bform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:b>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_bzi_Bform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:b>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_jxr_Bform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:b>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_jyr_Bform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:b>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_jzr_Bform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:b>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_jxi_Bform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:b>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_jyi_Bform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:b>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_jzi_Bform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:b>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_hxr_Bform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:b>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_hyr_Bform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:b>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_hzr_Bform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:b>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_hxi_Bform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:b>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_hyi_Bform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:b>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_hzi_Bform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:b>' , '<STR_LIT>' ) ) <EOL> if testJ : <EOL> def test_Jvec_jxr_Jform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_jyr_Jform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_jzr_Jform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_jxi_Jform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_jyi_Jform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_jzi_Jform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_hxr_Jform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_hyr_Jform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_hzr_Jform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_hxi_Jform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_hyi_Jform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_hzi_Jform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_exr_Jform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_eyr_Jform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_ezr_Jform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_exi_Jform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_eyi_Jform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_ezi_Jform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_bxr_Jform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_byr_Jform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_bzr_Jform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_bxi_Jform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_byi_Jform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_bzi_Jform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> if testH : <EOL> def test_Jvec_hxr_Hform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:h>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_hyr_Hform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:h>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_hzr_Hform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:h>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_hxi_Hform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:h>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_hyi_Hform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:h>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_hzi_Hform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:h>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_hxr_Hform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:h>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_hyr_Hform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:h>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_hzr_Hform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:h>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_hxi_Hform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:h>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_hyi_Hform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:h>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_hzi_Hform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:h>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_exr_Hform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:h>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_eyr_Hform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:h>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_ezr_Hform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:h>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_exi_Hform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:h>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_eyi_Hform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:h>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_ezi_Hform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:h>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_bxr_Hform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:h>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_byr_Hform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:h>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_bzr_Hform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:h>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_bxi_Hform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:h>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_byi_Hform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:h>' , '<STR_LIT>' ) ) <EOL> def test_Jvec_bzi_Hform ( self ) : <EOL> self . assertTrue ( derivTest ( '<STR_LIT:h>' , '<STR_LIT>' ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
