mirror of
https://github.com/wassname/simpeg.git
synced 2026-09-12 12:51:28 +08:00
Merge branch 'dev' of https://github.com/simpeg/simpeg into feat/treeMeshCounting
Conflicts: .travis.yml SimPEG/Utils/__init__.py
This commit is contained in:
@@ -26,7 +26,14 @@ def SolverWrapD(fun, factorize=True, checkAccuracy=True, accuracyTol=1e-6):
|
||||
|
||||
def __init__(self, A, **kwargs):
|
||||
self.A = A.tocsc()
|
||||
|
||||
self.checkAccuracy = kwargs.get("checkAccuracy", checkAccuracy)
|
||||
if kwargs.has_key("checkAccuracy"): del kwargs["checkAccuracy"]
|
||||
self.accuracyTol = kwargs.get("accuracyTol", accuracyTol)
|
||||
if kwargs.has_key("accuracyTol"): del kwargs["accuracyTol"]
|
||||
|
||||
self.kwargs = kwargs
|
||||
|
||||
if factorize:
|
||||
self.solver = fun(self.A, **kwargs)
|
||||
|
||||
@@ -57,8 +64,8 @@ def SolverWrapD(fun, factorize=True, checkAccuracy=True, accuracyTol=1e-6):
|
||||
else:
|
||||
X[:,i] = fun(self.A, b[:,i], **self.kwargs)
|
||||
|
||||
if checkAccuracy:
|
||||
_checkAccuracy(self.A, b, X, accuracyTol)
|
||||
if self.checkAccuracy:
|
||||
_checkAccuracy(self.A, b, X, self.accuracyTol)
|
||||
return X
|
||||
|
||||
def clean(self):
|
||||
@@ -81,6 +88,12 @@ def SolverWrapI(fun, checkAccuracy=True, accuracyTol=1e-5):
|
||||
|
||||
def __init__(self, A, **kwargs):
|
||||
self.A = A
|
||||
|
||||
self.checkAccuracy = kwargs.get("checkAccuracy", checkAccuracy)
|
||||
if kwargs.has_key("checkAccuracy"): del kwargs["checkAccuracy"]
|
||||
self.accuracyTol = kwargs.get("accuracyTol", accuracyTol)
|
||||
if kwargs.has_key("accuracyTol"): del kwargs["accuracyTol"]
|
||||
|
||||
self.kwargs = kwargs
|
||||
|
||||
def __mul__(self, b):
|
||||
@@ -108,8 +121,8 @@ def SolverWrapI(fun, checkAccuracy=True, accuracyTol=1e-5):
|
||||
else:
|
||||
X[:,i] = out
|
||||
|
||||
if checkAccuracy:
|
||||
_checkAccuracy(self.A, b, X, accuracyTol)
|
||||
if self.checkAccuracy:
|
||||
_checkAccuracy(self.A, b, X, self.accuracyTol)
|
||||
return X
|
||||
|
||||
def clean(self):
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
from matutils import *
|
||||
from codeutils import *
|
||||
from meshutils import exampleLrmGrid, meshTensor, closestPoints, readUBCTensorMesh, writeUBCTensorMesh, writeUBCocTreeFiles, readUBCocTreeFiles, writeUBCTensorModel, readVTRFile, writeVTRFile, writeVTUFile
|
||||
from meshutils import *
|
||||
from curvutils import volTetra, faceInfo, indexCube
|
||||
from interputils import interpmat
|
||||
from ipythonutils import easyAnimate as animate
|
||||
from CounterUtils import *
|
||||
import ModelBuilder
|
||||
import SolverUtils
|
||||
|
||||
@@ -17,7 +17,7 @@ def memProfileWrapper(towrap, *funNames):
|
||||
|
||||
For example::
|
||||
|
||||
foo_mem = memProfile(foo,'my_func')
|
||||
foo_mem = memProfileWrapper(foo,['my_func'])
|
||||
fooi = foo_mem()
|
||||
for i in range(5):
|
||||
fooi.my_func()
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
from tempfile import NamedTemporaryFile
|
||||
import matplotlib.pyplot as plt
|
||||
from matplotlib import animation
|
||||
|
||||
# http://jakevdp.github.io/blog/2013/05/12/embedding-matplotlib-animations/
|
||||
# http://www.renevolution.com/how-to-install-ffmpeg-on-mac-os-x/
|
||||
|
||||
VIDEO_TAG = """<video controls loop>
|
||||
<source src="data:video/x-m4v;base64,{0}" type="video/mp4">
|
||||
Your browser does not support the video tag.
|
||||
</video>"""
|
||||
|
||||
def anim_to_html(anim):
|
||||
if not hasattr(anim, '_encoded_video'):
|
||||
with NamedTemporaryFile(suffix='.mp4') as f:
|
||||
anim.save(f.name, fps=20, extra_args=['-vcodec', 'libx264', '-pix_fmt', 'yuv420p'])
|
||||
video = open(f.name, "rb").read()
|
||||
anim._encoded_video = video.encode("base64")
|
||||
|
||||
return VIDEO_TAG.format(anim._encoded_video)
|
||||
|
||||
def display_animation(anim):
|
||||
plt.close(anim._fig)
|
||||
return anim_to_html(anim)
|
||||
|
||||
animation.Animation._repr_html_ = display_animation
|
||||
|
||||
easyAnimate = animation.FuncAnimation
|
||||
Reference in New Issue
Block a user