[yt-svn] commit/yt: xarthisius: Merged in atmyers/yt (pull request #2241)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Wed Jun 29 11:23:03 PDT 2016


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/03a2de258276/
Changeset:   03a2de258276
Branch:      yt
User:        xarthisius
Date:        2016-06-29 18:22:52+00:00
Summary:     Merged in atmyers/yt (pull request #2241)

[OPT] Disable bounds checking on pixelize_element_mesh
Affected #:  2 files

diff -r f44aacc05874d84296ec4ffbe53f4f0a66d425b2 -r 03a2de258276003f6e70140a850ab2acee80aeee yt/utilities/lib/fp_utils.pxd
--- a/yt/utilities/lib/fp_utils.pxd
+++ b/yt/utilities/lib/fp_utils.pxd
@@ -50,11 +50,11 @@
                       np.float64_t a, np.float64_t b) nogil:
     return fmin(fmax(f, a), b)
 
-cdef inline np.int64_t i64max(np.int64_t i0, np.int64_t i1):
+cdef inline np.int64_t i64max(np.int64_t i0, np.int64_t i1) nogil:
     if i0 > i1: return i0
     return i1
 
-cdef inline np.int64_t i64min(np.int64_t i0, np.int64_t i1):
+cdef inline np.int64_t i64min(np.int64_t i0, np.int64_t i1) nogil:
     if i0 < i1: return i0
     return i1
 

diff -r f44aacc05874d84296ec4ffbe53f4f0a66d425b2 -r 03a2de258276003f6e70140a850ab2acee80aeee yt/utilities/lib/pixelization_routines.pyx
--- a/yt/utilities/lib/pixelization_routines.pyx
+++ b/yt/utilities/lib/pixelization_routines.pyx
@@ -32,7 +32,6 @@
     Q1Sampler2D, \
     W1Sampler3D
 
-
 cdef extern from "pixelization_constants.h":
     enum:
         MAX_NUM_FACES
@@ -618,57 +617,58 @@
         else:
             idds[i] = 1.0 / dds[i]
 
-    for ci in range(conn.shape[0]):
+    with cython.boundscheck(False):
+        for ci in range(conn.shape[0]):
 
-        # Fill the vertices
-        LE[0] = LE[1] = LE[2] = 1e60
-        RE[0] = RE[1] = RE[2] = -1e60
+            # Fill the vertices
+            LE[0] = LE[1] = LE[2] = 1e60
+            RE[0] = RE[1] = RE[2] = -1e60
 
-        for n in range(num_field_vals):
-            field_vals[n] = field[ci, n]
+            for n in range(num_field_vals):
+                field_vals[n] = field[ci, n]
 
-        for n in range(nvertices):
-            cj = conn[ci, n] - index_offset
+            for n in range(nvertices):
+                cj = conn[ci, n] - index_offset
+                for i in range(ndim):
+                    vertices[ndim*n + i] = coords[cj, i]
+                    LE[i] = fmin(LE[i], vertices[ndim*n+i])
+                    RE[i] = fmax(RE[i], vertices[ndim*n+i])
+
+            use = 1
             for i in range(ndim):
-                vertices[ndim*n + i] = coords[cj, i]
-                LE[i] = fmin(LE[i], vertices[ndim*n+i])
-                RE[i] = fmax(RE[i], vertices[ndim*n+i])
+                if RE[i] < pLE[i] or LE[i] >= pRE[i]:
+                    use = 0
+                    break
+                pstart[i] = i64max(<np.int64_t> ((LE[i] - pLE[i])*idds[i]) - 1, 0)
+                pend[i] = i64min(<np.int64_t> ((RE[i] - pLE[i])*idds[i]) + 1, img.shape[i]-1)
 
-        use = 1
-        for i in range(ndim):
-            if RE[i] < pLE[i] or LE[i] >= pRE[i]:
-                use = 0
-                break
-            pstart[i] = i64max(<np.int64_t> ((LE[i] - pLE[i])*idds[i]) - 1, 0)
-            pend[i] = i64min(<np.int64_t> ((RE[i] - pLE[i])*idds[i]) + 1, img.shape[i]-1)
+            # override for the 2D case
+            if ndim == 2:
+                pstart[2] = 0
+                pend[2] = 0
 
-        # override for the 2D case
-        if ndim == 2:
-            pstart[2] = 0
-            pend[2] = 0
+            if use == 0:
+                continue
 
-        if use == 0:
-            continue
-
-        # Now our bounding box intersects, so we get the extents of our pixel
-        # region which overlaps with the bounding box, and we'll check each
-        # pixel in there.
-        for pi in range(pstart[0], pend[0] + 1):
-            ppoint[0] = (pi + 0.5) * dds[0] + pLE[0]
-            for pj in range(pstart[1], pend[1] + 1):
-                ppoint[1] = (pj + 0.5) * dds[1] + pLE[1]
-                for pk in range(pstart[2], pend[2] + 1):
-                    ppoint[2] = (pk + 0.5) * dds[2] + pLE[2]
-                    # Now we just need to figure out if our ppoint is within
-                    # our set of vertices.
-                    sampler.map_real_to_unit(mapped_coord, vertices, ppoint)
-                    if not sampler.check_inside(mapped_coord):
-                        continue
-                    if (num_field_vals == 1):
-                        img[pi, pj, pk] = field_vals[0]
-                    else:
-                        img[pi, pj, pk] = sampler.sample_at_unit_point(mapped_coord,
-                                                                       field_vals)
+            # Now our bounding box intersects, so we get the extents of our pixel
+            # region which overlaps with the bounding box, and we'll check each
+            # pixel in there.
+            for pi in range(pstart[0], pend[0] + 1):
+                ppoint[0] = (pi + 0.5) * dds[0] + pLE[0]
+                for pj in range(pstart[1], pend[1] + 1):
+                    ppoint[1] = (pj + 0.5) * dds[1] + pLE[1]
+                    for pk in range(pstart[2], pend[2] + 1):
+                        ppoint[2] = (pk + 0.5) * dds[2] + pLE[2]
+                        # Now we just need to figure out if our ppoint is within
+                        # our set of vertices.
+                        sampler.map_real_to_unit(mapped_coord, vertices, ppoint)
+                        if not sampler.check_inside(mapped_coord):
+                            continue
+                        if (num_field_vals == 1):
+                            img[pi, pj, pk] = field_vals[0]
+                        else:
+                            img[pi, pj, pk] = sampler.sample_at_unit_point(mapped_coord,
+                                                                           field_vals)
     free(vertices)
     free(field_vals)
     return img

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