Futurize 1, futurize 2, pasteurize.

This commit is contained in:
Brendan Smithyman
2016-07-16 14:17:02 -05:00
parent 362975d2bd
commit ca8d8f8c2d
197 changed files with 2618 additions and 1235 deletions
+6
View File
@@ -1,3 +1,9 @@
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()
import os
import glob
import unittest
+14 -7
View File
@@ -1,3 +1,10 @@
from __future__ import print_function
from __future__ import division
from __future__ import unicode_literals
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()
from past.utils import old_div
import unittest
from SimPEG import Mesh, Utils, EM, Maps, np
import SimPEG.EM.Static.DC as DC
@@ -32,7 +39,7 @@ class DCProblemAnalyticTests(unittest.TestCase):
try:
from pymatsolver import MumpsSolver
self.Solver = MumpsSolver
except ImportError, e:
except ImportError as e:
self.Solver = SolverLU
def test_Problem3D_N(self):
@@ -41,13 +48,13 @@ class DCProblemAnalyticTests(unittest.TestCase):
problem.Solver = self.Solver
problem.pair(self.survey)
data = self.survey.dpred(self.sigma)
err= np.linalg.norm((data-self.data_anal)/self.data_anal)**2 / self.data_anal.size
err= old_div(np.linalg.norm(old_div((data-self.data_anal),self.data_anal))**2, self.data_anal.size)
if err < 0.05:
passed = True
print ">> DC analytic test for Problem3D_N is passed"
print(">> DC analytic test for Problem3D_N is passed")
else:
passed = False
print ">> DC analytic test for Problem3D_N is failed"
print(">> DC analytic test for Problem3D_N is failed")
self.assertTrue(passed)
def test_Problem3D_CC(self):
@@ -55,13 +62,13 @@ class DCProblemAnalyticTests(unittest.TestCase):
problem.Solver = self.Solver
problem.pair(self.survey)
data = self.survey.dpred(self.sigma)
err= np.linalg.norm((data-self.data_anal)/self.data_anal)**2 / self.data_anal.size
err= old_div(np.linalg.norm(old_div((data-self.data_anal),self.data_anal))**2, self.data_anal.size)
if err < 0.05:
passed = True
print ">> DC analytic test for Problem3D_CC is passed"
print(">> DC analytic test for Problem3D_CC is passed")
else:
passed = False
print ">> DC analytic test for Problem3D_CC is failed"
print(">> DC analytic test for Problem3D_CC is failed")
self.assertTrue(passed)
if __name__ == '__main__':
+8 -2
View File
@@ -1,3 +1,9 @@
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()
import unittest
from SimPEG import *
import SimPEG.EM.Static.DC as DC
@@ -55,7 +61,7 @@ class DCProblem_2DTestsCC(unittest.TestCase):
wtJv = w.dot(self.p.Jvec(self.m0, v))
vtJtw = v.dot(self.p.Jtvec(self.m0, w))
passed = np.abs(wtJv - vtJtw) < 1e-10
print 'Adjoint Test', np.abs(wtJv - vtJtw), passed
print('Adjoint Test', np.abs(wtJv - vtJtw), passed)
self.assertTrue(passed)
def test_dataObj(self):
@@ -115,7 +121,7 @@ class DCProblemTestsN(unittest.TestCase):
wtJv = w.dot(self.p.Jvec(self.m0, v))
vtJtw = v.dot(self.p.Jtvec(self.m0, w))
passed = np.abs(wtJv - vtJtw) < 1e-8
print 'Adjoint Test', np.abs(wtJv - vtJtw), passed
print('Adjoint Test', np.abs(wtJv - vtJtw), passed)
self.assertTrue(passed)
def test_dataObj(self):
+14 -7
View File
@@ -1,3 +1,10 @@
from __future__ import print_function
from __future__ import division
from __future__ import unicode_literals
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()
from past.utils import old_div
import unittest
from SimPEG import Mesh, Utils, EM, Maps, np
import SimPEG.EM.Static.DC as DC
@@ -35,7 +42,7 @@ class DCProblemAnalyticTests(unittest.TestCase):
try:
from pymatsolver import MumpsSolver
self.Solver = MumpsSolver
except ImportError, e:
except ImportError as e:
self.Solver = SolverLU
def test_Problem3D_N(self):
@@ -43,13 +50,13 @@ class DCProblemAnalyticTests(unittest.TestCase):
problem.Solver = self.Solver
problem.pair(self.survey)
data = self.survey.dpred(self.sigma)
err= np.linalg.norm(data-self.data_anal)/np.linalg.norm(self.data_anal)
err= old_div(np.linalg.norm(data-self.data_anal),np.linalg.norm(self.data_anal))
if err < 0.2:
passed = True
print ">> DC analytic test for Problem3D_N is passed"
print(">> DC analytic test for Problem3D_N is passed")
else:
passed = False
print ">> DC analytic test for Problem3D_N is failed"
print(">> DC analytic test for Problem3D_N is failed")
self.assertTrue(passed)
def test_Problem3D_CC(self):
@@ -57,13 +64,13 @@ class DCProblemAnalyticTests(unittest.TestCase):
problem.Solver = self.Solver
problem.pair(self.survey)
data = self.survey.dpred(self.sigma)
err= np.linalg.norm(data-self.data_anal)/np.linalg.norm(self.data_anal)
err= old_div(np.linalg.norm(data-self.data_anal),np.linalg.norm(self.data_anal))
if err < 0.2:
passed = True
print ">> DC analytic test for Problem3D_CC is passed"
print(">> DC analytic test for Problem3D_CC is passed")
else:
passed = False
print ">> DC analytic test for Problem3D_CC is failed"
print(">> DC analytic test for Problem3D_CC is failed")
self.assertTrue(passed)
if __name__ == '__main__':
+11 -4
View File
@@ -1,3 +1,10 @@
from __future__ import print_function
from __future__ import division
from __future__ import unicode_literals
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()
from past.utils import old_div
import unittest
from SimPEG import *
import SimPEG.EM.Static.DC as DC
@@ -14,7 +21,7 @@ class DCProblemTestsCC(unittest.TestCase):
cs = surveySize/nElecs/4
mesh = Mesh.TensorMesh([
[(cs,10, -1.3),(cs,surveySize/cs),(cs,10, 1.3)],
[(cs,10, -1.3),(cs,old_div(surveySize,cs)),(cs,10, 1.3)],
[(cs,3, -1.3),(cs,3,1.3)],
# [(cs,5, -1.3),(cs,10)]
],'CN')
@@ -55,7 +62,7 @@ class DCProblemTestsCC(unittest.TestCase):
wtJv = w.dot(self.p.Jvec(self.m0, v))
vtJtw = v.dot(self.p.Jtvec(self.m0, w))
passed = np.abs(wtJv - vtJtw) < 1e-10
print 'Adjoint Test', np.abs(wtJv - vtJtw), passed
print('Adjoint Test', np.abs(wtJv - vtJtw), passed)
self.assertTrue(passed)
def test_dataObj(self):
@@ -74,7 +81,7 @@ class DCProblemTestsN(unittest.TestCase):
cs = surveySize/nElecs/4
mesh = Mesh.TensorMesh([
[(cs,10, -1.3),(cs,surveySize/cs),(cs,10, 1.3)],
[(cs,10, -1.3),(cs,old_div(surveySize,cs)),(cs,10, 1.3)],
[(cs,3, -1.3),(cs,3,1.3)],
# [(cs,5, -1.3),(cs,10)]
],'CN')
@@ -115,7 +122,7 @@ class DCProblemTestsN(unittest.TestCase):
wtJv = w.dot(self.p.Jvec(self.m0, v))
vtJtw = v.dot(self.p.Jtvec(self.m0, w))
passed = np.abs(wtJv - vtJtw) < 1e-8
print 'Adjoint Test', np.abs(wtJv - vtJtw), passed
print('Adjoint Test', np.abs(wtJv - vtJtw), passed)
self.assertTrue(passed)
def test_dataObj(self):
+15 -8
View File
@@ -1,3 +1,10 @@
from __future__ import print_function
from __future__ import division
from __future__ import unicode_literals
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()
from past.utils import old_div
import unittest
from SimPEG import Mesh, Utils, EM, Maps, np
import SimPEG.EM.Static.DC as DC
@@ -42,7 +49,7 @@ class IPProblemAnalyticTests(unittest.TestCase):
try:
from pymatsolver import MumpsSolver
self.Solver = MumpsSolver
except ImportError, e:
except ImportError as e:
self.Solver = SolverLU
def test_Problem3D_N(self):
@@ -59,13 +66,13 @@ class IPProblemAnalyticTests(unittest.TestCase):
problemIP.pair(surveyIP)
data_full = data0 - datainf
data = surveyIP.dpred(self.eta)
err= np.linalg.norm((data-data_full)/data_full)**2 / data_full.size
err= old_div(np.linalg.norm(old_div((data-data_full),data_full))**2, data_full.size)
if err < 0.05:
passed = True
print ">> IP forward test for Problem3D_N is passed"
print(">> IP forward test for Problem3D_N is passed")
else:
passed = False
print ">> IP forward test for Problem3D_N is failed"
print(">> IP forward test for Problem3D_N is failed")
self.assertTrue(passed)
def test_Problem3D_CC(self):
@@ -76,19 +83,19 @@ class IPProblemAnalyticTests(unittest.TestCase):
data0 = self.surveyDC.dpred(self.sigma0)
finf = problemDC.fields(self.sigmaInf)
datainf = self.surveyDC.dpred(self.sigmaInf, f=finf)
problemIP = IP.Problem3D_CC(self.mesh, rho=1./self.sigmaInf, Ainv=problemDC.Ainv, f=finf)
problemIP = IP.Problem3D_CC(self.mesh, rho=old_div(1.,self.sigmaInf), Ainv=problemDC.Ainv, f=finf)
problemIP.Solver = self.Solver
surveyIP = IP.Survey([self.src])
problemIP.pair(surveyIP)
data_full = data0 - datainf
data = surveyIP.dpred(self.eta)
err= np.linalg.norm((data-data_full)/data_full)**2 / data_full.size
err= old_div(np.linalg.norm(old_div((data-data_full),data_full))**2, data_full.size)
if err < 0.05:
passed = True
print ">> IP forward test for Problem3D_CC is passed"
print(">> IP forward test for Problem3D_CC is passed")
else:
passed = False
print ">> IP forward test for Problem3D_CC is failed"
print(">> IP forward test for Problem3D_CC is failed")
self.assertTrue(passed)
if __name__ == '__main__':
+12 -5
View File
@@ -1,3 +1,10 @@
from __future__ import print_function
from __future__ import division
from __future__ import unicode_literals
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()
from past.utils import old_div
import unittest
from SimPEG import *
import SimPEG.EM.Static.DC as DC
@@ -15,7 +22,7 @@ class IPProblemTestsCC(unittest.TestCase):
cs = surveySize/nElecs/4
mesh = Mesh.TensorMesh([
[(cs,10, -1.3),(cs,surveySize/cs),(cs,10, 1.3)],
[(cs,10, -1.3),(cs,old_div(surveySize,cs)),(cs,10, 1.3)],
[(cs,3, -1.3),(cs,3,1.3)],
# [(cs,5, -1.3),(cs,10)]
],'CN')
@@ -23,7 +30,7 @@ class IPProblemTestsCC(unittest.TestCase):
srcList = DC.Utils.WennerSrcList(nElecs, aSpacing, in2D=True)
survey = IP.Survey(srcList)
sigma = np.ones(mesh.nC)
problem = IP.Problem3D_CC(mesh, rho=1./sigma)
problem = IP.Problem3D_CC(mesh, rho=old_div(1.,sigma))
problem.pair(survey)
mSynth = np.ones(mesh.nC)*0.1
survey.makeSyntheticData(mSynth)
@@ -55,7 +62,7 @@ class IPProblemTestsCC(unittest.TestCase):
wtJv = w.dot(self.p.Jvec(self.m0, v))
vtJtw = v.dot(self.p.Jtvec(self.m0, w))
passed = np.abs(wtJv - vtJtw) < 1e-10
print 'Adjoint Test', np.abs(wtJv - vtJtw), passed
print('Adjoint Test', np.abs(wtJv - vtJtw), passed)
self.assertTrue(passed)
def test_dataObj(self):
@@ -74,7 +81,7 @@ class IPProblemTestsN(unittest.TestCase):
cs = surveySize/nElecs/4
mesh = Mesh.TensorMesh([
[(cs,10, -1.3),(cs,surveySize/cs),(cs,10, 1.3)],
[(cs,10, -1.3),(cs,old_div(surveySize,cs)),(cs,10, 1.3)],
[(cs,3, -1.3),(cs,3,1.3)],
# [(cs,5, -1.3),(cs,10)]
],'CN')
@@ -114,7 +121,7 @@ class IPProblemTestsN(unittest.TestCase):
wtJv = w.dot(self.p.Jvec(self.m0, v))
vtJtw = v.dot(self.p.Jtvec(self.m0, w))
passed = np.abs(wtJv - vtJtw) < 1e-8
print 'Adjoint Test', np.abs(wtJv - vtJtw), passed
print('Adjoint Test', np.abs(wtJv - vtJtw), passed)
self.assertTrue(passed)
def test_dataObj(self):
+15 -7
View File
@@ -1,3 +1,11 @@
from __future__ import print_function
from __future__ import division
from __future__ import unicode_literals
from __future__ import absolute_import
from builtins import int
from future import standard_library
standard_library.install_aliases()
from past.utils import old_div
import unittest
from SimPEG import *
import SimPEG
@@ -37,10 +45,10 @@ class IPProblemTestsCC(unittest.TestCase):
src = SIP.Src.Dipole([rx], Aloc, Bloc)
survey = SIP.Survey([src])
colemap = [("eta", Maps.IdentityMap(mesh)), ("taui", Maps.IdentityMap(mesh))]
problem = SIP.Problem3D_CC(mesh, rho=1./sigma, mapping=colemap)
problem = SIP.Problem3D_CC(mesh, rho=old_div(1.,sigma), mapping=colemap)
problem.Solver = MumpsSolver
problem.pair(survey)
mSynth = np.r_[eta, 1./tau]
mSynth = np.r_[eta, old_div(1.,tau)]
survey.makeSyntheticData(mSynth)
# Now set up the problem to do some minimization
dmis = DataMisfit.l2_DataMisfit(survey)
@@ -70,7 +78,7 @@ class IPProblemTestsCC(unittest.TestCase):
wtJv = w.dot(self.p.Jvec(self.m0, v))
vtJtw = v.dot(self.p.Jtvec(self.m0, w))
passed = np.abs(wtJv - vtJtw) < 1e-10
print 'Adjoint Test', np.abs(wtJv - vtJtw), passed
print('Adjoint Test', np.abs(wtJv - vtJtw), passed)
self.assertTrue(passed)
def test_dataObj(self):
@@ -112,7 +120,7 @@ class IPProblemTestsN(unittest.TestCase):
problem = SIP.Problem3D_N(mesh, sigma=sigma, mapping=colemap)
problem.Solver = MumpsSolver
problem.pair(survey)
mSynth = np.r_[eta, 1./tau]
mSynth = np.r_[eta, old_div(1.,tau)]
survey.makeSyntheticData(mSynth)
# Now set up the problem to do some minimization
dmis = DataMisfit.l2_DataMisfit(survey)
@@ -142,7 +150,7 @@ class IPProblemTestsN(unittest.TestCase):
wtJv = w.dot(self.p.Jvec(self.m0, v))
vtJtw = v.dot(self.p.Jtvec(self.m0, w))
passed = np.abs(wtJv - vtJtw) < 1e-8
print 'Adjoint Test', np.abs(wtJv - vtJtw), passed
print('Adjoint Test', np.abs(wtJv - vtJtw), passed)
self.assertTrue(passed)
def test_dataObj(self):
@@ -189,7 +197,7 @@ class IPProblemTestsN_air(unittest.TestCase):
problem = SIP.Problem3D_N(mesh, sigma=sigma, mapping=colemap)
problem.Solver = MumpsSolver
problem.pair(survey)
mSynth = np.r_[eta[~airind], 1./tau[~airind]]
mSynth = np.r_[eta[~airind], old_div(1.,tau[~airind])]
survey.makeSyntheticData(mSynth)
# Now set up the problem to do some minimization
dmis = DataMisfit.l2_DataMisfit(survey)
@@ -220,7 +228,7 @@ class IPProblemTestsN_air(unittest.TestCase):
wtJv = w.dot(self.p.Jvec(self.m0, v))
vtJtw = v.dot(self.p.Jtvec(self.m0, w))
passed = np.abs(wtJv - vtJtw) < 1e-8
print 'Adjoint Test', np.abs(wtJv - vtJtw), passed
print('Adjoint Test', np.abs(wtJv - vtJtw), passed)
self.assertTrue(passed)
def test_dataObj(self):