Skip to content

Commit

Permalink
Avoid enumerate in Cython, define type of all vars. Fixes #2766
Browse files Browse the repository at this point in the history
  • Loading branch information
Xarthisius committed Jul 20, 2020
1 parent fddd88c commit 24a7343
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions yt/geometry/oct_container.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -727,12 +727,13 @@ cdef class OctreeContainer:
np.int64_t offset = 0):
cdef np.ndarray[np.float64_t, ndim=2] source
cdef np.ndarray[np.float64_t, ndim=1] dest
cdef int i
cdef int i, lvl

for key in dest_fields:
dest = dest_fields[key]
source = source_fields[key]
for i, lvl in enumerate(levels):
for i in range(levels.shape[0]):
lvl = levels[i]
if lvl != level: continue
if file_inds[i] < 0:
dest[i + offset] = np.nan
Expand Down Expand Up @@ -819,13 +820,16 @@ cdef class OctreeContainer:
"""
cdef np.ndarray[np.float64_t, ndim=2] source
cdef np.ndarray[np.float64_t, ndim=1] dest
cdef int i, count
cdef int i, count, lev
cdef np.int32_t dom

for key in dest_fields:
dest = dest_fields[key]
source = source_fields[key]
count = 0
for i, (lev, dom) in enumerate(zip(levels, domains)):
for i in range(levels.shape[0]):
lev = levels[i]
dom = domains[i]
if lev != level or dom != domain: continue
count += 1
if file_inds[i] < 0:
Expand Down

0 comments on commit 24a7343

Please sign in to comment.