[yt-svn] commit/yt: MatthewTurk: Merged in chummels/yt (pull request #1313)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Fri Nov 21 18:18:15 PST 2014
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/340a245199ef/
Changeset: 340a245199ef
Branch: yt
User: MatthewTurk
Date: 2014-11-22 02:18:06+00:00
Summary: Merged in chummels/yt (pull request #1313)
Fixes warnings with `divide by zero` in some projections
Affected #: 2 files
diff -r b07a3328710256a1d765284337b45d710a8ca715 -r 340a245199ef6d426bf886761e9e41eadfb70a8b yt/data_objects/construction_data_containers.py
--- a/yt/data_objects/construction_data_containers.py
+++ b/yt/data_objects/construction_data_containers.py
@@ -317,7 +317,12 @@
np.add(py, oy, py)
np.multiply(pdy, self.ds.domain_width[yax], pdy)
if self.weight_field is not None:
- np.divide(nvals, nwvals[:,None], nvals)
+ # If there are 0s remaining in the weight vals
+ # this will not throw an error, but silently
+ # return nans for vals where dividing by 0
+ # Leave as NaNs to be auto-masked by Matplotlib
+ with np.errstate(invalid='ignore'):
+ np.divide(nvals, nwvals[:,None], nvals)
# We now convert to half-widths and center-points
data = {}
#non_nan = ~np.any(np.isnan(nvals), axis=-1)
diff -r b07a3328710256a1d765284337b45d710a8ca715 -r 340a245199ef6d426bf886761e9e41eadfb70a8b yt/data_objects/octree_subset.py
--- a/yt/data_objects/octree_subset.py
+++ b/yt/data_objects/octree_subset.py
@@ -265,7 +265,12 @@
self.fcoords, fields,
self.domain_id, self._domain_offset, self.ds.periodicity,
index_fields, particle_octree, pdom_ind, self.ds.geometry)
- vals = op.finalize()
+ # If there are 0s in the smoothing field this will not throw an error,
+ # but silently return nans for vals where dividing by 0
+ # Same as what is currently occurring, but suppressing the div by zero
+ # error.
+ with np.errstate(invalid='ignore'):
+ vals = op.finalize()
if vals is None: return
if isinstance(vals, list):
vals = [np.asfortranarray(v) for v in vals]
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list