New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ref/tdem testing #620
Ref/tdem testing #620
Conversation
lheagy
commented
Jun 24, 2017
- clean up in the time domain testing
- efficiency fix in the Problem class. Now we check if the model has truly updated before clearing matrices:
SimPEG/Problem.py
Outdated
if hasattr(self, prop): | ||
delattr(self, prop) | ||
def _on_model_update(self, change): | ||
if self.model is None or not np.allclose(self.model, change['value']): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if an early exit of self.model is change['value']
would be faster. If the model is large a point wise comparison is going to be slow. If they are pointing to the same block in memory, then we can skip that.
|
||
# class TDEM_DerivTests(unittest.TestCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to have these tests perhaps tested on dev-->master? Just so that we know that it is still working, because they are useful for debugging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right now the TDEM tests are still timing out, so this would first take some re-organizing of tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this back on the test_TDEM_DerivAdjoint
Codecov Report
@@ Coverage Diff @@
## em/dev #620 +/- ##
==========================================
- Coverage 74.33% 74.32% -0.01%
==========================================
Files 105 105
Lines 13956 13960 +4
==========================================
+ Hits 10374 10376 +2
- Misses 3582 3584 +2
Continue to review full report at Codecov.
|
SimPEG/Problem.py
Outdated
if hasattr(self, prop): | ||
delattr(self, prop) | ||
def _on_model_update(self, change): | ||
if self.model is change['value']: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change['prev'] is change['value']
the model will always be the value!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the if (not this and not that) a bit unclear as to why you would skip the check. If you are checking a corner case, then I would say err on the side of clearing model dependence and just remove this logic?
However, if your check on undefined
and None
is to make sure that these don't fail the np.allclose
then I would suggest changing that to
isinstance(change['previous'], np.ndarray) and
isinstance(change['value'], np.ndarray) and
np.allclose(change['previous'], change['value'])
Which is checking what you actually want...!
So something like:
if change['previous'] is change['value']:
return # model has not changed
if (
isinstance(change['previous'], np.ndarray) and
isinstance(change['value'], np.ndarray) and
np.allclose(change['previous'], change['value'])
):
return # model has not *really* changed
I think your current code would break by setting model to properties.undefined
, for example.
SimPEG/Problem.py
Outdated
if change['previous'] is change['value']: | ||
return | ||
if ( | ||
not isinstance(change['previous'], properties.utils.Sentinel) and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that you can say change['previous'] is not properties.undefined
there is only ever one instance of the sentinel hanging around, and it is much more clear what you care looking to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perfect, thanks @rowanc1
…not clearing property matrices
…s in test_TDEM_DerivAdjoint
@@ -1,160 +0,0 @@ | |||
from __future__ import division, print_function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated test_TDEM_DerivAdjoint to test multiple sources, so this test is now redundant
@@ -130,7 +130,8 @@ def test_misfit(self): | |||
self.survey.dpred(m), lambda mx: self.p.Jvec(self.m0, mx) | |||
], | |||
self.m0, | |||
plotIt=False | |||
plotIt=False, | |||
num=3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sgkang: I fixed the number of iterations this runs. If we let it go too far it fails b/c we hit machine precision.
download([url+f for f in cloudfiles], folder=basePath, overwrite=True) | ||
# directory where the downloaded files are | ||
|
||
url = "https://storage.googleapis.com/simpeg/Chile_GRAV_4_Miller/Chile_GRAV_4_Miller.tar.gz" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
url = "https://storage.googleapis.com/simpeg/Chile_GRAV_4_Miller/Chile_GRAV_4_Miller.tar.gz" | ||
downloads = download(url, overwrite=True) | ||
basePath = downloads.split(".")[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have also downloaded to the current directory (a folder called Chile_GRAV_4_Miller will be created). This makes it easier to work with different systems and to keep track of the files (esp on travis)
cache docs examples
…reated when tar unzipped
@@ -392,7 +392,7 @@ def run(plotIt=True, saveFig=False, cleanup=True): | |||
|
|||
ax0.semilogx(sigma_re, z, 'k', lw=2, label="RESOLVE") | |||
ax0.semilogx(sigma_sky, z, 'b', lw=2, label="SkyTEM") | |||
ax0.set_ylim(-100, 0) | |||
ax0.set_ylim(-50, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the range we used in the paper
# Download to Downloads/SimPEGtemp | ||
basePath = os.path.expanduser('~/Downloads/simpegtemp') | ||
download([url+f for f in cloudfiles], folder=basePath, overwrite=True) | ||
url = "https://storage.googleapis.com/simpeg/Chile_GRAV_4_Miller/Chile_GRAV_4_Miller.tar.gz" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fourndo are you good with this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm good with that.
… nan. Thumbs up of the merge - DF
@@ -2,7 +2,7 @@ | |||
import numpy as np | |||
from scipy.interpolate import griddata, interp1d | |||
|
|||
def surface2ind_topo(mesh, topo, gridLoc='CC', method='cubic', fill_value=np.nan): | |||
def surface2ind_topo(mesh, topo, gridLoc='CC', method='nearest', fill_value=np.nan): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @fourndo!
Thanks for your input all! |