Skip to content

Commit

Permalink
Fixing non-integer slice indices error.
Browse files Browse the repository at this point in the history
Slice object arguments not explicitly cast to integers previously, which seems to
raise exceptions in newer NumPy versions.
  • Loading branch information
matt-graham committed May 17, 2018
1 parent b1277bd commit 7b925a7
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pompy/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,14 @@ def generate_single_array(self, puff_array):
# the possibility of the kernel being partly outside the
# extents of the destination array
(w, h) = kernel.shape
r_rng_arr = slice(max(0, u - w / 2.),
max(min(u + w / 2., self.nx), 0))
c_rng_arr = slice(max(0, v - h / 2.),
max(min(v + h / 2., self.ny), 0))
r_rng_knl = slice(max(0, -u + w / 2.),
min(-u + w / 2. + self.nx, w))
c_rng_knl = slice(max(0, -v + h / 2.),
min(-v + h / 2. + self.ny, h))
r_rng_arr = slice(int(max(0, u - w / 2.)),
int(max(min(u + w / 2., self.nx), 0)))
c_rng_arr = slice(int(max(0, v - h / 2.)),
int(max(min(v + h / 2., self.ny), 0)))
r_rng_knl = slice(int(max(0, -u + w / 2.)),
int(min(-u + w / 2. + self.nx, w)))
c_rng_knl = slice(int(max(0, -v + h / 2.)),
int(min(-v + h / 2. + self.ny, h)))
# add puff kernel values to concentration field array
conc_array[r_rng_arr, c_rng_arr] += kernel[r_rng_knl, c_rng_knl]
return conc_array
Expand Down

0 comments on commit 7b925a7

Please sign in to comment.