[yt-svn] commit/yt: MatthewTurk: Sam and I worked through it, and we spotted that when your bounds hit the max

Bitbucket commits-noreply at bitbucket.org
Wed Aug 1 12:21:49 PDT 2012


1 new commit in yt:


https://bitbucket.org/yt_analysis/yt/changeset/3c2ce08a8633/
changeset:   3c2ce08a8633
branch:      yt
user:        MatthewTurk
date:        2012-08-01 21:20:59
summary:     Sam and I worked through it, and we spotted that when your bounds hit the max
value in a sim this could lead to spurious reads from memory.

Closes #390 .
affected #:  1 file

diff -r 2ff4b99601585798c457e113af85c56dd80ba67f -r 3c2ce08a863303a80b057f8f9fba38af0866b5b6 yt/utilities/lib/field_interpolation_tables.pxd
--- a/yt/utilities/lib/field_interpolation_tables.pxd
+++ b/yt/utilities/lib/field_interpolation_tables.pxd
@@ -50,7 +50,7 @@
               int field_id, int weight_field_id, int weight_table_id) nogil:
     fit.bounds[0] = bounds1; fit.bounds[1] = bounds2
     fit.nbins = nbins
-    fit.dbin = (fit.bounds[1] - fit.bounds[0])/fit.nbins
+    fit.dbin = (fit.bounds[1] - fit.bounds[0])/(fit.nbins-1)
     fit.idbin = 1.0/fit.dbin
     # Better not pull this out from under us, yo
     fit.values = values
@@ -65,8 +65,9 @@
                                        np.float64_t dvs[6]) nogil:
     cdef np.float64_t bv, dy, dd, tf, rv
     cdef int bin_id
-    if dvs[fit.field_id] > fit.bounds[1] or dvs[fit.field_id] < fit.bounds[0]: return 0.0
+    if dvs[fit.field_id] >= fit.bounds[1] or dvs[fit.field_id] <= fit.bounds[0]: return 0.0
     bin_id = <int> ((dvs[fit.field_id] - fit.bounds[0]) * fit.idbin)
+    bin_id = iclip(bin_id, 0, fit.nbins-2)
     dd = dvs[fit.field_id] - (fit.bounds[0] + bin_id * fit.dbin) # x - x0
     bv = fit.values[bin_id]
     dy = fit.values[bin_id + 1] - bv

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